Mercurial > libervia-backend
annotate src/test/helpers.py @ 591:65821b3fa7ab
Fix pep8 support in src/test.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:35 +0100 |
parents | 952322b1d490 |
children | 84a6e83157c2 |
rev | line source |
---|---|
335 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 SAT: a jabber client | |
572 | 6 Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org) |
335 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
9 it under the terms of the GNU Affero General Public License as published by |
335 | 10 the Free Software Foundation, either version 3 of the License, or |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
16 GNU Affero General Public License for more details. |
335 | 17 |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
18 You should have received a copy of the GNU Affero General Public License |
335 | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | |
21 | |
22 import __builtin__ | |
23 from twisted.words.protocols.jabber.jid import JID | |
24 | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
25 TEST_JID_STR = u"test@example.org/SàT" |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
26 TEST_JID = JID(u"test@example.org/SàT") |
335 | 27 TEST_PROFILE = 'test_profile' |
28 | |
591
65821b3fa7ab
Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
29 |
335 | 30 class DifferentArgsException(Exception): |
31 pass | |
32 | |
591
65821b3fa7ab
Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
33 |
335 | 34 class FakeSAT(object): |
35 """Class to simulate a SAT instance""" | |
36 | |
37 def __init__(self): | |
38 self.bridge = FakeBridge() | |
39 self.memory = FakeMemory() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
40 self.trigger = FakeTriggerManager() |
335 | 41 |
42 | |
43 class FakeBridge(object): | |
44 """Class to simulate and test bridge calls""" | |
45 | |
46 def expectCall(self, name, *check_args, **check_kwargs): | |
47 def checkCall(*args, **kwargs): | |
48 if args != check_args or kwargs != check_kwargs: | |
49 print "\n\n--------------------" | |
50 print "Args are not equals:" | |
51 print "args\n----\n%s (sent)\n%s (wanted)" % (args, check_args) | |
52 print "kwargs\n------\n%s (sent)\n%s (wanted)" % (kwargs, check_kwargs) | |
53 print "--------------------\n\n" | |
54 raise DifferentArgsException | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
55 |
335 | 56 setattr(self, name, checkCall) |
57 | |
58 | |
59 class FakeMemory(object): | |
60 """Class to simulate and test memory object""" | |
61 | |
62 def getProfileName(self, profile_key): | |
63 return profile_key | |
64 | |
512
862c0d6ab974
core, bridge, quick_frontend: MUC private messages history management:
Goffi <goffi@goffi.org>
parents:
484
diff
changeset
|
65 def addToHistory(self, from_jid, to_jid, message, _type='chat', timestamp=None, profile=None): |
335 | 66 pass |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
67 |
335 | 68 def addContact(self, contact_jid, attributes, groups, profile_key='@DEFAULT@'): |
69 pass | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
70 |
484
23cbdf0a0777
core: presence status + last resource refactored and kept in entitiesCache in memory.py, profile cache is purged on disconnection
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
71 def setPresenceStatus(self, contact_jid, show, priority, statuses, profile_key='@DEFAULT@'): |
335 | 72 pass |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
73 |
335 | 74 def addWaitingSub(self, type, contact_jid, profile_key): |
75 pass | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
76 |
335 | 77 def delWaitingSub(self, contact_jid, profile_key): |
78 pass | |
79 | |
591
65821b3fa7ab
Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
80 |
335 | 81 class FakeTriggerManager(object): |
82 | |
83 def add(self, point_name, callback): | |
84 pass | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
85 |
335 | 86 def point(self, point_name, *args, **kwargs): |
87 """We always return true to continue the action""" | |
88 return True | |
89 | |
591
65821b3fa7ab
Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
90 |
335 | 91 class FakeParent(object): |
92 def __init__(self): | |
93 self.profile = 'test_profile' | |
94 self.jid = TEST_JID | |
95 | |
591
65821b3fa7ab
Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
96 |
335 | 97 def _(text): |
98 return text | |
99 | |
100 __builtin__.__dict__['_'] = _ |