comparison src/test/test_helpers_plugins.py @ 794:52c4b755aba6

test: make FakeClient profile dependent and add some tools to test MUC
author souliane <souliane@mailoo.org>
date Fri, 10 Jan 2014 18:15:02 +0100
parents
children 1fe00f0c9a91
comparison
equal deleted inserted replaced
793:cb2db0d85029 794:52c4b755aba6
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # SAT: a jabber client
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org)
6 # Copyright (C) 2013 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 import helpers
24 import helpers_plugins
25
26
27 class FakeXEP_0045Test(helpers.SatTestCase):
28
29 def setUp(self):
30 self.host = helpers.FakeSAT()
31 self.plugin = helpers_plugins.FakeXEP_0045(self.host)
32
33 def test_joinRoom(self):
34 self.plugin.joinRoom(0, 0)
35 self.assertEqual('test', self.plugin.getNick(0, 0))
36 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 0))
37 self.assertEqual(None, self.plugin.getNickOfUser(0, 1, 0))
38 self.assertEqual(None, self.plugin.getNickOfUser(0, 2, 0))
39 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 0))
40 self.assertEqual('', self.plugin.getNick(0, 1))
41 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 1))
42 self.assertEqual(None, self.plugin.getNickOfUser(0, 1, 1))
43 self.assertEqual(None, self.plugin.getNickOfUser(0, 2, 1))
44 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 1))
45 self.assertEqual('', self.plugin.getNick(0, 2))
46 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 2))
47 self.assertEqual(None, self.plugin.getNickOfUser(0, 1, 2))
48 self.assertEqual(None, self.plugin.getNickOfUser(0, 2, 2))
49 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 2))
50 self.assertEqual('', self.plugin.getNick(0, 3))
51 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 3))
52 self.assertEqual(None, self.plugin.getNickOfUser(0, 1, 3))
53 self.assertEqual(None, self.plugin.getNickOfUser(0, 2, 3))
54 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 3))
55 self.plugin.joinRoom(0, 1)
56 self.assertEqual('test', self.plugin.getNick(0, 0))
57 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 0))
58 self.assertEqual('sender', self.plugin.getNickOfUser(0, 1, 0))
59 self.assertEqual('sender', self.plugin.getNickOfUser(0, 2, 0))
60 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 0))
61 self.assertEqual('sender', self.plugin.getNick(0, 1))
62 self.assertEqual('test', self.plugin.getNickOfUser(0, 0, 1))
63 self.assertEqual(None, self.plugin.getNickOfUser(0, 1, 1))
64 self.assertEqual(None, self.plugin.getNickOfUser(0, 2, 1))
65 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 1))
66 self.assertEqual('', self.plugin.getNick(0, 2))
67 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 2))
68 self.assertEqual(None, self.plugin.getNickOfUser(0, 1, 2))
69 self.assertEqual(None, self.plugin.getNickOfUser(0, 2, 2))
70 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 2))
71 self.assertEqual('', self.plugin.getNick(0, 3))
72 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 3))
73 self.assertEqual(None, self.plugin.getNickOfUser(0, 1, 3))
74 self.assertEqual(None, self.plugin.getNickOfUser(0, 2, 3))
75 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 3))
76 self.plugin.joinRoom(0, 2)
77 self.assertEqual('test', self.plugin.getNick(0, 0))
78 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 0))
79 self.assertEqual('sender', self.plugin.getNickOfUser(0, 1, 0))
80 self.assertEqual('sender', self.plugin.getNickOfUser(0, 2, 0))
81 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 0))
82 self.assertEqual('sender', self.plugin.getNick(0, 1))
83 self.assertEqual('test', self.plugin.getNickOfUser(0, 0, 1))
84 self.assertEqual('sender', self.plugin.getNickOfUser(0, 1, 1)) # Const.JID[2] is in the roster for Const.PROFILE[1]
85 self.assertEqual('sender', self.plugin.getNickOfUser(0, 2, 1))
86 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 1))
87 self.assertEqual('sender', self.plugin.getNick(0, 2))
88 self.assertEqual('test', self.plugin.getNickOfUser(0, 0, 2))
89 self.assertEqual('sender', self.plugin.getNickOfUser(0, 1, 2))
90 self.assertEqual('sender', self.plugin.getNickOfUser(0, 2, 2)) # Const.JID[1] is in the roster for Const.PROFILE[2]
91 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 2))
92 self.assertEqual('', self.plugin.getNick(0, 3))
93 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 3))
94 self.assertEqual(None, self.plugin.getNickOfUser(0, 1, 3))
95 self.assertEqual(None, self.plugin.getNickOfUser(0, 2, 3))
96 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 3))
97 self.plugin.joinRoom(0, 3)
98 self.assertEqual('test', self.plugin.getNick(0, 0))
99 self.assertEqual(None, self.plugin.getNickOfUser(0, 0, 0))
100 self.assertEqual('sender', self.plugin.getNickOfUser(0, 1, 0))
101 self.assertEqual('sender', self.plugin.getNickOfUser(0, 2, 0))
102 self.assertEqual('sender_', self.plugin.getNickOfUser(0, 3, 0))
103 self.assertEqual('sender', self.plugin.getNick(0, 1))
104 self.assertEqual('test', self.plugin.getNickOfUser(0, 0, 1))
105 self.assertEqual('sender', self.plugin.getNickOfUser(0, 1, 1)) # Const.JID[2] is in the roster for Const.PROFILE[1]
106 self.assertEqual('sender', self.plugin.getNickOfUser(0, 2, 1))
107 self.assertEqual('sender_', self.plugin.getNickOfUser(0, 3, 1))
108 self.assertEqual('sender', self.plugin.getNick(0, 2))
109 self.assertEqual('test', self.plugin.getNickOfUser(0, 0, 2))
110 self.assertEqual('sender', self.plugin.getNickOfUser(0, 1, 2))
111 self.assertEqual('sender', self.plugin.getNickOfUser(0, 2, 2)) # Const.JID[1] is in the roster for Const.PROFILE[2]
112 self.assertEqual('sender_', self.plugin.getNickOfUser(0, 3, 2))
113 self.assertEqual('sender_', self.plugin.getNick(0, 3))
114 self.assertEqual('test', self.plugin.getNickOfUser(0, 0, 3))
115 self.assertEqual('sender', self.plugin.getNickOfUser(0, 1, 3))
116 self.assertEqual('sender', self.plugin.getNickOfUser(0, 2, 3))
117 self.assertEqual(None, self.plugin.getNickOfUser(0, 3, 3))