Mercurial > libervia-backend
diff src/test/test_core_xmpp.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 | 9810f22ba733 |
children | 1fe00f0c9a91 |
line wrap: on
line diff
--- a/src/test/test_core_xmpp.py Fri Jan 10 18:07:36 2014 +0100 +++ b/src/test/test_core_xmpp.py Thu Jan 09 11:18:33 2014 +0100 @@ -32,11 +32,11 @@ def setUp(self): self.host = helpers.FakeSAT() - self.client = xmpp.SatXMPPClient(self.host, "test_profile", JID("test@example.org"), "test") + self.client = xmpp.SatXMPPClient(self.host, Const.PROFILE[0], JID("test@example.org"), "test") def test_init(self): """Check that init values are correctly initialised""" - self.assertEqual(self.client.profile, "test_profile") + self.assertEqual(self.client.profile, Const.PROFILE[0]) print self.client.host self.assertEqual(self.client.host_app, self.host) self.assertTrue(isinstance(self.client.client_initialized, defer.Deferred)) @@ -56,7 +56,7 @@ </message> """ stanza = parseXml(xml) - self.host.bridge.expectCall("newMessage", u"sender@example.net/house", u"test", u"chat", u"test@example.org/SàT", {}, profile="test_profile") + self.host.bridge.expectCall("newMessage", u"sender@example.net/house", u"test", u"chat", u"test@example.org/SàT", {}, profile=Const.PROFILE[0]) self.message.onMessage(stanza) @@ -68,13 +68,13 @@ self.roster.parent = helpers.FakeClient(self.host) def test_onRosterSet(self): - roster_item = RosterItem(Const.TEST_JID) + roster_item = RosterItem(Const.JID[0]) roster_item.name = u"Test Man" roster_item.subscriptionTo = True roster_item.subscriptionFrom = True roster_item.ask = False roster_item.groups = set([u"Test Group 1", u"Test Group 2", u"Test Group 3"]) - self.host.bridge.expectCall("newContact", Const.TEST_JID_STR, {'to': 'True', 'from': 'True', 'ask': 'False', 'name': u'Test Man'}, set([u"Test Group 1", u"Test Group 2", u"Test Group 3"]), "test_profile") + self.host.bridge.expectCall("newContact", Const.JID_STR[0], {'to': 'True', 'from': 'True', 'ask': 'False', 'name': u'Test Man'}, set([u"Test Group 1", u"Test Group 2", u"Test Group 3"]), Const.PROFILE[0]) self.roster.onRosterSet(roster_item) @@ -86,29 +86,29 @@ self.presence.parent = helpers.FakeClient(self.host) def test_availableReceived(self): - self.host.bridge.expectCall("presenceUpdate", Const.TEST_JID_STR, "xa", 15, {'default': "test status", 'fr': 'statut de test'}, Const.TEST_PROFILE) - self.presence.availableReceived(Const.TEST_JID, 'xa', {None: "test status", 'fr': 'statut de test'}, 15) + self.host.bridge.expectCall("presenceUpdate", Const.JID_STR[0], "xa", 15, {'default': "test status", 'fr': 'statut de test'}, Const.PROFILE[0]) + self.presence.availableReceived(Const.JID[0], 'xa', {None: "test status", 'fr': 'statut de test'}, 15) def test_availableReceived_empty_statuses(self): - self.host.bridge.expectCall("presenceUpdate", Const.TEST_JID_STR, "xa", 15, {}, Const.TEST_PROFILE) - self.presence.availableReceived(Const.TEST_JID, 'xa', None, 15) + self.host.bridge.expectCall("presenceUpdate", Const.JID_STR[0], "xa", 15, {}, Const.PROFILE[0]) + self.presence.availableReceived(Const.JID[0], 'xa', None, 15) def test_unavailableReceived(self): - self.host.bridge.expectCall("presenceUpdate", Const.TEST_JID_STR, "unavailable", 0, {}, Const.TEST_PROFILE) - self.presence.unavailableReceived(Const.TEST_JID, None) + self.host.bridge.expectCall("presenceUpdate", Const.JID_STR[0], "unavailable", 0, {}, Const.PROFILE[0]) + self.presence.unavailableReceived(Const.JID[0], None) def test_subscribedReceived(self): - self.host.bridge.expectCall("subscribe", "subscribed", Const.TEST_JID.userhost(), Const.TEST_PROFILE) - self.presence.subscribedReceived(Const.TEST_JID) + self.host.bridge.expectCall("subscribe", "subscribed", Const.JID[0].userhost(), Const.PROFILE[0]) + self.presence.subscribedReceived(Const.JID[0]) def test_unsubscribedReceived(self): - self.host.bridge.expectCall("subscribe", "unsubscribed", Const.TEST_JID.userhost(), Const.TEST_PROFILE) - self.presence.unsubscribedReceived(Const.TEST_JID) + self.host.bridge.expectCall("subscribe", "unsubscribed", Const.JID[0].userhost(), Const.PROFILE[0]) + self.presence.unsubscribedReceived(Const.JID[0]) def test_subscribeReceived(self): - self.host.bridge.expectCall("subscribe", "subscribe", Const.TEST_JID.userhost(), Const.TEST_PROFILE) - self.presence.subscribeReceived(Const.TEST_JID) + self.host.bridge.expectCall("subscribe", "subscribe", Const.JID[0].userhost(), Const.PROFILE[0]) + self.presence.subscribeReceived(Const.JID[0]) def test_unsubscribeReceived(self): - self.host.bridge.expectCall("subscribe", "unsubscribe", Const.TEST_JID.userhost(), Const.TEST_PROFILE) - self.presence.unsubscribeReceived(Const.TEST_JID) + self.host.bridge.expectCall("subscribe", "unsubscribe", Const.JID[0].userhost(), Const.PROFILE[0]) + self.presence.unsubscribeReceived(Const.JID[0])