Mercurial > libervia-backend
annotate src/test/test_plugin_misc_room_game.py @ 1904:614f3abb2c69
plugin XEP-0060: fixed traceback if service was None
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 10 Mar 2016 17:50:17 +0100 |
parents | d17772b0fe22 |
children | 0681d69cbe0a |
rev | line source |
---|---|
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
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 |
1766 | 5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
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 _ |
997
b3f383ab39da
test: configuration/use of new logging system
Goffi <goffi@goffi.org>
parents:
993
diff
changeset
|
24 from sat.core.log import getLogger |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
25 from constants import Const |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 from wokkel.muc import User |
997
b3f383ab39da
test: configuration/use of new logging system
Goffi <goffi@goffi.org>
parents:
993
diff
changeset
|
30 |
b3f383ab39da
test: configuration/use of new logging system
Goffi <goffi@goffi.org>
parents:
993
diff
changeset
|
31 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
|
32 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
33 # Data used for test initialization |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
34 NAMESERVICE = 'http://www.goffi.org/protocol/dummy' |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
35 TAG = 'dummy' |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
36 PLUGIN_INFO = { |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
37 "name": "Dummy plugin", |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
38 "import_name": "DUMMY", |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 "type": "MISC", |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
40 "protocols": [], |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
41 "dependencies": [], |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
42 "main": "Dummy", |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
43 "handler": "no", # handler MUST be "no" (dynamic inheritance) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
44 "description": _("""Dummy plugin to test room game""") |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
45 } |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
46 |
1412 | 47 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
|
48 PROFILE = Const.PROFILE[0] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
49 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
|
50 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
51 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
52 class RoomGameTest(helpers.SatTestCase): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
53 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
54 def setUp(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
55 self.host = helpers.FakeSAT() |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
56 |
1271 | 57 def reinit(self, game_init={}, player_init={}): |
58 self.host.reinit() | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
59 self.plugin = plugin.RoomGame(self.host) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
60 self.plugin._init_(self.host, PLUGIN_INFO, (NAMESERVICE, TAG), game_init, player_init) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
61 self.plugin_0045 = self.host.plugins['XEP-0045'] = helpers_plugins.FakeXEP_0045(self.host) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
62 self.plugin_0249 = self.host.plugins['XEP-0249'] = helpers_plugins.FakeXEP_0249(self.host) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
63 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
|
64 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
|
65 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
66 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
|
67 self.plugin_0045.joinRoom(user_index, muc_index) |
1412 | 68 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
|
69 |
829
187d2443c82d
test: improvements for the helpers classes:
souliane <souliane@mailoo.org>
parents:
828
diff
changeset
|
70 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
|
71 content = "<%s" % tag |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
72 if not players: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
73 content += "/>" |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
74 else: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
75 content += ">" |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
76 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
|
77 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
|
78 content += "</%s>" % tag |
1412 | 79 return "<message to='%s' type='%s'><%s xmlns='%s'>%s</dummy></message>" % (to.full(), type_, TAG, NAMESERVICE, content) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
80 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
81 def test_createOrInvite_solo(self): |
1271 | 82 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
83 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
|
84 self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), [], Const.PROFILE[0]) |
1412 | 85 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
|
86 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
87 def test_createOrInvite_multi_not_waiting(self): |
1271 | 88 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
89 self.plugin_0045.joinRoom(0, 0) |
1412 | 90 other_players = [Const.JID[1], Const.JID[2]] |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
91 self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), other_players, Const.PROFILE[0]) |
1412 | 92 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
|
93 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
94 def test_createOrInvite_multi_waiting(self): |
1271 | 95 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
|
96 self.plugin_0045.joinRoom(0, 0) |
1412 | 97 other_players = [Const.JID[1], Const.JID[2]] |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
98 self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), other_players, Const.PROFILE[0]) |
1412 | 99 self.assertTrue(self.plugin._gameExists(ROOM_JID, False)) |
100 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
|
101 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
102 def test_initGame(self): |
1271 | 103 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
104 self.initGame(0, 0) |
1412 | 105 self.assertTrue(self.plugin.isReferee(ROOM_JID, Const.JID[0].user)) |
106 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
|
107 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
108 def test_checkJoinAuth(self): |
1271 | 109 self.reinit() |
1412 | 110 check = lambda value: getattr(self, "assert%s" % value)(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[0], 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
|
111 check(False) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
112 # 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
|
113 self.initGame(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
114 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
|
115 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
116 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
|
117 check(False) |
1412 | 118 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
|
119 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
120 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
|
121 check(False) |
1412 | 122 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
|
123 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
124 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
125 def test_updatePlayers(self): |
1271 | 126 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
127 self.initGame(0, 0) |
1412 | 128 self.assertEqual(self.plugin.games[ROOM_JID]['players'], []) |
129 self.plugin._updatePlayers(ROOM_JID, [], True, Const.PROFILE[0]) | |
130 self.assertEqual(self.plugin.games[ROOM_JID]['players'], []) | |
131 self.plugin._updatePlayers(ROOM_JID, ["user1"], True, Const.PROFILE[0]) | |
132 self.assertEqual(self.plugin.games[ROOM_JID]['players'], ["user1"]) | |
133 self.plugin._updatePlayers(ROOM_JID, ["user2", "user3"], True, Const.PROFILE[0]) | |
134 self.assertEqual(self.plugin.games[ROOM_JID]['players'], ["user1", "user2", "user3"]) | |
135 self.plugin._updatePlayers(ROOM_JID, ["user2", "user3"], True, Const.PROFILE[0]) # should not be stored twice | |
136 self.assertEqual(self.plugin.games[ROOM_JID]['players'], ["user1", "user2", "user3"]) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
137 |
828
8f335c03eebb
plugins room_games, radiocol, libervia: small changes like refactorization to ease the maintenance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
138 def test_synchronizeRoom(self): |
1271 | 139 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
140 self.initGame(0, 0) |
1412 | 141 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) |
142 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", [])) | |
143 self.plugin.games[ROOM_JID]['players'].append("test1") | |
144 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) | |
145 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", ["test1"])) | |
146 self.plugin.games[ROOM_JID]['started'] = True | |
147 self.plugin.games[ROOM_JID]['players'].append("test2") | |
148 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) | |
149 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", ["test1", "test2"])) | |
150 self.plugin.games[ROOM_JID]['players'].append("test3") | |
151 self.plugin.games[ROOM_JID]['players'].append("test4") | |
152 user1 = JID(ROOM_JID.userhost() + "/" + Const.JID[0].user) | |
153 user2 = JID(ROOM_JID.userhost() + "/" + Const.JID[1].user) | |
154 self.plugin._synchronizeRoom(ROOM_JID, [user1, user2], Const.PROFILE[0]) | |
155 self.assertEqualXML(self.host.getSentMessageXml(0), self._expectedMessage(user1, "normal", "started", ["test1", "test2", "test3", "test4"])) | |
156 self.assertEqualXML(self.host.getSentMessageXml(0), self._expectedMessage(user2, "normal", "started", ["test1", "test2", "test3", "test4"])) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
157 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
158 def test_invitePlayers(self): |
1271 | 159 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
160 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
161 self.plugin_0045.joinRoom(0, 1) |
1412 | 162 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
|
163 room = self.plugin_0045.getRoom(0, 0) |
1412 | 164 nicks = self.plugin._invitePlayers(room, [Const.JID[1], Const.JID[2]], Const.JID[0].user, Const.PROFILE[0]) |
165 self.assertEqual(self.plugin.invitations[ROOM_JID][0][1], [Const.JID[1].userhostJID(), Const.JID[2].userhostJID()]) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
166 # 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
|
167 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
|
168 |
1412 | 169 nicks = self.plugin._invitePlayers(room, [Const.JID[1], Const.JID[3]], Const.JID[0].user, Const.PROFILE[0]) |
170 self.assertEqual(self.plugin.invitations[ROOM_JID][1][1], [Const.JID[1].userhostJID(), Const.JID[3].userhostJID()]) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
171 # 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
|
172 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
|
173 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
174 def test_checkInviteAuth(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
175 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
176 def check(value, index): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
177 nick = self.plugin_0045.getNick(0, index) |
1412 | 178 getattr(self, "assert%s" % value)(self.plugin._checkInviteAuth(ROOM_JID, nick)) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
179 |
1271 | 180 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
181 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
182 for mode in [self.plugin.FROM_ALL, self.plugin.FROM_NONE, self.plugin.FROM_REFEREE, self.plugin.FROM_PLAYERS]: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
183 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
|
184 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
185 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
186 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
187 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
|
188 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
189 check(True, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
190 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
|
191 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
|
192 check(False, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
193 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
|
194 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
195 check(False, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
196 user_nick = self.plugin_0045.joinRoom(0, 1) |
1412 | 197 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
|
198 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
|
199 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
200 check(True, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
201 check(False, 2) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
202 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
203 def test_isReferee(self): |
1271 | 204 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
205 self.initGame(0, 0) |
1412 | 206 self.assertTrue(self.plugin.isReferee(ROOM_JID, self.plugin_0045.getNick(0, 0))) |
207 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
|
208 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
209 def test_isPlayer(self): |
1271 | 210 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
211 self.initGame(0, 0) |
1412 | 212 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
|
213 user_nick = self.plugin_0045.joinRoom(0, 1) |
1412 | 214 self.plugin.games[ROOM_JID]['players'].append(user_nick) |
215 self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick)) | |
216 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
|
217 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
218 def test_checkWaitAuth(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
219 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
220 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
|
221 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
|
222 self.assertEqual((value, confirmed, rest), self.plugin._checkWaitAuth(room, other_players)) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
223 |
1271 | 224 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
225 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
226 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
|
227 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
|
228 check(True, [], [], []) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
229 check(True, [Const.JID[0]], [], [Const.JID[0]]) # getRoomNickOfUser checks for the other users only |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
230 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
|
231 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
|
232 check(True, [], [], []) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 check(False, other_players, [self.plugin_0045.getNickOfUser(0, 1, 0)], [Const.JID[3]]) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
239 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
|
240 check(True, other_players, [self.plugin_0045.getNickOfUser(0, 1, 0), |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
241 self.plugin_0045.getNickOfUser(0, 3, 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 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
|
244 # 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
|
245 check(True, other_players, [self.plugin_0045.getNickOfUser(0, 1, 0), |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
246 self.plugin_0045.getNickOfUser(0, 3, 0), |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
247 self.plugin_0045.getNickOfUser(0, 2, 0)], []) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
248 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
249 def test_prepareRoom_trivial(self): |
1271 | 250 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
251 other_players = [] |
1412 | 252 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) |
253 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) | |
254 self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[0], Const.JID[0].user)) | |
255 self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[0].user)) | |
256 self.assertEqual((True, [], []), self.plugin._checkWaitAuth(ROOM_JID, [])) | |
257 self.assertTrue(self.plugin.isReferee(ROOM_JID, Const.JID[0].user)) | |
258 self.assertTrue(self.plugin.isPlayer(ROOM_JID, Const.JID[0].user)) | |
259 self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
260 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
261 def test_prepareRoom_invite(self): |
1271 | 262 self.reinit() |
1412 | 263 other_players = [Const.JID[1], Const.JID[2]] |
264 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
|
265 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
|
266 |
1412 | 267 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) |
268 self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[1], Const.JID[1].user)) | |
269 self.assertFalse(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[3], Const.JID[3].user)) | |
270 self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[1].user)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
271 self.assertEqual((True, [], other_players), self.plugin._checkWaitAuth(room, other_players)) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
272 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
273 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
|
274 self.plugin.userJoinedTrigger(room, room.roster[player2_nick], PROFILE) |
1412 | 275 self.assertTrue(self.plugin.isPlayer(ROOM_JID, player2_nick)) |
276 self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID, player2_nick)) | |
277 self.assertFalse(self.plugin.isReferee(ROOM_JID, player2_nick)) | |
278 self.assertTrue(self.plugin.isPlayer(ROOM_JID, player2_nick)) | |
279 self.assertTrue(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNickOfUser(0, 2, 0))) | |
280 self.assertFalse(self.plugin.isPlayer(ROOM_JID, "xxx")) | |
281 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, Const.PROFILE[1])) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
282 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
283 def test_prepareRoom_score1(self): |
1271 | 284 self.reinit(player_init={'score': 0}) |
1412 | 285 other_players = [Const.JID[1], Const.JID[2]] |
286 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
|
287 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
|
288 |
1412 | 289 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) |
290 self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[1], Const.JID[1].user)) | |
291 self.assertFalse(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[3], Const.JID[3].user)) | |
292 self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[1].user)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
293 self.assertEqual((False, [], other_players), self.plugin._checkWaitAuth(room, other_players)) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
294 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
295 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
|
296 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
1412 | 297 self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick)) |
298 self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, user_nick)) | |
299 self.assertFalse(self.plugin.isReferee(ROOM_JID, user_nick)) | |
300 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
|
301 # the following assertion is True because Const.JID[1] and Const.JID[2] have the same userhost |
1412 | 302 self.assertTrue(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNickOfUser(0, 2, 0))) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
303 # the following assertion is True because Const.JID[1] nick in the room is equal to Const.JID[3].user |
1412 | 304 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
|
305 # 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
|
306 self.assertEqual(self.plugin_0045.getNickOfUser(0, 3, 0), None) |
1412 | 307 self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, Const.PROFILE[0])) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
308 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
309 def test_prepareRoom_score2(self): |
1271 | 310 self.reinit(player_init={'score': 0}) |
1412 | 311 other_players = [Const.JID[1], Const.JID[4]] |
312 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
|
313 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
|
314 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
315 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
|
316 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
1412 | 317 self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
318 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
|
319 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
1412 | 320 self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
321 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
322 def test_userJoinedTrigger(self): |
1271 | 323 self.reinit(player_init={"xxx": "xyz"}) |
1412 | 324 other_players = [Const.JID[1], Const.JID[3]] |
325 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
|
326 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
|
327 |
1412 | 328 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", nicks)) |
329 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
|
330 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
331 # wrong profile |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
332 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
|
333 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
|
334 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), OTHER_PROFILE) |
1271 | 335 self.assertEqual(self.host.getSentMessage(0), None) # no new message has been sent |
1412 | 336 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
|
337 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
338 # 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
|
339 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
|
340 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
|
341 nicks.append(user_nick) |
1412 | 342 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", nicks)) |
343 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
|
344 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
345 # 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
|
346 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
|
347 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[4]), PROFILE) |
1412 | 348 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(JID(ROOM_JID.userhost() + '/' + user_nick), "normal", "players", nicks)) |
349 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
|
350 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
351 # 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
|
352 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
|
353 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
|
354 nicks.append(user_nick) |
1412 | 355 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks)) |
356 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) # game started | |
357 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
|
358 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
359 # wait for none |
1271 | 360 self.reinit() |
1412 | 361 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) |
1271 | 362 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
|
363 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
|
364 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
|
365 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
|
366 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
|
367 nicks.append(user_nick) |
1412 | 368 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks)) |
369 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
|
370 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
371 def test_userLeftTrigger(self): |
1271 | 372 self.reinit(player_init={"xxx": "xyz"}) |
1412 | 373 other_players = [Const.JID[1], Const.JID[3], Const.JID[4]] |
374 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
|
375 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
|
376 nicks = [self.plugin_0045.getNick(0, 0)] |
1412 | 377 self.assertEqual(self.plugin.invitations[ROOM_JID][0][1], [Const.JID[1].userhostJID(), Const.JID[3].userhostJID(), Const.JID[4].userhostJID()]) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
378 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
379 # one user joins |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
380 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
|
381 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
|
382 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
383 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
384 # the user leaves |
1412 | 385 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
|
386 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
|
387 # to not call self.plugin_0045.leaveRoom(0, 1) here, we are testing the trigger with a wrong profile |
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
388 self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[1]), Const.PROFILE[1]) # not the referee |
1412 | 389 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
|
390 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
|
391 user_nick = self.plugin_0045.leaveRoom(0, 1) |
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
392 self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[1]), PROFILE) # referee |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
393 nicks.pop() |
1412 | 394 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
|
395 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
396 # all the users join |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
397 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
|
398 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
|
399 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
400 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
|
401 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
|
402 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
403 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
|
404 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
|
405 nicks.append(user_nick) |
1412 | 406 self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks) |
407 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
|
408 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
409 # one user leaves |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
410 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
|
411 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
|
412 nicks.pop() |
1412 | 413 self.assertEqual(self.plugin.invitations[ROOM_JID][0][1], [Const.JID[4].userhostJID()]) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
414 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
415 # another leaves |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
416 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
|
417 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
|
418 nicks.pop() |
1412 | 419 self.assertEqual(self.plugin.invitations[ROOM_JID][0][1], [Const.JID[4].userhostJID(), Const.JID[3].userhostJID()]) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
420 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
421 # they can join again |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
422 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
|
423 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
|
424 nicks.append(user_nick) |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
425 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
|
426 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
|
427 nicks.append(user_nick) |
1412 | 428 self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks) |
429 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
|
430 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
431 def test__checkCreateGameAndInit(self): |
1271 | 432 self.reinit() |
1412 | 433 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) # print internal error |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
434 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
435 nick = self.plugin_0045.joinRoom(0, 0) |
1412 | 436 self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) |
437 self.assertTrue(self.plugin._gameExists(ROOM_JID, False)) | |
438 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) | |
439 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
|
440 |
1412 | 441 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE)) # print internal error |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
442 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
443 self.plugin_0045.joinRoom(0, 1) |
1412 | 444 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE)) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
445 |
1412 | 446 self.plugin.createGame(ROOM_JID, [Const.JID[1]], PROFILE) |
447 self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) | |
448 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
449 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
450 def test_createGame(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
451 |
1271 | 452 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
|
453 nicks = [] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
454 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
|
455 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
|
456 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
457 # game not exists |
1412 | 458 self.plugin.createGame(ROOM_JID, nicks, PROFILE) |
459 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) | |
460 self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks) | |
461 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
462 for nick in nicks: |
1412 | 463 self.assertEqual('init', self.plugin.games[ROOM_JID]['status'][nick]) |
464 self.assertEqual(self.plugin.player_init, self.plugin.games[ROOM_JID]['players_data'][nick]) | |
465 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
|
466 for nick in nicks: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
467 # checks that a copy of self.player_init has been done and not a reference |
1412 | 468 self.assertEqual(nick, self.plugin.games[ROOM_JID]['players_data'][nick]['xxx']) |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
469 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
470 # game exists, current profile is referee |
1271 | 471 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
|
472 self.initGame(0, 0) |
1412 | 473 self.plugin.games[ROOM_JID]['started'] = True |
474 self.plugin.createGame(ROOM_JID, nicks, PROFILE) | |
475 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks)) | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
476 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
477 # game exists, current profile is not referee |
1271 | 478 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
|
479 self.initGame(0, 0) |
1412 | 480 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
|
481 self.plugin_0045.joinRoom(0, 1) |
1412 | 482 self.plugin.createGame(ROOM_JID, nicks, OTHER_PROFILE) |
1271 | 483 self.assertEqual(self.host.getSentMessage(0), None) # no sync message has been sent by other_profile |