Mercurial > libervia-backend
diff src/test/test_plugin_xep_0085.py @ 786:c3acc1298a2f
test: FakeMemory inherits from Memory + more helpers basic support + cleaning
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 05 Jan 2014 13:04:54 +0100 |
parents | 27581cddb758 |
children | 2136be5a44a8 |
line wrap: on
line diff
--- a/src/test/test_plugin_xep_0085.py Sun Jan 05 13:00:17 2014 +0100 +++ b/src/test/test_plugin_xep_0085.py Sun Jan 05 13:04:54 2014 +0100 @@ -40,13 +40,16 @@ self.host.memory.init() self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, NO_SECURITY_LIMIT, Const.TEST_PROFILE) for state in plugin.CHAT_STATES: - xml = """ - <message type="chat" from="sender@example.net/house" to="sender@example.net/house" id="test_1"> + xml = u""" + <message type="chat" from="%s" to="%s" id="test_1"> %s - <%s xmlns='http://jabber.org/protocol/chatstates'/> + <%s xmlns='%s'/> </message> - """ % ("<body>test</body>" if state == "active" else "", state) - stanza = parseXml(xml) + """ % (Const.TEST_JID_2_STR, + Const.TEST_JID_STR, + "<body>test</body>" if state == "active" else "", + state, plugin.NS_CHAT_STATES) + stanza = parseXml(xml.encode("utf-8")) self.host.bridge.expectCall("chatStateReceived", u"sender@example.net/house", state, Const.TEST_PROFILE) self.plugin.messageReceivedTrigger(stanza, defer.Deferred(), Const.TEST_PROFILE) @@ -54,15 +57,17 @@ self.host.memory.init() self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, NO_SECURITY_LIMIT, Const.TEST_PROFILE) for state in plugin.CHAT_STATES: - mess_data = {"to": "test@example.org/SàT", + mess_data = {"to": Const.TEST_JID, "type": "chat", "message": "content", "extra": {} if state == "active" else {"chat_state": state}} - mess_data['xml'] = parseXml(""" - <message type="chat" from="sender@example.net/house" to="test@example.org/SàT" id="test_1"> + stanza = u""" + <message type="chat" from="%s" to="%s" id="test_1"> %s </message> - """ % (("<body>%s</body>" % mess_data['message']) if state == "active" else "",)) + """ % (Const.TEST_JID_2_STR, Const.TEST_JID_STR, + ("<body>%s</body>" % mess_data['message']) if state == "active" else "") + mess_data['xml'] = parseXml(stanza.encode("utf-8")) expected = deepcopy(mess_data['xml']) expected.addElement(state, plugin.NS_CHAT_STATES) treatments = defer.Deferred()