Mercurial > libervia-backend
comparison src/test/test_plugin_xep_0085.py @ 915:6f96ee4d8cc0
tests: tests fixes
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 21 Mar 2014 16:19:46 +0100 |
parents | 1fe00f0c9a91 |
children | 861593a5652b |
comparison
equal
deleted
inserted
replaced
914:1a3ba959f0ab | 915:6f96ee4d8cc0 |
---|---|
20 | 20 |
21 """ Plugin chat states notification tests """ | 21 """ Plugin chat states notification tests """ |
22 | 22 |
23 from constants import Const | 23 from constants import Const |
24 from sat.test import helpers | 24 from sat.test import helpers |
25 from sat.core.constants import Const as C | |
25 from sat.plugins import plugin_xep_0085 as plugin | 26 from sat.plugins import plugin_xep_0085 as plugin |
26 from sat.memory.memory import NO_SECURITY_LIMIT | |
27 from copy import deepcopy | 27 from copy import deepcopy |
28 from twisted.internet import defer | 28 from twisted.internet import defer |
29 from wokkel.generic import parseXml | 29 from wokkel.generic import parseXml |
30 from twisted.words.protocols.jabber.jid import JID | 30 from twisted.words.protocols.jabber.jid import JID |
31 | 31 |
36 self.host = helpers.FakeSAT() | 36 self.host = helpers.FakeSAT() |
37 self.plugin = plugin.XEP_0085(self.host) | 37 self.plugin = plugin.XEP_0085(self.host) |
38 | 38 |
39 def test_messageReceived(self): | 39 def test_messageReceived(self): |
40 self.host.memory.init() | 40 self.host.memory.init() |
41 self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, NO_SECURITY_LIMIT, Const.PROFILE[0]) | 41 self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, C.NO_SECURITY_LIMIT, Const.PROFILE[0]) |
42 for state in plugin.CHAT_STATES: | 42 for state in plugin.CHAT_STATES: |
43 xml = u""" | 43 xml = u""" |
44 <message type="chat" from="%s" to="%s" id="test_1"> | 44 <message type="chat" from="%s" to="%s" id="test_1"> |
45 %s | 45 %s |
46 <%s xmlns='%s'/> | 46 <%s xmlns='%s'/> |
53 self.host.bridge.expectCall("chatStateReceived", Const.JID_STR[1], state, Const.PROFILE[0]) | 53 self.host.bridge.expectCall("chatStateReceived", Const.JID_STR[1], state, Const.PROFILE[0]) |
54 self.plugin.messageReceivedTrigger(stanza, defer.Deferred(), Const.PROFILE[0]) | 54 self.plugin.messageReceivedTrigger(stanza, defer.Deferred(), Const.PROFILE[0]) |
55 | 55 |
56 def test_sendMessageTrigger(self): | 56 def test_sendMessageTrigger(self): |
57 self.host.memory.init() | 57 self.host.memory.init() |
58 self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, NO_SECURITY_LIMIT, Const.PROFILE[0]) | 58 self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, C.NO_SECURITY_LIMIT, Const.PROFILE[0]) |
59 for state in plugin.CHAT_STATES: | 59 for state in plugin.CHAT_STATES: |
60 mess_data = {"to": Const.JID[0], | 60 mess_data = {"to": Const.JID[0], |
61 "type": "chat", | 61 "type": "chat", |
62 "message": "content", | 62 "message": "content", |
63 "extra": {} if state == "active" else {"chat_state": state}} | 63 "extra": {} if state == "active" else {"chat_state": state}} |