Mercurial > libervia-backend
comparison libervia/backend/test/test_core_xmpp.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | bc7d45dedeb0 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
28 | 28 |
29 class SatXMPPClientTest(unittest.TestCase): | 29 class SatXMPPClientTest(unittest.TestCase): |
30 | 30 |
31 def setUp(self): | 31 def setUp(self): |
32 self.host = helpers.FakeSAT() | 32 self.host = helpers.FakeSAT() |
33 self.client = xmpp.SatXMPPClient(self.host, Const.PROFILE[0], JID("test@example.org"), "test") | 33 self.client = xmpp.SatXMPPClient( |
34 self.host, Const.PROFILE[0], JID("test@example.org"), "test" | |
35 ) | |
34 | 36 |
35 def test_init(self): | 37 def test_init(self): |
36 """Check that init values are correctly initialised""" | 38 """Check that init values are correctly initialised""" |
37 self.assertEqual(self.client.profile, Const.PROFILE[0]) | 39 self.assertEqual(self.client.profile, Const.PROFILE[0]) |
38 print(self.client.jid.host) | 40 print(self.client.jid.host) |
51 <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"> |
52 <body>test</body> | 54 <body>test</body> |
53 </message> | 55 </message> |
54 """ | 56 """ |
55 stanza = parseXml(xml) | 57 stanza = parseXml(xml) |
56 self.host.bridge.expect_call("message_new", "sender@example.net/house", "test", "chat", "test@example.org/SàT", {}, profile=Const.PROFILE[0]) | 58 self.host.bridge.expect_call( |
59 "message_new", | |
60 "sender@example.net/house", | |
61 "test", | |
62 "chat", | |
63 "test@example.org/SàT", | |
64 {}, | |
65 profile=Const.PROFILE[0], | |
66 ) | |
57 self.message.onMessage(stanza) | 67 self.message.onMessage(stanza) |
58 | 68 |
59 | 69 |
60 class LiberviaRosterProtocolTest(unittest.TestCase): | 70 class LiberviaRosterProtocolTest(unittest.TestCase): |
61 | 71 |
69 roster_item.name = "Test Man" | 79 roster_item.name = "Test Man" |
70 roster_item.subscriptionTo = True | 80 roster_item.subscriptionTo = True |
71 roster_item.subscriptionFrom = True | 81 roster_item.subscriptionFrom = True |
72 roster_item.ask = False | 82 roster_item.ask = False |
73 roster_item.groups = set(["Test Group 1", "Test Group 2", "Test Group 3"]) | 83 roster_item.groups = set(["Test Group 1", "Test Group 2", "Test Group 3"]) |
74 self.host.bridge.expect_call("contact_new", Const.JID_STR[0], {'to': 'True', 'from': 'True', 'ask': 'False', 'name': 'Test Man'}, set(["Test Group 1", "Test Group 2", "Test Group 3"]), Const.PROFILE[0]) | 84 self.host.bridge.expect_call( |
85 "contact_new", | |
86 Const.JID_STR[0], | |
87 {"to": "True", "from": "True", "ask": "False", "name": "Test Man"}, | |
88 set(["Test Group 1", "Test Group 2", "Test Group 3"]), | |
89 Const.PROFILE[0], | |
90 ) | |
75 self.roster._register_item(roster_item) | 91 self.roster._register_item(roster_item) |
76 | 92 |
77 | 93 |
78 class SatPresenceProtocolTest(unittest.TestCase): | 94 class SatPresenceProtocolTest(unittest.TestCase): |
79 | 95 |
81 self.host = helpers.FakeSAT() | 97 self.host = helpers.FakeSAT() |
82 self.presence = xmpp.SatPresenceProtocol(self.host) | 98 self.presence = xmpp.SatPresenceProtocol(self.host) |
83 self.presence.parent = helpers.FakeClient(self.host) | 99 self.presence.parent = helpers.FakeClient(self.host) |
84 | 100 |
85 def test_availableReceived(self): | 101 def test_availableReceived(self): |
86 self.host.bridge.expect_call("presence_update", Const.JID_STR[0], "xa", 15, {'default': "test status", 'fr': 'statut de test'}, Const.PROFILE[0]) | 102 self.host.bridge.expect_call( |
87 self.presence.availableReceived(Const.JID[0], 'xa', {None: "test status", 'fr': 'statut de test'}, 15) | 103 "presence_update", |
104 Const.JID_STR[0], | |
105 "xa", | |
106 15, | |
107 {"default": "test status", "fr": "statut de test"}, | |
108 Const.PROFILE[0], | |
109 ) | |
110 self.presence.availableReceived( | |
111 Const.JID[0], "xa", {None: "test status", "fr": "statut de test"}, 15 | |
112 ) | |
88 | 113 |
89 def test_available_received_empty_statuses(self): | 114 def test_available_received_empty_statuses(self): |
90 self.host.bridge.expect_call("presence_update", Const.JID_STR[0], "xa", 15, {}, Const.PROFILE[0]) | 115 self.host.bridge.expect_call( |
91 self.presence.availableReceived(Const.JID[0], 'xa', None, 15) | 116 "presence_update", Const.JID_STR[0], "xa", 15, {}, Const.PROFILE[0] |
117 ) | |
118 self.presence.availableReceived(Const.JID[0], "xa", None, 15) | |
92 | 119 |
93 def test_unavailableReceived(self): | 120 def test_unavailableReceived(self): |
94 self.host.bridge.expect_call("presence_update", Const.JID_STR[0], "unavailable", 0, {}, Const.PROFILE[0]) | 121 self.host.bridge.expect_call( |
122 "presence_update", Const.JID_STR[0], "unavailable", 0, {}, Const.PROFILE[0] | |
123 ) | |
95 self.presence.unavailableReceived(Const.JID[0], None) | 124 self.presence.unavailableReceived(Const.JID[0], None) |
96 | 125 |
97 def test_subscribedReceived(self): | 126 def test_subscribedReceived(self): |
98 self.host.bridge.expect_call("subscribe", "subscribed", Const.JID[0].userhost(), Const.PROFILE[0]) | 127 self.host.bridge.expect_call( |
128 "subscribe", "subscribed", Const.JID[0].userhost(), Const.PROFILE[0] | |
129 ) | |
99 self.presence.subscribedReceived(Const.JID[0]) | 130 self.presence.subscribedReceived(Const.JID[0]) |
100 | 131 |
101 def test_unsubscribedReceived(self): | 132 def test_unsubscribedReceived(self): |
102 self.host.bridge.expect_call("subscribe", "unsubscribed", Const.JID[0].userhost(), Const.PROFILE[0]) | 133 self.host.bridge.expect_call( |
134 "subscribe", "unsubscribed", Const.JID[0].userhost(), Const.PROFILE[0] | |
135 ) | |
103 self.presence.unsubscribedReceived(Const.JID[0]) | 136 self.presence.unsubscribedReceived(Const.JID[0]) |
104 | 137 |
105 def test_subscribeReceived(self): | 138 def test_subscribeReceived(self): |
106 self.host.bridge.expect_call("subscribe", "subscribe", Const.JID[0].userhost(), Const.PROFILE[0]) | 139 self.host.bridge.expect_call( |
140 "subscribe", "subscribe", Const.JID[0].userhost(), Const.PROFILE[0] | |
141 ) | |
107 self.presence.subscribeReceived(Const.JID[0]) | 142 self.presence.subscribeReceived(Const.JID[0]) |
108 | 143 |
109 def test_unsubscribeReceived(self): | 144 def test_unsubscribeReceived(self): |
110 self.host.bridge.expect_call("subscribe", "unsubscribe", Const.JID[0].userhost(), Const.PROFILE[0]) | 145 self.host.bridge.expect_call( |
146 "subscribe", "unsubscribe", Const.JID[0].userhost(), Const.PROFILE[0] | |
147 ) | |
111 self.presence.unsubscribeReceived(Const.JID[0]) | 148 self.presence.unsubscribeReceived(Const.JID[0]) |