diff options
author | Brendan Taylor <bct@diffeq.com> | 2008-08-09 10:10:04 +0400 |
---|---|---|
committer | Brendan Taylor <bct@diffeq.com> | 2008-08-09 10:10:04 +0400 |
commit | 559a8c8b1359dfdb1cf2af2928c8c8b7e31e220b (patch) | |
tree | 8883b8b8b7b10db365372b4a4eebae73a0c93cf8 /test/lib | |
parent | 198a0ca738d18980901b674fd89849fa5eba79f6 (diff) |
status change tests, hopefully fix some status change issues
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/mocks.py | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/test/lib/mocks.py b/test/lib/mocks.py index 5790dbde6..f5c74f607 100644 --- a/test/lib/mocks.py +++ b/test/lib/mocks.py @@ -3,9 +3,13 @@ from mock import Mock from common import gajim -class MockConnection(Mock): +from common.connection_handlers import ConnectionHandlersBase + +class MockConnection(Mock, ConnectionHandlersBase): def __init__(self, account, *args): Mock.__init__(self, *args) + ConnectionHandlersBase.__init__(self) + self.name = account self.connected = 2 self.mood = {} @@ -13,6 +17,8 @@ class MockConnection(Mock): self.tune = {} self.blocked_contacts = {} self.blocked_groups = {} + self.sessions = {} + gajim.interface.instances[account] = {'infos': {}, 'disco': {}, 'gc_config': {}, 'search': {}} gajim.interface.minimized_controls[account] = {} gajim.contacts.add_account(account) @@ -37,11 +43,39 @@ class MockWindow(Mock): def __init__(self, *args): Mock.__init__(self, *args) self.window = Mock() + self._controls = {} + + def get_control(self, jid, account): + try: + return self._controls[account][jid] + except KeyError: + return None + + def has_control(self, jid, acct): + return self.get_control(jid, acct) is not None + + def new_tab(self, ctrl): + account = ctrl.account + jid = ctrl.jid + + if account not in self._controls: + self._controls[account] = {} + + if jid not in self._controls[account]: + self._controls[account][jid] = {} + + self._controls[account][jid] = ctrl + + def __nonzero__(self): + return True class MockChatControl(Mock): - def __init__(self, *args): + def __init__(self, jid, account, *args): Mock.__init__(self, *args) + self.jid = jid + self.account = account + self.parent_win = MockWindow({'get_active_control': self}) self.session = None @@ -90,9 +124,12 @@ class MockSession(Mock): self.thread_id = '%0x' % random.randint(0, 10000) def __repr__(self): - print '<MockSession %s>' % self.thread_id + return '<MockSession %s>' % self.thread_id def __nonzero__(self): return True + def __eq__(self, other): + return self is other + # vim: se ts=3: |