annotate src/test/helpers.py @ 792:2136be5a44a8

test: define the constants JIDs and profiles as lists
author souliane <souliane@mailoo.org>
date Thu, 09 Jan 2014 11:18:33 +0100
parents 0cb423500fbb
children 52c4b755aba6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
335
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
4 # SAT: a jabber client
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org)
335
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
10 # (at your option) any later version.
335
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
15 # GNU Affero General Public License for more details.
335
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 591
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
335
Goffi <goffi@goffi.org>
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 696
diff changeset
20 from sat.core.i18n import _
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
21 from sat.core import exceptions
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
22 from constants import Const
649
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
23 from wokkel.xmppim import RosterItem
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
24 from sat.core.xmpp import SatRosterProtocol
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
25 from sat.memory.memory import Params, Memory
647
63b6e684bbfa tests: Use of FailTest for DifferentArgsException instead of Exception, so the test fail instead of raising en error.
Goffi <goffi@goffi.org>
parents: 609
diff changeset
26 from twisted.trial.unittest import FailTest
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
27 from twisted.trial import unittest
782
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
28 from twisted.internet import defer
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
29 from twisted.words.protocols.jabber.jid import JID
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
30 from xml.etree import cElementTree as etree
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
31 from collections import Counter
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
32 import re
335
Goffi <goffi@goffi.org>
parents:
diff changeset
33
Goffi <goffi@goffi.org>
parents:
diff changeset
34
649
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
35 def b2s(value):
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
36 """Convert a bool to a unicode string used in bridge
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
37 @param value: boolean value
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
38 @return: unicode conversion, according to bridge convention
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
39
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
40 """
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
41 return u"True" if value else u"False"
591
65821b3fa7ab Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
42
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
43
647
63b6e684bbfa tests: Use of FailTest for DifferentArgsException instead of Exception, so the test fail instead of raising en error.
Goffi <goffi@goffi.org>
parents: 609
diff changeset
44 class DifferentArgsException(FailTest):
335
Goffi <goffi@goffi.org>
parents:
diff changeset
45 pass
Goffi <goffi@goffi.org>
parents:
diff changeset
46
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
47
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
48 class DifferentXMLException(FailTest):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
49 pass
591
65821b3fa7ab Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
50
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
51
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
52 class DifferentListException(FailTest):
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
53 pass
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
54
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
55
335
Goffi <goffi@goffi.org>
parents:
diff changeset
56 class FakeSAT(object):
Goffi <goffi@goffi.org>
parents:
diff changeset
57 """Class to simulate a SAT instance"""
Goffi <goffi@goffi.org>
parents:
diff changeset
58
Goffi <goffi@goffi.org>
parents:
diff changeset
59 def __init__(self):
Goffi <goffi@goffi.org>
parents:
diff changeset
60 self.bridge = FakeBridge()
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
61 self.memory = FakeMemory(self)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
62 self.trigger = FakeTriggerManager()
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
63 self.init()
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
64
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
65 def init(self):
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
66 """This can be called by tests that check for sent and stored messages"""
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
67 self.sent_messages = []
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
68 self.stored_messages = []
335
Goffi <goffi@goffi.org>
parents:
diff changeset
69
649
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
70 def delContact(self, to, profile_key):
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
71 #TODO
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
72 pass
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
73
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
74 def registerCallback(self, callback, *args, **kwargs):
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
75 pass
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
76
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
77 def registerNewAccountCB(self, data, profile):
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
78 pass
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
79
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
80 def sendMessage(self, to_s, msg, subject=None, mess_type='auto', extra={}, profile_key='@NONE@'):
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
81 self.sendAndStoreMessage({"to": JID(to_s)})
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
82
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
83 def sendAndStoreMessage(self, mess_data, skip_send=False, profile=None):
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
84 if not skip_send:
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
85 self.sent_messages.append(mess_data["to"])
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
86 self.stored_messages.append(mess_data["to"])
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
87 pass
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
88
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
89 def requestServerDisco(self, feature, jid_=None, cache_only=False, profile_key="@NONE"):
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
90 """Discover if a server or its items offer a given feature
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
91 @param feature: the feature to check
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
92 @param jid_: the jid of the server, local server if None
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
93 @param cache_only: expect the result to be in cache and don't actually
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
94 make any request. This can be used anytime for requesting a feature on
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
95 the local server because the data are cached for sure.
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
96 @result: the Deferred entity jid offering the feature, or None
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
97 """
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
98 profile = self.memory.getProfileName(profile_key)
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
99 self.memory.server_features.setdefault(profile, {})
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
100 if jid_ is None:
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
101 jid_ = self.getClientHostJid(profile_key)
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
102 # call FakeMemory.init and FakeMemory.addServerFeature
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
103 # in your tests to change the return value of this method
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
104 return defer.succeed(jid_ if self.memory.hasServerFeature(feature, jid_, profile_key) else None)
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
105
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
106 def getClientHostJid(self, profile_key):
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
107 return JID(Const.JID[0].host)
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
108
335
Goffi <goffi@goffi.org>
parents:
diff changeset
109
Goffi <goffi@goffi.org>
parents:
diff changeset
110 class FakeBridge(object):
Goffi <goffi@goffi.org>
parents:
diff changeset
111 """Class to simulate and test bridge calls"""
Goffi <goffi@goffi.org>
parents:
diff changeset
112
Goffi <goffi@goffi.org>
parents:
diff changeset
113 def expectCall(self, name, *check_args, **check_kwargs):
Goffi <goffi@goffi.org>
parents:
diff changeset
114 def checkCall(*args, **kwargs):
Goffi <goffi@goffi.org>
parents:
diff changeset
115 if args != check_args or kwargs != check_kwargs:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 print "\n\n--------------------"
Goffi <goffi@goffi.org>
parents:
diff changeset
117 print "Args are not equals:"
Goffi <goffi@goffi.org>
parents:
diff changeset
118 print "args\n----\n%s (sent)\n%s (wanted)" % (args, check_args)
Goffi <goffi@goffi.org>
parents:
diff changeset
119 print "kwargs\n------\n%s (sent)\n%s (wanted)" % (kwargs, check_kwargs)
Goffi <goffi@goffi.org>
parents:
diff changeset
120 print "--------------------\n\n"
Goffi <goffi@goffi.org>
parents:
diff changeset
121 raise DifferentArgsException
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
122
335
Goffi <goffi@goffi.org>
parents:
diff changeset
123 setattr(self, name, checkCall)
Goffi <goffi@goffi.org>
parents:
diff changeset
124
694
4284b6ad8aa3 tests: plugin text syntaxes sanitisation tests
Goffi <goffi@goffi.org>
parents: 693
diff changeset
125 def addMethod(self, name, int_suffix, in_sign, out_sign, method, async=False):
4284b6ad8aa3 tests: plugin text syntaxes sanitisation tests
Goffi <goffi@goffi.org>
parents: 693
diff changeset
126 pass
335
Goffi <goffi@goffi.org>
parents:
diff changeset
127
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
128 def addSignal(self, name, int_suffix, signature):
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
129 pass
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
130
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
131
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
132 class FakeParams(Params):
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
133 """Class to simulate and test params object. The methods of Params that could
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
134 not be run (for example those using the storage attribute must be overwritten
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
135 by a naive simulation of what they should do."""
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
136
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
137 def __init__(self, host, storage):
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
138 Params.__init__(self, host, storage)
782
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
139 self.params = {} # naive simulation of values storage
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
140
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
141 def setParam(self, name, value, category, security_limit=-1, profile_key='@NONE@'):
782
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
142 profile = self.getProfileName(profile_key)
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
143 self.params.setdefault(profile, {})
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
144 self.params[profile_key][(category, name)] = value
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
145
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
146 def getParamA(self, name, category, attr="value", profile_key='@NONE@'):
782
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
147 profile = self.getProfileName(profile_key)
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
148 return self.params[profile][(category, name)]
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
149
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
150 def getProfileName(self, profile_key, return_profile_keys=False):
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
151 if profile_key == '@DEFAULT@':
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
152 return Const.PROFILE[0]
782
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
153 elif profile_key == '@NONE@':
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
154 raise exceptions.ProfileNotSetError
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
155 else:
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
156 return profile_key
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
157
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
158 def loadIndParams(self, profile, cache=None):
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
159 self.params[profile] = {}
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
160 return defer.succeed(None)
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
161
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
162
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
163 class FakeMemory(Memory):
335
Goffi <goffi@goffi.org>
parents:
diff changeset
164 """Class to simulate and test memory object"""
Goffi <goffi@goffi.org>
parents:
diff changeset
165
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
166 def __init__(self, host):
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
167 # do not call Memory.__init__, we just want to call the methods that are
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
168 # manipulating basic stuff, the others should be overwritten when needed
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
169 self.host = host
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
170 self.params = FakeParams(host, None)
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
171 self.init()
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
172
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
173 def init(self):
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
174 """Tests that manipulate params, entities, features should
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
175 re-initialise the memory first to not fake the result."""
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
176 self.params.load_default_params()
782
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
177 self.params.params.clear()
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
178 self.entities_data = {}
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
179 self.server_features = {}
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
180
782
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
181 def getProfileName(self, profile_key, return_profile_keys=False):
0e5807193721 test: added some tests for Memory
souliane <souliane@mailoo.org>
parents: 781
diff changeset
182 return self.params.getProfileName(profile_key, return_profile_keys)
335
Goffi <goffi@goffi.org>
parents:
diff changeset
183
669
ffb716804580 core, bridge: extra parameter is saved in history:
Goffi <goffi@goffi.org>
parents: 649
diff changeset
184 def addToHistory(self, from_jid, to_jid, message, _type='chat', extra=None, timestamp=None, profile="@NONE@"):
335
Goffi <goffi@goffi.org>
parents:
diff changeset
185 pass
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
186
335
Goffi <goffi@goffi.org>
parents:
diff changeset
187 def addContact(self, contact_jid, attributes, groups, profile_key='@DEFAULT@'):
Goffi <goffi@goffi.org>
parents:
diff changeset
188 pass
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
189
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
190 def setPresenceStatus(self, contact_jid, show, priority, statuses, profile_key='@DEFAULT@'):
335
Goffi <goffi@goffi.org>
parents:
diff changeset
191 pass
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
192
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
193 def addWaitingSub(self, type_, contact_jid, profile_key):
335
Goffi <goffi@goffi.org>
parents:
diff changeset
194 pass
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
195
335
Goffi <goffi@goffi.org>
parents:
diff changeset
196 def delWaitingSub(self, contact_jid, profile_key):
Goffi <goffi@goffi.org>
parents:
diff changeset
197 pass
Goffi <goffi@goffi.org>
parents:
diff changeset
198
781
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
199 def updateEntityData(self, entity_jid, key, value, profile_key):
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
200 self.entities_data.setdefault(entity_jid, {})
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
201 self.entities_data[entity_jid][key] = value
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
202
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
203 def getEntityData(self, entity_jid, keys, profile_key):
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
204 result = {}
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
205 for key in keys:
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
206 result[key] = self.entities_data[entity_jid][key]
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
207 return result
80ab2b58e205 test: added support of basic memory stuff in helpers.py
souliane <souliane@mailoo.org>
parents: 780
diff changeset
208
591
65821b3fa7ab Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
209
335
Goffi <goffi@goffi.org>
parents:
diff changeset
210 class FakeTriggerManager(object):
Goffi <goffi@goffi.org>
parents:
diff changeset
211
786
c3acc1298a2f test: FakeMemory inherits from Memory + more helpers basic support + cleaning
souliane <souliane@mailoo.org>
parents: 782
diff changeset
212 def add(self, point_name, callback, priority=0):
335
Goffi <goffi@goffi.org>
parents:
diff changeset
213 pass
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
214
335
Goffi <goffi@goffi.org>
parents:
diff changeset
215 def point(self, point_name, *args, **kwargs):
Goffi <goffi@goffi.org>
parents:
diff changeset
216 """We always return true to continue the action"""
Goffi <goffi@goffi.org>
parents:
diff changeset
217 return True
Goffi <goffi@goffi.org>
parents:
diff changeset
218
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
219
649
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
220 class FakeRosterProtocol(SatRosterProtocol):
591
65821b3fa7ab Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
221
649
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
222 def __init__(self, host, parent):
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
223 SatRosterProtocol.__init__(self, host)
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
224 self.parent = parent
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
225 self.addItem(Const.JID[0])
649
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
226
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
227 def addItem(self, jid, *args, **kwargs):
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
228 if not args and not kwargs:
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
229 # defaults values setted for the tests only
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
230 kwargs["subscriptionTo"] = True
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
231 kwargs["subscriptionFrom"] = True
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
232 roster_item = RosterItem(jid, *args, **kwargs)
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
233 attrs = {'to': b2s(roster_item.subscriptionTo), 'from': b2s(roster_item.subscriptionFrom), 'ask': b2s(roster_item.pendingOut)}
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
234 if roster_item.name:
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
235 attrs['name'] = roster_item.name
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
236 self.host.bridge.expectCall("newContact", jid.full(), attrs, roster_item.groups, self.parent.profile)
649
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
237 self.onRosterSet(roster_item)
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
238
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
239
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
240 class FakeClient(object):
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
241 def __init__(self, host):
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
242 self.host = host
335
Goffi <goffi@goffi.org>
parents:
diff changeset
243 self.profile = 'test_profile'
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
244 self.jid = Const.JID[0]
649
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
245 self.roster = FakeRosterProtocol(host, self)
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
246
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
247 def send(self, obj):
e20c823f23e2 tests: helpers improvments:
Goffi <goffi@goffi.org>
parents: 647
diff changeset
248 pass
335
Goffi <goffi@goffi.org>
parents:
diff changeset
249
591
65821b3fa7ab Fix pep8 support in src/test.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
250
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
251 class SatTestCase(unittest.TestCase):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
252
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
253 def assertEqualXML(self, xml, expected, ignore_blank=False):
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
254 def equalElt(got_elt, exp_elt):
696
f1a2831d549d test: better ignore_blank in helpers's assertEqualXML
Goffi <goffi@goffi.org>
parents: 694
diff changeset
255 if ignore_blank:
f1a2831d549d test: better ignore_blank in helpers's assertEqualXML
Goffi <goffi@goffi.org>
parents: 694
diff changeset
256 for elt in got_elt, exp_elt:
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
257 for attr in ('text', 'tail'):
696
f1a2831d549d test: better ignore_blank in helpers's assertEqualXML
Goffi <goffi@goffi.org>
parents: 694
diff changeset
258 value = getattr(elt, attr)
f1a2831d549d test: better ignore_blank in helpers's assertEqualXML
Goffi <goffi@goffi.org>
parents: 694
diff changeset
259 try:
f1a2831d549d test: better ignore_blank in helpers's assertEqualXML
Goffi <goffi@goffi.org>
parents: 694
diff changeset
260 value = value.strip() or None
f1a2831d549d test: better ignore_blank in helpers's assertEqualXML
Goffi <goffi@goffi.org>
parents: 694
diff changeset
261 except AttributeError:
f1a2831d549d test: better ignore_blank in helpers's assertEqualXML
Goffi <goffi@goffi.org>
parents: 694
diff changeset
262 value = None
f1a2831d549d test: better ignore_blank in helpers's assertEqualXML
Goffi <goffi@goffi.org>
parents: 694
diff changeset
263 setattr(elt, attr, value)
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
264 if (got_elt.tag != exp_elt.tag):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
265 print "XML are not equals (elt %s/%s):" % (got_elt, exp_elt)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
266 print "tag: got [%s] expected: [%s]" % (got_elt.tag, exp_elt.tag)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
267 return False
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
268 if (got_elt.attrib != exp_elt.attrib):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
269 print "XML are not equals (elt %s/%s):" % (got_elt, exp_elt)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
270 print "attribs: got %s expected %s" % (got_elt.attrib, exp_elt.attrib)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
271 return False
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
272 if (got_elt.tail != exp_elt.tail or got_elt.text != exp_elt.text):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
273 print "XML are not equals (elt %s/%s):" % (got_elt, exp_elt)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
274 print "text: got [%s] expected: [%s]" % (got_elt.text, exp_elt.text)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
275 print "tail: got [%s] expected: [%s]" % (got_elt.tail, exp_elt.tail)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
276 return False
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
277 if (len(got_elt) != len(exp_elt)):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
278 print "XML are not equals (elt %s/%s):" % (got_elt, exp_elt)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
279 print "children len: got %d expected: %d" % (len(got_elt), len(exp_elt))
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
280 return False
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
281 for idx, child in enumerate(got_elt):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
282 if not equalElt(child, exp_elt[idx]):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
283 return False
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
284 return True
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
285
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
286 def remove_blank(xml):
780
9810f22ba733 test: store the constants in constants.py + better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 771
diff changeset
287 lines = [line.strip() for line in re.sub(r'[ \t\r\f\v]+', ' ', xml).split('\n')]
693
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
288 return '\n'.join([line for line in lines if line])
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
289
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
290 xml_elt = etree.fromstring(remove_blank(xml) if ignore_blank else xml)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
291 expected_elt = etree.fromstring(remove_blank(expected) if ignore_blank else expected)
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
292
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
293 if not equalElt(xml_elt, expected_elt):
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
294 print "---"
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
295 print "XML are not equals:"
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
296 print "got:\n-\n%s\n-\n\n" % etree.tostring(xml_elt, encoding='utf-8')
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
297 print "was expecting:\n-\n%s\n-\n\n" % etree.tostring(expected_elt, encoding='utf-8')
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
298 print "---"
65b30bc7f1b3 tests: added XML comparaison method to helpers
Goffi <goffi@goffi.org>
parents: 669
diff changeset
299 raise DifferentXMLException
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
300
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
301 def assertEqualUnsortedList(self, a, b, msg):
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
302 counter_a = Counter(a)
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
303 counter_b = Counter(b)
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
304 if counter_a != counter_b:
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
305 print "---"
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
306 print "Unsorted lists are not equals:"
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
307 print "got : %s" % counter_a
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
308 print "was expecting: %s" % counter_b
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
309 if msg:
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
310 print msg
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
311 print "---"
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 786
diff changeset
312 raise DifferentListException