Mercurial > libervia-backend
comparison src/test/test_plugin_xep_0033.py @ 1271:2308f8405ffb
test: refactoring:
- rename internal init methods to reinit
- rename getSentMessage to getSentMessageXml
- rename getSentMessageRaw to getSentMessage
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 19 Dec 2014 11:36:00 +0100 |
parents | 7ea0215e7092 |
children | 7fbc858cd1cd |
comparison
equal
deleted
inserted
replaced
1270:037ec0795a85 | 1271:2308f8405ffb |
---|---|
44 def setUp(self): | 44 def setUp(self): |
45 self.host = helpers.FakeSAT() | 45 self.host = helpers.FakeSAT() |
46 self.plugin = plugin.XEP_0033(self.host) | 46 self.plugin = plugin.XEP_0033(self.host) |
47 | 47 |
48 def test_messageReceived(self): | 48 def test_messageReceived(self): |
49 self.host.memory.init() | 49 self.host.memory.reinit() |
50 xml = u""" | 50 xml = u""" |
51 <message type="chat" from="%s" to="%s" id="test_1"> | 51 <message type="chat" from="%s" to="%s" id="test_1"> |
52 <body>test</body> | 52 <body>test</body> |
53 <addresses xmlns='http://jabber.org/protocol/address'> | 53 <addresses xmlns='http://jabber.org/protocol/address'> |
54 <address type='to' jid='%s'/> | 54 <address type='to' jid='%s'/> |
146 post_treatments.callback(data) | 146 post_treatments.callback(data) |
147 logger.setLevel(level) | 147 logger.setLevel(level) |
148 post_treatments.addCallbacks(assertAddresses, lambda failure: sendMessageErrback(failure, exception)) | 148 post_treatments.addCallbacks(assertAddresses, lambda failure: sendMessageErrback(failure, exception)) |
149 | 149 |
150 # feature is not supported, abort the message | 150 # feature is not supported, abort the message |
151 self.host.memory.init() | |
152 data = deepcopy(mess_data) | 151 data = deepcopy(mess_data) |
153 trigger(data, CancelError) | 152 trigger(data, CancelError) |
153 self.host.memory.reinit() | |
154 | 154 |
155 # feature is supported by the main target server | 155 # feature is supported by the main target server |
156 self.host.init() | 156 self.host.reinit() |
157 self.host.memory.init() | |
158 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) | 157 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) |
159 data = deepcopy(mess_data) | 158 data = deepcopy(mess_data) |
160 trigger(data, CancelError) | 159 trigger(data, CancelError) |
161 checkSentAndStored() | 160 checkSentAndStored() |
162 | 161 |
163 # feature is supported by all target servers | 162 # feature is supported by all target servers |
164 self.host.init() | 163 self.host.reinit() |
165 self.host.memory.init() | |
166 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) | 164 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) |
167 for dest in (JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC): | 165 for dest in (JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC): |
168 self.host.addFeature(JID(JID(dest).host), plugin.NS_ADDRESS, PROFILE) | 166 self.host.addFeature(JID(JID(dest).host), plugin.NS_ADDRESS, PROFILE) |
169 data = deepcopy(mess_data) | 167 data = deepcopy(mess_data) |
170 trigger(data, CancelError) | 168 trigger(data, CancelError) |
171 checkSentAndStored() | 169 checkSentAndStored() |
172 | 170 |
173 # check that a wrong recipient entity is fixed by the backend | 171 # check that a wrong recipient entity is fixed by the backend |
174 self.host.init() | 172 self.host.reinit() |
175 self.host.memory.init() | |
176 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) | 173 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) |
177 for dest in (JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC): | 174 for dest in (JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC): |
178 self.host.addFeature(JID(JID(dest).host), plugin.NS_ADDRESS, PROFILE) | 175 self.host.addFeature(JID(JID(dest).host), plugin.NS_ADDRESS, PROFILE) |
179 data = deepcopy(mess_data) | 176 data = deepcopy(mess_data) |
180 data["to"] = JID(JID_STR_X_TO) | 177 data["to"] = JID(JID_STR_X_TO) |