Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mocks.py « test - dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a04ec3a2dd19aa3e5b21a8b220e3e109e3c62020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# gajim-specific mock objects
from mock import Mock

from common import gajim

class MockConnection(Mock):
	def __init__(self, name, *args):
		Mock.__init__(self, *args)
		self.name = name
		gajim.connections[name] = self

class MockWindow(Mock):
	def __init__(self, *args):
		Mock.__init__(self, *args)
		self.window = Mock()

class MockChatControl(Mock):
	def __init__(self, *args):
		Mock.__init__(self, *args)

		self.parent_win = MockWindow({'get_active_control': self})
		self.session = None

	def set_session(self, sess):
		self.session = sess

	def __nonzero__(self):
		return True

	def __eq__(self, other):
		return self is other

class MockInterface(Mock):
	def __init__(self, acct, *args):
		Mock.__init__(self, *args)
		self.msg_win_mgr = Mock()
		self.roster = Mock()

		self.remote_ctrl = None
		self.minimized_controls = { acct: {} }

class MockLogger(Mock):
	def __init__(self):
		Mock.__init__(self, {'write': None})

class MockContact(Mock):
	def __nonzero__(self):
		return True

import random

class MockSession(Mock):
	def __init__(self, conn, jid, thread_id, type):
		Mock.__init__(self)

		self.conn = conn
		self.jid = jid
		self.type = type
		self.thread_id = thread_id

		if not self.thread_id:
			self.thread_id = '%0x' % random.randint(0, 10000)

	def __repr__(self):
		print '<MockSession %s>' % self.thread_id

	def __nonzero__(self):
		return True

# vim: se ts=3: