Mercurial > libervia-backend
annotate sat/test/test_plugin_misc_room_game.py @ 2740:8fd8ce5a5855
jp (message/send, encryption): encryption handling:
- encryption algorithm can now be requested when sending a message (using --encrypt option)
- new encryption commands to (de)activate encryption session, check available algorithms, or manage trust.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 02 Jan 2019 18:50:57 +0100 |
parents | 56f94936df1e |
children | 003b8b4b56a7 |
rev | line source |
---|---|
1934
2daf7b4c6756
use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents:
1909
diff
changeset
|
1 #!/usr/bin/env python2 |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
4 # SAT: a jabber client |
2483 | 5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) |
1766 | 6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
7 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
8 # This program is free software: you can redistribute it and/or modify |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
9 # it under the terms of the GNU Affero General Public License as published by |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
10 # the Free Software Foundation, either version 3 of the License, or |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
11 # (at your option) any later version. |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
12 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
16 # GNU Affero General Public License for more details. |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
17 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Affero General Public License |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
20 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
21 """ Tests for the plugin room game (base class for MUC games) """ |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
22 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
23 from sat.core.i18n import _ |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
24 from constants import Const |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
25 from sat.test import helpers, helpers_plugins |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
26 from sat.plugins import plugin_misc_room_game as plugin |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
27 from twisted.words.protocols.jabber.jid import JID |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
28 from wokkel.muc import User |
997
b3f383ab39da
test: configuration/use of new logging system
Goffi <goffi@goffi.org>
parents:
993
diff
changeset
|
29 |
b3f383ab39da
test: configuration/use of new logging system
Goffi <goffi@goffi.org>
parents:
993
diff
changeset
|
30 from logging import WARNING |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
31 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
32 # Data used for test initialization |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
33 NAMESERVICE = "http://www.goffi.org/protocol/dummy" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
34 TAG = "dummy" |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
35 PLUGIN_INFO = { |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
36 "name": "Dummy plugin", |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
37 "import_name": "DUMMY", |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
38 "type": "MISC", |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 "protocols": [], |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
40 "dependencies": [], |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
41 "main": "Dummy", |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
42 "handler": "no", # handler MUST be "no" (dynamic inheritance) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
43 "description": _("""Dummy plugin to test room game"""), |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
44 } |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
45 |
1412 | 46 ROOM_JID = JID(Const.MUC_STR[0]) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
47 PROFILE = Const.PROFILE[0] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
48 OTHER_PROFILE = Const.PROFILE[1] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
49 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
50 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
51 class RoomGameTest(helpers.SatTestCase): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
52 def setUp(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
53 self.host = helpers.FakeSAT() |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
54 |
1271 | 55 def reinit(self, game_init={}, player_init={}): |
56 self.host.reinit() | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
57 self.plugin = plugin.RoomGame(self.host) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
58 self.plugin._init_( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
59 self.host, PLUGIN_INFO, (NAMESERVICE, TAG), game_init, player_init |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
60 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
61 self.plugin_0045 = self.host.plugins["XEP-0045"] = helpers_plugins.FakeXEP_0045( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
62 self.host |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
63 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
64 self.plugin_0249 = self.host.plugins["XEP-0249"] = helpers_plugins.FakeXEP_0249( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
65 self.host |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
66 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
67 for profile in Const.PROFILE: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
68 self.host.getClient(profile) # init self.host.profiles[profile] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
69 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
70 def initGame(self, muc_index, user_index): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
71 self.plugin_0045.joinRoom(user_index, muc_index) |
1412 | 72 self.plugin._initGame(JID(Const.MUC_STR[muc_index]), Const.JID[user_index].user) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
73 |
829
187d2443c82d
test: improvements for the helpers classes:
souliane <souliane@mailoo.org>
parents:
828
diff
changeset
|
74 def _expectedMessage(self, to, type_, tag, players=[]): |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
75 content = "<%s" % tag |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
76 if not players: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
77 content += "/>" |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
78 else: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
79 content += ">" |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
80 for i in xrange(0, len(players)): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
81 content += "<player index='%s'>%s</player>" % (i, players[i]) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
82 content += "</%s>" % tag |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
83 return "<message to='%s' type='%s'><%s xmlns='%s'>%s</dummy></message>" % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
84 to.full(), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
85 type_, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
86 TAG, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
87 NAMESERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
88 content, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
89 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
90 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
91 def test_createOrInvite_solo(self): |
1271 | 92 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
93 self.plugin_0045.joinRoom(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
94 self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), [], Const.PROFILE[0]) |
1412 | 95 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
96 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
97 def test_createOrInvite_multi_not_waiting(self): |
1271 | 98 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
99 self.plugin_0045.joinRoom(0, 0) |
1412 | 100 other_players = [Const.JID[1], Const.JID[2]] |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
101 self.plugin._createOrInvite( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
102 self.plugin_0045.getRoom(0, 0), other_players, Const.PROFILE[0] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
103 ) |
1412 | 104 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
105 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
106 def test_createOrInvite_multi_waiting(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
107 self.reinit(player_init={"score": 0}) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
108 self.plugin_0045.joinRoom(0, 0) |
1412 | 109 other_players = [Const.JID[1], Const.JID[2]] |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
110 self.plugin._createOrInvite( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
111 self.plugin_0045.getRoom(0, 0), other_players, Const.PROFILE[0] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
112 ) |
1412 | 113 self.assertTrue(self.plugin._gameExists(ROOM_JID, False)) |
114 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
115 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
116 def test_initGame(self): |
1271 | 117 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
118 self.initGame(0, 0) |
1412 | 119 self.assertTrue(self.plugin.isReferee(ROOM_JID, Const.JID[0].user)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
120 self.assertEqual([], self.plugin.games[ROOM_JID]["players"]) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
121 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
122 def test_checkJoinAuth(self): |
1271 | 123 self.reinit() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
124 check = lambda value: getattr(self, "assert%s" % value)( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
125 self.plugin._checkJoinAuth(ROOM_JID, Const.JID[0], Const.JID[0].user) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
126 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
127 check(False) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
128 # to test the "invited" mode, the referee must be different than the user to test |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
129 self.initGame(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
130 self.plugin.join_mode = self.plugin.ALL |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
131 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
132 self.plugin.join_mode = self.plugin.INVITED |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
133 check(False) |
1412 | 134 self.plugin.invitations[ROOM_JID] = [(None, [Const.JID[0].userhostJID()])] |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
135 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
136 self.plugin.join_mode = self.plugin.NONE |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
137 check(False) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
138 self.plugin.games[ROOM_JID]["players"].append(Const.JID[0].user) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
139 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
140 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
141 def test_updatePlayers(self): |
1271 | 142 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
143 self.initGame(0, 0) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
144 self.assertEqual(self.plugin.games[ROOM_JID]["players"], []) |
1412 | 145 self.plugin._updatePlayers(ROOM_JID, [], True, Const.PROFILE[0]) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
146 self.assertEqual(self.plugin.games[ROOM_JID]["players"], []) |
1412 | 147 self.plugin._updatePlayers(ROOM_JID, ["user1"], True, Const.PROFILE[0]) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
148 self.assertEqual(self.plugin.games[ROOM_JID]["players"], ["user1"]) |
1412 | 149 self.plugin._updatePlayers(ROOM_JID, ["user2", "user3"], True, Const.PROFILE[0]) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
150 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
151 self.plugin.games[ROOM_JID]["players"], ["user1", "user2", "user3"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
152 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
153 self.plugin._updatePlayers( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
154 ROOM_JID, ["user2", "user3"], True, Const.PROFILE[0] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
155 ) # should not be stored twice |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
156 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
157 self.plugin.games[ROOM_JID]["players"], ["user1", "user2", "user3"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
158 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
159 |
828
8f335c03eebb
plugins room_games, radiocol, libervia: small changes like refactorization to ease the maintenance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
160 def test_synchronizeRoom(self): |
1271 | 161 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
162 self.initGame(0, 0) |
1412 | 163 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
164 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
165 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
166 self._expectedMessage(ROOM_JID, "groupchat", "players", []), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
167 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
168 self.plugin.games[ROOM_JID]["players"].append("test1") |
1412 | 169 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
170 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
171 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
172 self._expectedMessage(ROOM_JID, "groupchat", "players", ["test1"]), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
173 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
174 self.plugin.games[ROOM_JID]["started"] = True |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
175 self.plugin.games[ROOM_JID]["players"].append("test2") |
1412 | 176 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
177 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
178 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
179 self._expectedMessage(ROOM_JID, "groupchat", "started", ["test1", "test2"]), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
180 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
181 self.plugin.games[ROOM_JID]["players"].append("test3") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
182 self.plugin.games[ROOM_JID]["players"].append("test4") |
1412 | 183 user1 = JID(ROOM_JID.userhost() + "/" + Const.JID[0].user) |
184 user2 = JID(ROOM_JID.userhost() + "/" + Const.JID[1].user) | |
185 self.plugin._synchronizeRoom(ROOM_JID, [user1, user2], Const.PROFILE[0]) | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
186 self.assertEqualXML( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
187 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
188 self._expectedMessage( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
189 user1, "normal", "started", ["test1", "test2", "test3", "test4"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
190 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
191 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
192 self.assertEqualXML( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
193 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
194 self._expectedMessage( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
195 user2, "normal", "started", ["test1", "test2", "test3", "test4"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
196 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
197 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
198 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
199 def test_invitePlayers(self): |
1271 | 200 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
201 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
202 self.plugin_0045.joinRoom(0, 1) |
1412 | 203 self.assertEqual(self.plugin.invitations[ROOM_JID], []) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
204 room = self.plugin_0045.getRoom(0, 0) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
205 nicks = self.plugin._invitePlayers( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
206 room, [Const.JID[1], Const.JID[2]], Const.JID[0].user, Const.PROFILE[0] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
207 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
208 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
209 self.plugin.invitations[ROOM_JID][0][1], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
210 [Const.JID[1].userhostJID(), Const.JID[2].userhostJID()], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
211 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
212 # the following assertion is True because Const.JID[1] and Const.JID[2] have the same userhost |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
213 self.assertEqual(nicks, [Const.JID[1].user, Const.JID[2].user]) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
214 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
215 nicks = self.plugin._invitePlayers( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
216 room, [Const.JID[1], Const.JID[3]], Const.JID[0].user, Const.PROFILE[0] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
217 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
218 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
219 self.plugin.invitations[ROOM_JID][1][1], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
220 [Const.JID[1].userhostJID(), Const.JID[3].userhostJID()], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
221 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
222 # this time Const.JID[1] and Const.JID[3] have the same user but the host differs |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
223 self.assertEqual(nicks, [Const.JID[1].user]) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
224 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
225 def test_checkInviteAuth(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
226 def check(value, index): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
227 nick = self.plugin_0045.getNick(0, index) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
228 getattr(self, "assert%s" % value)( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
229 self.plugin._checkInviteAuth(ROOM_JID, nick) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
230 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
231 |
1271 | 232 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
233 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
234 for mode in [ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
235 self.plugin.FROM_ALL, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
236 self.plugin.FROM_NONE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
237 self.plugin.FROM_REFEREE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
238 self.plugin.FROM_PLAYERS, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
239 ]: |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
240 self.plugin.invite_mode = mode |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
241 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
242 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
243 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
244 self.plugin.invite_mode = self.plugin.FROM_ALL |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
245 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
246 check(True, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
247 self.plugin.invite_mode = self.plugin.FROM_NONE |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
248 check(True, 0) # game initialized but not started yet, referee can invite |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
249 check(False, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
250 self.plugin.invite_mode = self.plugin.FROM_REFEREE |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
251 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
252 check(False, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
253 user_nick = self.plugin_0045.joinRoom(0, 1) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
254 self.plugin.games[ROOM_JID]["players"].append(user_nick) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
255 self.plugin.invite_mode = self.plugin.FROM_PLAYERS |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
256 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
257 check(True, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
258 check(False, 2) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
259 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
260 def test_isReferee(self): |
1271 | 261 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
262 self.initGame(0, 0) |
1412 | 263 self.assertTrue(self.plugin.isReferee(ROOM_JID, self.plugin_0045.getNick(0, 0))) |
264 self.assertFalse(self.plugin.isReferee(ROOM_JID, self.plugin_0045.getNick(0, 1))) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
265 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
266 def test_isPlayer(self): |
1271 | 267 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
268 self.initGame(0, 0) |
1412 | 269 self.assertTrue(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNick(0, 0))) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
270 user_nick = self.plugin_0045.joinRoom(0, 1) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
271 self.plugin.games[ROOM_JID]["players"].append(user_nick) |
1412 | 272 self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick)) |
273 self.assertFalse(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNick(0, 2))) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
274 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
275 def test_checkWaitAuth(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
276 def check(value, other_players, confirmed, rest): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
277 room = self.plugin_0045.getRoom(0, 0) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
278 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
279 (value, confirmed, rest), self.plugin._checkWaitAuth(room, other_players) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
280 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
281 |
1271 | 282 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
283 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
284 other_players = [Const.JID[1], Const.JID[3]] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
285 self.plugin.wait_mode = self.plugin.FOR_NONE |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
286 check(True, [], [], []) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
287 check( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
288 True, [Const.JID[0]], [], [Const.JID[0]] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
289 ) # getRoomNickOfUser checks for the other users only |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
290 check(True, other_players, [], other_players) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
291 self.plugin.wait_mode = self.plugin.FOR_ALL |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
292 check(True, [], [], []) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
293 check(False, [Const.JID[0]], [], [Const.JID[0]]) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
294 check(False, other_players, [], other_players) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
295 self.plugin_0045.joinRoom(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
296 check(False, other_players, [], other_players) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
297 self.plugin_0045.joinRoom(0, 4) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
298 check( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
299 False, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
300 other_players, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
301 [self.plugin_0045.getNickOfUser(0, 1, 0)], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
302 [Const.JID[3]], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
303 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
304 self.plugin_0045.joinRoom(0, 3) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
305 check( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
306 True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
307 other_players, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
308 [ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
309 self.plugin_0045.getNickOfUser(0, 1, 0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
310 self.plugin_0045.getNickOfUser(0, 3, 0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
311 ], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
312 [], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
313 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
314 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
315 other_players = [Const.JID[1], Const.JID[3], Const.JID[2]] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
316 # the following assertion is True because Const.JID[1] and Const.JID[2] have the same userhost |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
317 check( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
318 True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
319 other_players, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
320 [ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
321 self.plugin_0045.getNickOfUser(0, 1, 0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
322 self.plugin_0045.getNickOfUser(0, 3, 0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
323 self.plugin_0045.getNickOfUser(0, 2, 0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
324 ], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
325 [], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
326 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
327 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
328 def test_prepareRoom_trivial(self): |
1271 | 329 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
330 other_players = [] |
1412 | 331 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) |
332 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
333 self.assertTrue( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
334 self.plugin._checkJoinAuth(ROOM_JID, Const.JID[0], Const.JID[0].user) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
335 ) |
1412 | 336 self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[0].user)) |
337 self.assertEqual((True, [], []), self.plugin._checkWaitAuth(ROOM_JID, [])) | |
338 self.assertTrue(self.plugin.isReferee(ROOM_JID, Const.JID[0].user)) | |
339 self.assertTrue(self.plugin.isPlayer(ROOM_JID, Const.JID[0].user)) | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
340 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
341 (False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
342 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
343 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
344 def test_prepareRoom_invite(self): |
1271 | 345 self.reinit() |
1412 | 346 other_players = [Const.JID[1], Const.JID[2]] |
347 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
348 room = self.plugin_0045.getRoom(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
349 |
1412 | 350 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
351 self.assertTrue( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
352 self.plugin._checkJoinAuth(ROOM_JID, Const.JID[1], Const.JID[1].user) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
353 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
354 self.assertFalse( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
355 self.plugin._checkJoinAuth(ROOM_JID, Const.JID[3], Const.JID[3].user) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
356 ) |
1412 | 357 self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[1].user)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
358 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
359 (True, [], other_players), self.plugin._checkWaitAuth(room, other_players) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
360 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
361 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
362 player2_nick = self.plugin_0045.joinRoom(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
363 self.plugin.userJoinedTrigger(room, room.roster[player2_nick], PROFILE) |
1412 | 364 self.assertTrue(self.plugin.isPlayer(ROOM_JID, player2_nick)) |
365 self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID, player2_nick)) | |
366 self.assertFalse(self.plugin.isReferee(ROOM_JID, player2_nick)) | |
367 self.assertTrue(self.plugin.isPlayer(ROOM_JID, player2_nick)) | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
368 self.assertTrue( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
369 self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNickOfUser(0, 2, 0)) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
370 ) |
1412 | 371 self.assertFalse(self.plugin.isPlayer(ROOM_JID, "xxx")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
372 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
373 (False, False), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
374 self.plugin._checkCreateGameAndInit(ROOM_JID, Const.PROFILE[1]), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
375 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
376 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
377 def test_prepareRoom_score1(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
378 self.reinit(player_init={"score": 0}) |
1412 | 379 other_players = [Const.JID[1], Const.JID[2]] |
380 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
381 room = self.plugin_0045.getRoom(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
382 |
1412 | 383 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
384 self.assertTrue( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
385 self.plugin._checkJoinAuth(ROOM_JID, Const.JID[1], Const.JID[1].user) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
386 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
387 self.assertFalse( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
388 self.plugin._checkJoinAuth(ROOM_JID, Const.JID[3], Const.JID[3].user) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
389 ) |
1412 | 390 self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[1].user)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
391 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
392 (False, [], other_players), self.plugin._checkWaitAuth(room, other_players) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
393 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
394 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
395 user_nick = self.plugin_0045.joinRoom(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
396 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
1412 | 397 self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick)) |
398 self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, user_nick)) | |
399 self.assertFalse(self.plugin.isReferee(ROOM_JID, user_nick)) | |
400 self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
401 # the following assertion is True because Const.JID[1] and Const.JID[2] have the same userhost |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
402 self.assertTrue( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
403 self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNickOfUser(0, 2, 0)) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
404 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
405 # the following assertion is True because Const.JID[1] nick in the room is equal to Const.JID[3].user |
1412 | 406 self.assertTrue(self.plugin.isPlayer(ROOM_JID, Const.JID[3].user)) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
407 # but Const.JID[3] is actually not in the room |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
408 self.assertEqual(self.plugin_0045.getNickOfUser(0, 3, 0), None) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
409 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
410 (True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, Const.PROFILE[0]) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
411 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
412 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
413 def test_prepareRoom_score2(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
414 self.reinit(player_init={"score": 0}) |
1412 | 415 other_players = [Const.JID[1], Const.JID[4]] |
416 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
417 room = self.plugin_0045.getRoom(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
418 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
419 user_nick = self.plugin_0045.joinRoom(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
420 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
421 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
422 (True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
423 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
424 user_nick = self.plugin_0045.joinRoom(0, 4) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
425 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
426 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
427 (False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
428 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
429 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
430 def test_userJoinedTrigger(self): |
1271 | 431 self.reinit(player_init={"xxx": "xyz"}) |
1412 | 432 other_players = [Const.JID[1], Const.JID[3]] |
433 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
434 nicks = [self.plugin_0045.getNick(0, 0)] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
435 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
436 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
437 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
438 self._expectedMessage(ROOM_JID, "groupchat", "players", nicks), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
439 ) |
1412 | 440 self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 1) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
441 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
442 # wrong profile |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
443 user_nick = self.plugin_0045.joinRoom(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
444 room = self.plugin_0045.getRoom(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
445 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), OTHER_PROFILE) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
446 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
447 self.host.getSentMessage(0), None |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
448 ) # no new message has been sent |
1412 | 449 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) # game not started |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
450 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
451 # referee profile, user is allowed, wait for one more |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
452 room = self.plugin_0045.getRoom(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
453 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
454 nicks.append(user_nick) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
455 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
456 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
457 self._expectedMessage(ROOM_JID, "groupchat", "players", nicks), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
458 ) |
1412 | 459 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) # game not started |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
460 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
461 # referee profile, user is not allowed |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
462 user_nick = self.plugin_0045.joinRoom(0, 4) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
463 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[4]), PROFILE) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
464 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
465 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
466 self._expectedMessage( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
467 JID(ROOM_JID.userhost() + "/" + user_nick), "normal", "players", nicks |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
468 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
469 ) |
1412 | 470 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) # game not started |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
471 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
472 # referee profile, user is allowed, everybody here |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
473 user_nick = self.plugin_0045.joinRoom(0, 3) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
474 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[3]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
475 nicks.append(user_nick) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
476 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
477 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
478 self._expectedMessage(ROOM_JID, "groupchat", "started", nicks), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
479 ) |
1412 | 480 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) # game started |
481 self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 0) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
482 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
483 # wait for none |
1271 | 484 self.reinit() |
1412 | 485 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) |
1271 | 486 self.assertNotEqual(self.host.getSentMessage(0), None) # init messages |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
487 room = self.plugin_0045.getRoom(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
488 nicks = [self.plugin_0045.getNick(0, 0)] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
489 user_nick = self.plugin_0045.joinRoom(0, 3) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
490 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[3]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
491 nicks.append(user_nick) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
492 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
493 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
494 self._expectedMessage(ROOM_JID, "groupchat", "started", nicks), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
495 ) |
1412 | 496 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
497 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
498 def test_userLeftTrigger(self): |
1271 | 499 self.reinit(player_init={"xxx": "xyz"}) |
1412 | 500 other_players = [Const.JID[1], Const.JID[3], Const.JID[4]] |
501 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
502 room = self.plugin_0045.getRoom(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
503 nicks = [self.plugin_0045.getNick(0, 0)] |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
504 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
505 self.plugin.invitations[ROOM_JID][0][1], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
506 [ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
507 Const.JID[1].userhostJID(), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
508 Const.JID[3].userhostJID(), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
509 Const.JID[4].userhostJID(), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
510 ], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
511 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
512 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
513 # one user joins |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
514 user_nick = self.plugin_0045.joinRoom(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
515 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
516 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
517 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
518 # the user leaves |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
519 self.assertEqual(self.plugin.games[ROOM_JID]["players"], nicks) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
520 room = self.plugin_0045.getRoom(0, 1) |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
521 # to not call self.plugin_0045.leaveRoom(0, 1) here, we are testing the trigger with a wrong profile |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
522 self.plugin.userLeftTrigger( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
523 room, User(user_nick, Const.JID[1]), Const.PROFILE[1] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
524 ) # not the referee |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
525 self.assertEqual(self.plugin.games[ROOM_JID]["players"], nicks) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
526 room = self.plugin_0045.getRoom(0, 0) |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
527 user_nick = self.plugin_0045.leaveRoom(0, 1) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
528 self.plugin.userLeftTrigger( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
529 room, User(user_nick, Const.JID[1]), PROFILE |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
530 ) # referee |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
531 nicks.pop() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
532 self.assertEqual(self.plugin.games[ROOM_JID]["players"], nicks) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
533 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
534 # all the users join |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
535 user_nick = self.plugin_0045.joinRoom(0, 1) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
536 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
537 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
538 user_nick = self.plugin_0045.joinRoom(0, 3) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
539 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[3]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
540 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
541 user_nick = self.plugin_0045.joinRoom(0, 4) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
542 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[4]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
543 nicks.append(user_nick) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
544 self.assertEqual(self.plugin.games[ROOM_JID]["players"], nicks) |
1412 | 545 self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 0) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
546 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
547 # one user leaves |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
548 user_nick = self.plugin_0045.leaveRoom(0, 4) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
549 self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[4]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
550 nicks.pop() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
551 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
552 self.plugin.invitations[ROOM_JID][0][1], [Const.JID[4].userhostJID()] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
553 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
554 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
555 # another leaves |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
556 user_nick = self.plugin_0045.leaveRoom(0, 3) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
557 self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[3]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
558 nicks.pop() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
559 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
560 self.plugin.invitations[ROOM_JID][0][1], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
561 [Const.JID[4].userhostJID(), Const.JID[3].userhostJID()], |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
562 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
563 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
564 # they can join again |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
565 user_nick = self.plugin_0045.joinRoom(0, 3) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
566 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[3]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
567 nicks.append(user_nick) |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
568 user_nick = self.plugin_0045.joinRoom(0, 4) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
569 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[4]), PROFILE) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
570 nicks.append(user_nick) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
571 self.assertEqual(self.plugin.games[ROOM_JID]["players"], nicks) |
1412 | 572 self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 0) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
573 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
574 def test__checkCreateGameAndInit(self): |
1271 | 575 self.reinit() |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
576 helpers.muteLogging() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
577 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
578 (False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
579 ) |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
580 helpers.unmuteLogging() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
581 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
582 nick = self.plugin_0045.joinRoom(0, 0) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
583 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
584 (True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
585 ) |
1412 | 586 self.assertTrue(self.plugin._gameExists(ROOM_JID, False)) |
587 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) | |
588 self.assertTrue(self.plugin.isReferee(ROOM_JID, nick)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
589 |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
590 helpers.muteLogging() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
591 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
592 (False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
593 ) |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
594 helpers.unmuteLogging() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
595 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
596 self.plugin_0045.joinRoom(0, 1) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
597 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
598 (False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
599 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
600 |
1412 | 601 self.plugin.createGame(ROOM_JID, [Const.JID[1]], PROFILE) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
602 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
603 (False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
604 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
605 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
606 (False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
607 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
608 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
609 def test_createGame(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
610 |
1271 | 611 self.reinit(player_init={"xxx": "xyz"}) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
612 nicks = [] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
613 for i in [0, 1, 3, 4]: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
614 nicks.append(self.plugin_0045.joinRoom(0, i)) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
615 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
616 # game not exists |
1412 | 617 self.plugin.createGame(ROOM_JID, nicks, PROFILE) |
618 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
619 self.assertEqual(self.plugin.games[ROOM_JID]["players"], nicks) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
620 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
621 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
622 self._expectedMessage(ROOM_JID, "groupchat", "started", nicks), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
623 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
624 for nick in nicks: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
625 self.assertEqual("init", self.plugin.games[ROOM_JID]["status"][nick]) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
626 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
627 self.plugin.player_init, self.plugin.games[ROOM_JID]["players_data"][nick] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
628 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
629 self.plugin.games[ROOM_JID]["players_data"][nick]["xxx"] = nick |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
630 for nick in nicks: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
631 # checks that a copy of self.player_init has been done and not a reference |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
632 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
633 nick, self.plugin.games[ROOM_JID]["players_data"][nick]["xxx"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
634 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
635 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
636 # game exists, current profile is referee |
1271 | 637 self.reinit(player_init={"xxx": "xyz"}) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
638 self.initGame(0, 0) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
639 self.plugin.games[ROOM_JID]["started"] = True |
1412 | 640 self.plugin.createGame(ROOM_JID, nicks, PROFILE) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
641 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
642 self.host.getSentMessageXml(0), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
643 self._expectedMessage(ROOM_JID, "groupchat", "started", nicks), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
644 ) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
645 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
646 # game exists, current profile is not referee |
1271 | 647 self.reinit(player_init={"xxx": "xyz"}) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
648 self.initGame(0, 0) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
649 self.plugin.games[ROOM_JID]["started"] = True |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
650 self.plugin_0045.joinRoom(0, 1) |
1412 | 651 self.plugin.createGame(ROOM_JID, nicks, OTHER_PROFILE) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
652 self.assertEqual( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
653 self.host.getSentMessage(0), None |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
654 ) # no sync message has been sent by other_profile |