comparison src/test/test_core_xmpp.py @ 591:65821b3fa7ab

Fix pep8 support in src/test.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:35 +0100
parents 952322b1d490
children 84a6e83157c2
comparison
equal deleted inserted replaced
590:56531f9e9ac7 591:65821b3fa7ab
27 from twisted.words.protocols.jabber.jid import JID 27 from twisted.words.protocols.jabber.jid import JID
28 from wokkel.generic import parseXml 28 from wokkel.generic import parseXml
29 from wokkel.xmppim import RosterItem 29 from wokkel.xmppim import RosterItem
30 30
31 31
32
33 class SatXMPPClientTest(unittest.TestCase): 32 class SatXMPPClientTest(unittest.TestCase):
34 33
35 def setUp(self): 34 def setUp(self):
36 self.host = helpers.FakeSAT() 35 self.host = helpers.FakeSAT()
37 self.client = xmpp.SatXMPPClient(self.host, "test_profile", JID("test@example.org"), "test") 36 self.client = xmpp.SatXMPPClient(self.host, "test_profile", JID("test@example.org"), "test")
40 """Check that init values are correctly initialised""" 39 """Check that init values are correctly initialised"""
41 self.assertEqual(self.client.profile, "test_profile") 40 self.assertEqual(self.client.profile, "test_profile")
42 print self.client.host 41 print self.client.host
43 self.assertEqual(self.client.host_app, self.host) 42 self.assertEqual(self.client.host_app, self.host)
44 self.assertTrue(isinstance(self.client.client_initialized, defer.Deferred)) 43 self.assertTrue(isinstance(self.client.client_initialized, defer.Deferred))
44
45 45
46 class SatMessageProtocolTest(unittest.TestCase): 46 class SatMessageProtocolTest(unittest.TestCase):
47 47
48 def setUp(self): 48 def setUp(self):
49 self.host = helpers.FakeSAT() 49 self.host = helpers.FakeSAT()
58 """ 58 """
59 stanza = parseXml(xml) 59 stanza = parseXml(xml)
60 self.host.bridge.expectCall("newMessage", "sender@example.net/house", "test", "chat", u"test@example.org/SàT", profile="test_profile") 60 self.host.bridge.expectCall("newMessage", "sender@example.net/house", "test", "chat", u"test@example.org/SàT", profile="test_profile")
61 self.message.onMessage(stanza) 61 self.message.onMessage(stanza)
62 62
63
63 class SatRosterProtocolTest(unittest.TestCase): 64 class SatRosterProtocolTest(unittest.TestCase):
64 65
65 def setUp(self): 66 def setUp(self):
66 self.host = helpers.FakeSAT() 67 self.host = helpers.FakeSAT()
67 self.roster = xmpp.SatRosterProtocol(self.host) 68 self.roster = xmpp.SatRosterProtocol(self.host)
72 roster_item.name = u"Test Man" 73 roster_item.name = u"Test Man"
73 roster_item.subscriptionTo = True 74 roster_item.subscriptionTo = True
74 roster_item.subscriptionFrom = True 75 roster_item.subscriptionFrom = True
75 roster_item.ask = False 76 roster_item.ask = False
76 roster_item.groups = set([u"Test Group 1", u"Test Group 2", u"Test Group 3"]) 77 roster_item.groups = set([u"Test Group 1", u"Test Group 2", u"Test Group 3"])
77 self.host.bridge.expectCall("newContact", helpers.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") 78 self.host.bridge.expectCall("newContact", helpers.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")
78 self.roster.onRosterSet(roster_item) 79 self.roster.onRosterSet(roster_item)
80
79 81
80 class SatPresenceProtocolTest(unittest.TestCase): 82 class SatPresenceProtocolTest(unittest.TestCase):
81 83
82 def setUp(self): 84 def setUp(self):
83 self.host = helpers.FakeSAT() 85 self.host = helpers.FakeSAT()
84 self.presence = xmpp.SatPresenceProtocol(self.host) 86 self.presence = xmpp.SatPresenceProtocol(self.host)
85 self.presence.parent = helpers.FakeParent() 87 self.presence.parent = helpers.FakeParent()
86 88
87 def test_availableReceived(self): 89 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) 90 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) 91 self.presence.availableReceived(helpers.TEST_JID, 'xa', {None: "test status", 'fr': 'statut de test'}, 15)
90 92
91 def test_availableReceived_empty_statuses(self): 93 def test_availableReceived_empty_statuses(self):
92 self.host.bridge.expectCall("presenceUpdate", helpers.TEST_JID_STR, "xa", 15, {}, helpers.TEST_PROFILE) 94 self.host.bridge.expectCall("presenceUpdate", helpers.TEST_JID_STR, "xa", 15, {}, helpers.TEST_PROFILE)
93 self.presence.availableReceived(helpers.TEST_JID, 'xa', None, 15) 95 self.presence.availableReceived(helpers.TEST_JID, 'xa', None, 15)
94 96
109 self.presence.subscribeReceived(helpers.TEST_JID) 111 self.presence.subscribeReceived(helpers.TEST_JID)
110 112
111 def test_unsubscribeReceived(self): 113 def test_unsubscribeReceived(self):
112 self.host.bridge.expectCall("subscribe", "unsubscribe", helpers.TEST_JID.userhost(), helpers.TEST_PROFILE) 114 self.host.bridge.expectCall("subscribe", "unsubscribe", helpers.TEST_JID.userhost(), helpers.TEST_PROFILE)
113 self.presence.unsubscribeReceived(helpers.TEST_JID) 115 self.presence.unsubscribeReceived(helpers.TEST_JID)
114