comparison libervia/backend/test/test_helpers_plugins.py @ 4071:4b842c1fb686

refactoring: renamed `sat` package to `libervia.backend`
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 11:49:51 +0200
parents sat/test/test_helpers_plugins.py@524856bd7b19
children
comparison
equal deleted inserted replaced
4070:d10748475025 4071:4b842c1fb686
1 #!/usr/bin/env python3
2
3
4 # SAT: a jabber client
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org)
7
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
17
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21 """ Test the helper classes to see if they behave well"""
22
23 from libervia.backend.test import helpers
24 from libervia.backend.test import helpers_plugins
25
26
27 class FakeXEP_0045Test(helpers.SatTestCase):
28 def setUp(self):
29 self.host = helpers.FakeSAT()
30 self.plugin = helpers_plugins.FakeXEP_0045(self.host)
31
32 def test_join_room(self):
33 self.plugin.join_room(0, 0)
34 self.assertEqual("test", self.plugin.get_nick(0, 0))
35 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 0))
36 self.assertEqual(None, self.plugin.get_nick_of_user(0, 1, 0))
37 self.assertEqual(None, self.plugin.get_nick_of_user(0, 2, 0))
38 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 0))
39 self.assertEqual("", self.plugin.get_nick(0, 1))
40 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 1))
41 self.assertEqual(None, self.plugin.get_nick_of_user(0, 1, 1))
42 self.assertEqual(None, self.plugin.get_nick_of_user(0, 2, 1))
43 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 1))
44 self.assertEqual("", self.plugin.get_nick(0, 2))
45 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 2))
46 self.assertEqual(None, self.plugin.get_nick_of_user(0, 1, 2))
47 self.assertEqual(None, self.plugin.get_nick_of_user(0, 2, 2))
48 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 2))
49 self.assertEqual("", self.plugin.get_nick(0, 3))
50 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 3))
51 self.assertEqual(None, self.plugin.get_nick_of_user(0, 1, 3))
52 self.assertEqual(None, self.plugin.get_nick_of_user(0, 2, 3))
53 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 3))
54 self.plugin.join_room(0, 1)
55 self.assertEqual("test", self.plugin.get_nick(0, 0))
56 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 0))
57 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 1, 0))
58 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 2, 0))
59 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 0))
60 self.assertEqual("sender", self.plugin.get_nick(0, 1))
61 self.assertEqual("test", self.plugin.get_nick_of_user(0, 0, 1))
62 self.assertEqual(None, self.plugin.get_nick_of_user(0, 1, 1))
63 self.assertEqual(None, self.plugin.get_nick_of_user(0, 2, 1))
64 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 1))
65 self.assertEqual("", self.plugin.get_nick(0, 2))
66 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 2))
67 self.assertEqual(None, self.plugin.get_nick_of_user(0, 1, 2))
68 self.assertEqual(None, self.plugin.get_nick_of_user(0, 2, 2))
69 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 2))
70 self.assertEqual("", self.plugin.get_nick(0, 3))
71 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 3))
72 self.assertEqual(None, self.plugin.get_nick_of_user(0, 1, 3))
73 self.assertEqual(None, self.plugin.get_nick_of_user(0, 2, 3))
74 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 3))
75 self.plugin.join_room(0, 2)
76 self.assertEqual("test", self.plugin.get_nick(0, 0))
77 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 0))
78 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 1, 0))
79 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 2, 0))
80 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 0))
81 self.assertEqual("sender", self.plugin.get_nick(0, 1))
82 self.assertEqual("test", self.plugin.get_nick_of_user(0, 0, 1))
83 self.assertEqual(
84 "sender", self.plugin.get_nick_of_user(0, 1, 1)
85 ) # Const.JID[2] is in the roster for Const.PROFILE[1]
86 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 2, 1))
87 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 1))
88 self.assertEqual("sender", self.plugin.get_nick(0, 2))
89 self.assertEqual("test", self.plugin.get_nick_of_user(0, 0, 2))
90 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 1, 2))
91 self.assertEqual(
92 "sender", self.plugin.get_nick_of_user(0, 2, 2)
93 ) # Const.JID[1] is in the roster for Const.PROFILE[2]
94 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 2))
95 self.assertEqual("", self.plugin.get_nick(0, 3))
96 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 3))
97 self.assertEqual(None, self.plugin.get_nick_of_user(0, 1, 3))
98 self.assertEqual(None, self.plugin.get_nick_of_user(0, 2, 3))
99 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 3))
100 self.plugin.join_room(0, 3)
101 self.assertEqual("test", self.plugin.get_nick(0, 0))
102 self.assertEqual(None, self.plugin.get_nick_of_user(0, 0, 0))
103 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 1, 0))
104 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 2, 0))
105 self.assertEqual("sender_", self.plugin.get_nick_of_user(0, 3, 0))
106 self.assertEqual("sender", self.plugin.get_nick(0, 1))
107 self.assertEqual("test", self.plugin.get_nick_of_user(0, 0, 1))
108 self.assertEqual(
109 "sender", self.plugin.get_nick_of_user(0, 1, 1)
110 ) # Const.JID[2] is in the roster for Const.PROFILE[1]
111 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 2, 1))
112 self.assertEqual("sender_", self.plugin.get_nick_of_user(0, 3, 1))
113 self.assertEqual("sender", self.plugin.get_nick(0, 2))
114 self.assertEqual("test", self.plugin.get_nick_of_user(0, 0, 2))
115 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 1, 2))
116 self.assertEqual(
117 "sender", self.plugin.get_nick_of_user(0, 2, 2)
118 ) # Const.JID[1] is in the roster for Const.PROFILE[2]
119 self.assertEqual("sender_", self.plugin.get_nick_of_user(0, 3, 2))
120 self.assertEqual("sender_", self.plugin.get_nick(0, 3))
121 self.assertEqual("test", self.plugin.get_nick_of_user(0, 0, 3))
122 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 1, 3))
123 self.assertEqual("sender", self.plugin.get_nick_of_user(0, 2, 3))
124 self.assertEqual(None, self.plugin.get_nick_of_user(0, 3, 3))