Mercurial > libervia-backend
comparison src/test/test_core_xmpp.py @ 649:e20c823f23e2
tests: helpers improvments:
- FakeParent renamed FakeClient
- added FakeRoster class, and an instance of it in FakeClient (FakeClient.roster)
- b2s function to convert boolean value to strings used in bridge
- some fake methods (FakeClient.send, FakeSat.delContact) to avoid exceptions
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 29 Sep 2013 16:29:36 +0200 |
parents | 29cea30f20f5 |
children | 9810f22ba733 |
comparison
equal
deleted
inserted
replaced
648:29cea30f20f5 | 649:e20c823f23e2 |
---|---|
44 class SatMessageProtocolTest(unittest.TestCase): | 44 class SatMessageProtocolTest(unittest.TestCase): |
45 | 45 |
46 def setUp(self): | 46 def setUp(self): |
47 self.host = helpers.FakeSAT() | 47 self.host = helpers.FakeSAT() |
48 self.message = xmpp.SatMessageProtocol(self.host) | 48 self.message = xmpp.SatMessageProtocol(self.host) |
49 self.message.parent = helpers.FakeParent() | 49 self.message.parent = helpers.FakeClient(self.host) |
50 | 50 |
51 def test_onMessage(self): | 51 def test_onMessage(self): |
52 xml = """ | 52 xml = """ |
53 <message type="chat" from="sender@example.net/house" to="test@example.org/SàT" id="test_1"> | 53 <message type="chat" from="sender@example.net/house" to="test@example.org/SàT" id="test_1"> |
54 <body>test</body> | 54 <body>test</body> |
62 class SatRosterProtocolTest(unittest.TestCase): | 62 class SatRosterProtocolTest(unittest.TestCase): |
63 | 63 |
64 def setUp(self): | 64 def setUp(self): |
65 self.host = helpers.FakeSAT() | 65 self.host = helpers.FakeSAT() |
66 self.roster = xmpp.SatRosterProtocol(self.host) | 66 self.roster = xmpp.SatRosterProtocol(self.host) |
67 self.roster.parent = helpers.FakeParent() | 67 self.roster.parent = helpers.FakeClient(self.host) |
68 | 68 |
69 def test_onRosterSet(self): | 69 def test_onRosterSet(self): |
70 roster_item = RosterItem(helpers.TEST_JID) | 70 roster_item = RosterItem(helpers.TEST_JID) |
71 roster_item.name = u"Test Man" | 71 roster_item.name = u"Test Man" |
72 roster_item.subscriptionTo = True | 72 roster_item.subscriptionTo = True |
80 class SatPresenceProtocolTest(unittest.TestCase): | 80 class SatPresenceProtocolTest(unittest.TestCase): |
81 | 81 |
82 def setUp(self): | 82 def setUp(self): |
83 self.host = helpers.FakeSAT() | 83 self.host = helpers.FakeSAT() |
84 self.presence = xmpp.SatPresenceProtocol(self.host) | 84 self.presence = xmpp.SatPresenceProtocol(self.host) |
85 self.presence.parent = helpers.FakeParent() | 85 self.presence.parent = helpers.FakeClient(self.host) |
86 | 86 |
87 def test_availableReceived(self): | 87 def test_availableReceived(self): |
88 self.host.bridge.expectCall("presenceUpdate", helpers.TEST_JID_STR, "xa", 15, {'default': "test status", 'fr': 'statut de test'}, helpers.TEST_PROFILE) | 88 self.host.bridge.expectCall("presenceUpdate", helpers.TEST_JID_STR, "xa", 15, {'default': "test status", 'fr': 'statut de test'}, helpers.TEST_PROFILE) |
89 self.presence.availableReceived(helpers.TEST_JID, 'xa', {None: "test status", 'fr': 'statut de test'}, 15) | 89 self.presence.availableReceived(helpers.TEST_JID, 'xa', {None: "test status", 'fr': 'statut de test'}, 15) |
90 | 90 |