diff src/test/test_plugin_xep_0085.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 c3acc1298a2f
children 1fe00f0c9a91
line wrap: on
line diff
--- a/src/test/test_plugin_xep_0085.py	Fri Jan 10 18:07:36 2014 +0100
+++ b/src/test/test_plugin_xep_0085.py	Thu Jan 09 11:18:33 2014 +0100
@@ -38,26 +38,26 @@
 
     def test_messageReceived(self):
         self.host.memory.init()
-        self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, NO_SECURITY_LIMIT, Const.TEST_PROFILE)
+        self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, NO_SECURITY_LIMIT, Const.PROFILE[0])
         for state in plugin.CHAT_STATES:
             xml = u"""
             <message type="chat" from="%s" to="%s" id="test_1">
             %s
             <%s xmlns='%s'/>
             </message>
-            """ % (Const.TEST_JID_2_STR,
-                   Const.TEST_JID_STR,
+            """ % (Const.JID_STR[1],
+                   Const.JID_STR[0],
                    "<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)
+            self.host.bridge.expectCall("chatStateReceived", Const.JID_STR[1], state, Const.PROFILE[0])
+            self.plugin.messageReceivedTrigger(stanza, defer.Deferred(), Const.PROFILE[0])
 
     def test_sendMessageTrigger(self):
         self.host.memory.init()
-        self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, NO_SECURITY_LIMIT, Const.TEST_PROFILE)
+        self.host.memory.setParam(plugin.PARAM_NAME, True, plugin.PARAM_KEY, NO_SECURITY_LIMIT, Const.PROFILE[0])
         for state in plugin.CHAT_STATES:
-            mess_data = {"to": Const.TEST_JID,
+            mess_data = {"to": Const.JID[0],
                          "type": "chat",
                          "message": "content",
                          "extra": {} if state == "active" else {"chat_state": state}}
@@ -65,14 +65,14 @@
             <message type="chat" from="%s" to="%s" id="test_1">
             %s
             </message>
-            """ % (Const.TEST_JID_2_STR, Const.TEST_JID_STR,
+            """ % (Const.JID_STR[1], Const.JID_STR[0],
                    ("<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()
-            self.plugin.sendMessageTrigger(mess_data, treatments, Const.TEST_PROFILE)
+            self.plugin.sendMessageTrigger(mess_data, treatments, Const.PROFILE[0])
             xml = treatments.callbacks[0][0][0](mess_data)
             # cancel the timer to not block the process
-            self.plugin.map[Const.TEST_PROFILE][Const.TEST_JID.userhostJID()].timer.cancel()
+            self.plugin.map[Const.PROFILE[0]][Const.JID[0].userhostJID()].timer.cancel()
             self.assertEqualXML(xml['xml'].toXml().encode("utf-8"), expected.toXml().encode("utf-8"))