Mercurial > libervia-backend
annotate sat/test/test_plugin_misc_room_game.py @ 2617:81b70eeb710f
quick_frontend(contact list): refactored update:
update is now called with appropriate constant value (C.UPDATE_ADD, C.UPDATE_DELETE, C.UPDATE_MODIFY and so on) when a widget change visibility according to current options.
Before it was linked to cache only (C.UPDATE_ADD was only called when contact was first added to cache).
This make widget handling in frontends more easy.
Renamed entityToShow to entityVisible, which seems to correspond better.
Started reducing lines lenght to 90 chars as a test. May become the new coding style soon.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 24 Jun 2018 21:59:29 +0200 |
parents | 26edcf3a30eb |
children | 56f94936df1e |
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 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
33 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
|
34 TAG = 'dummy' |
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) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
43 "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
|
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 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
53 def setUp(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
54 self.host = helpers.FakeSAT() |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
55 |
1271 | 56 def reinit(self, game_init={}, player_init={}): |
57 self.host.reinit() | |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
65 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
|
66 self.plugin_0045.joinRoom(user_index, muc_index) |
1412 | 67 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
|
68 |
829
187d2443c82d
test: improvements for the helpers classes:
souliane <souliane@mailoo.org>
parents:
828
diff
changeset
|
69 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
|
70 content = "<%s" % tag |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
71 if not players: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
72 content += "/>" |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
73 else: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
74 content += ">" |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
75 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
|
76 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
|
77 content += "</%s>" % tag |
1412 | 78 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
|
79 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
80 def test_createOrInvite_solo(self): |
1271 | 81 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
82 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
|
83 self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), [], Const.PROFILE[0]) |
1412 | 84 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
|
85 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
86 def test_createOrInvite_multi_not_waiting(self): |
1271 | 87 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
88 self.plugin_0045.joinRoom(0, 0) |
1412 | 89 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
|
90 self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), other_players, Const.PROFILE[0]) |
1412 | 91 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
|
92 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
93 def test_createOrInvite_multi_waiting(self): |
1271 | 94 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
|
95 self.plugin_0045.joinRoom(0, 0) |
1412 | 96 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
|
97 self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), other_players, Const.PROFILE[0]) |
1412 | 98 self.assertTrue(self.plugin._gameExists(ROOM_JID, False)) |
99 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
|
100 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
101 def test_initGame(self): |
1271 | 102 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
103 self.initGame(0, 0) |
1412 | 104 self.assertTrue(self.plugin.isReferee(ROOM_JID, Const.JID[0].user)) |
105 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
|
106 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
107 def test_checkJoinAuth(self): |
1271 | 108 self.reinit() |
1412 | 109 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
|
110 check(False) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
111 # 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
|
112 self.initGame(0, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
113 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
|
114 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
115 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
|
116 check(False) |
1412 | 117 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
|
118 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
119 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
|
120 check(False) |
1412 | 121 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
|
122 check(True) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
123 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
124 def test_updatePlayers(self): |
1271 | 125 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
126 self.initGame(0, 0) |
1412 | 127 self.assertEqual(self.plugin.games[ROOM_JID]['players'], []) |
128 self.plugin._updatePlayers(ROOM_JID, [], True, Const.PROFILE[0]) | |
129 self.assertEqual(self.plugin.games[ROOM_JID]['players'], []) | |
130 self.plugin._updatePlayers(ROOM_JID, ["user1"], True, Const.PROFILE[0]) | |
131 self.assertEqual(self.plugin.games[ROOM_JID]['players'], ["user1"]) | |
132 self.plugin._updatePlayers(ROOM_JID, ["user2", "user3"], True, Const.PROFILE[0]) | |
133 self.assertEqual(self.plugin.games[ROOM_JID]['players'], ["user1", "user2", "user3"]) | |
134 self.plugin._updatePlayers(ROOM_JID, ["user2", "user3"], True, Const.PROFILE[0]) # should not be stored twice | |
135 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
|
136 |
828
8f335c03eebb
plugins room_games, radiocol, libervia: small changes like refactorization to ease the maintenance
souliane <souliane@mailoo.org>
parents:
811
diff
changeset
|
137 def test_synchronizeRoom(self): |
1271 | 138 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
139 self.initGame(0, 0) |
1412 | 140 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) |
141 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", [])) | |
142 self.plugin.games[ROOM_JID]['players'].append("test1") | |
143 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) | |
144 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", ["test1"])) | |
145 self.plugin.games[ROOM_JID]['started'] = True | |
146 self.plugin.games[ROOM_JID]['players'].append("test2") | |
147 self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0]) | |
148 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", ["test1", "test2"])) | |
149 self.plugin.games[ROOM_JID]['players'].append("test3") | |
150 self.plugin.games[ROOM_JID]['players'].append("test4") | |
151 user1 = JID(ROOM_JID.userhost() + "/" + Const.JID[0].user) | |
152 user2 = JID(ROOM_JID.userhost() + "/" + Const.JID[1].user) | |
153 self.plugin._synchronizeRoom(ROOM_JID, [user1, user2], Const.PROFILE[0]) | |
154 self.assertEqualXML(self.host.getSentMessageXml(0), self._expectedMessage(user1, "normal", "started", ["test1", "test2", "test3", "test4"])) | |
155 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
|
156 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
157 def test_invitePlayers(self): |
1271 | 158 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
159 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
160 self.plugin_0045.joinRoom(0, 1) |
1412 | 161 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
|
162 room = self.plugin_0045.getRoom(0, 0) |
1412 | 163 nicks = self.plugin._invitePlayers(room, [Const.JID[1], Const.JID[2]], Const.JID[0].user, Const.PROFILE[0]) |
164 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
|
165 # 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
|
166 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
|
167 |
1412 | 168 nicks = self.plugin._invitePlayers(room, [Const.JID[1], Const.JID[3]], Const.JID[0].user, Const.PROFILE[0]) |
169 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
|
170 # 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
|
171 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
|
172 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
173 def test_checkInviteAuth(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
174 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
175 def check(value, index): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
176 nick = self.plugin_0045.getNick(0, index) |
1412 | 177 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
|
178 |
1271 | 179 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
180 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
181 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
|
182 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
|
183 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
184 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
185 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
186 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
|
187 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
188 check(True, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
189 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
|
190 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
|
191 check(False, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
192 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
|
193 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
194 check(False, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
195 user_nick = self.plugin_0045.joinRoom(0, 1) |
1412 | 196 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
|
197 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
|
198 check(True, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
199 check(True, 1) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
200 check(False, 2) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
201 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
202 def test_isReferee(self): |
1271 | 203 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
204 self.initGame(0, 0) |
1412 | 205 self.assertTrue(self.plugin.isReferee(ROOM_JID, self.plugin_0045.getNick(0, 0))) |
206 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
|
207 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
208 def test_isPlayer(self): |
1271 | 209 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
210 self.initGame(0, 0) |
1412 | 211 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
|
212 user_nick = self.plugin_0045.joinRoom(0, 1) |
1412 | 213 self.plugin.games[ROOM_JID]['players'].append(user_nick) |
214 self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick)) | |
215 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
|
216 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
217 def test_checkWaitAuth(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
218 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
219 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
|
220 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
|
221 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
|
222 |
1271 | 223 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
224 self.initGame(0, 0) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
225 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
|
226 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
|
227 check(True, [], [], []) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 check(True, [], [], []) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
242 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
|
243 # 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
|
244 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
|
245 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
|
246 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
|
247 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
248 def test_prepareRoom_trivial(self): |
1271 | 249 self.reinit() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
250 other_players = [] |
1412 | 251 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) |
252 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) | |
253 self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[0], Const.JID[0].user)) | |
254 self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[0].user)) | |
255 self.assertEqual((True, [], []), self.plugin._checkWaitAuth(ROOM_JID, [])) | |
256 self.assertTrue(self.plugin.isReferee(ROOM_JID, Const.JID[0].user)) | |
257 self.assertTrue(self.plugin.isPlayer(ROOM_JID, Const.JID[0].user)) | |
258 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
|
259 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
260 def test_prepareRoom_invite(self): |
1271 | 261 self.reinit() |
1412 | 262 other_players = [Const.JID[1], Const.JID[2]] |
263 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
|
264 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
|
265 |
1412 | 266 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) |
267 self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[1], Const.JID[1].user)) | |
268 self.assertFalse(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[3], Const.JID[3].user)) | |
269 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
|
270 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
|
271 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
272 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
|
273 self.plugin.userJoinedTrigger(room, room.roster[player2_nick], PROFILE) |
1412 | 274 self.assertTrue(self.plugin.isPlayer(ROOM_JID, player2_nick)) |
275 self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID, player2_nick)) | |
276 self.assertFalse(self.plugin.isReferee(ROOM_JID, player2_nick)) | |
277 self.assertTrue(self.plugin.isPlayer(ROOM_JID, player2_nick)) | |
278 self.assertTrue(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNickOfUser(0, 2, 0))) | |
279 self.assertFalse(self.plugin.isPlayer(ROOM_JID, "xxx")) | |
280 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
|
281 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
282 def test_prepareRoom_score1(self): |
1271 | 283 self.reinit(player_init={'score': 0}) |
1412 | 284 other_players = [Const.JID[1], Const.JID[2]] |
285 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
|
286 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
|
287 |
1412 | 288 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) |
289 self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[1], Const.JID[1].user)) | |
290 self.assertFalse(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[3], Const.JID[3].user)) | |
291 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
|
292 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
|
293 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
294 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
|
295 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
1412 | 296 self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick)) |
297 self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, user_nick)) | |
298 self.assertFalse(self.plugin.isReferee(ROOM_JID, user_nick)) | |
299 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
|
300 # the following assertion is True because Const.JID[1] and Const.JID[2] have the same userhost |
1412 | 301 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
|
302 # the following assertion is True because Const.JID[1] nick in the room is equal to Const.JID[3].user |
1412 | 303 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
|
304 # 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
|
305 self.assertEqual(self.plugin_0045.getNickOfUser(0, 3, 0), None) |
1412 | 306 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
|
307 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
308 def test_prepareRoom_score2(self): |
1271 | 309 self.reinit(player_init={'score': 0}) |
1412 | 310 other_players = [Const.JID[1], Const.JID[4]] |
311 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
|
312 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
|
313 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
314 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
|
315 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
1412 | 316 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
|
317 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
|
318 self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE) |
1412 | 319 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
|
320 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
321 def test_userJoinedTrigger(self): |
1271 | 322 self.reinit(player_init={"xxx": "xyz"}) |
1412 | 323 other_players = [Const.JID[1], Const.JID[3]] |
324 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
|
325 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
|
326 |
1412 | 327 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", nicks)) |
328 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
|
329 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
330 # wrong profile |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
331 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
|
332 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
|
333 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), OTHER_PROFILE) |
1271 | 334 self.assertEqual(self.host.getSentMessage(0), None) # no new message has been sent |
1412 | 335 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
|
336 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
337 # 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
|
338 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
|
339 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
|
340 nicks.append(user_nick) |
1412 | 341 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", nicks)) |
342 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
|
343 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
344 # 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
|
345 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
|
346 self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[4]), PROFILE) |
1412 | 347 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(JID(ROOM_JID.userhost() + '/' + user_nick), "normal", "players", nicks)) |
348 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
|
349 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
350 # 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
|
351 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
|
352 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
|
353 nicks.append(user_nick) |
1412 | 354 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks)) |
355 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) # game started | |
356 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
|
357 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
358 # wait for none |
1271 | 359 self.reinit() |
1412 | 360 self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE) |
1271 | 361 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
|
362 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
|
363 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
|
364 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
|
365 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
|
366 nicks.append(user_nick) |
1412 | 367 self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks)) |
368 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
|
369 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
370 def test_userLeftTrigger(self): |
1271 | 371 self.reinit(player_init={"xxx": "xyz"}) |
1412 | 372 other_players = [Const.JID[1], Const.JID[3], Const.JID[4]] |
373 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
|
374 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
|
375 nicks = [self.plugin_0045.getNick(0, 0)] |
1412 | 376 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
|
377 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
378 # one user joins |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
379 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
|
380 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
|
381 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
382 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
383 # the user leaves |
1412 | 384 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
|
385 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
|
386 # 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
|
387 self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[1]), Const.PROFILE[1]) # not the referee |
1412 | 388 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
|
389 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
|
390 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
|
391 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
|
392 nicks.pop() |
1412 | 393 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
|
394 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
395 # all the users join |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
396 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
|
397 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
|
398 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
399 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
|
400 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
|
401 nicks.append(user_nick) |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
402 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
|
403 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
|
404 nicks.append(user_nick) |
1412 | 405 self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks) |
406 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
|
407 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
408 # one user leaves |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
409 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
|
410 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
|
411 nicks.pop() |
1412 | 412 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
|
413 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
414 # another leaves |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
415 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
|
416 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
|
417 nicks.pop() |
1412 | 418 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
|
419 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
420 # they can join again |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
421 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
|
422 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
|
423 nicks.append(user_nick) |
857
3c270d691e56
test: fix the tests for plugin room game
souliane <souliane@mailoo.org>
parents:
829
diff
changeset
|
424 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
|
425 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
|
426 nicks.append(user_nick) |
1412 | 427 self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks) |
428 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
|
429 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
430 def test__checkCreateGameAndInit(self): |
1271 | 431 self.reinit() |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
432 helpers.muteLogging() |
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
433 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) |
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
434 helpers.unmuteLogging() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
435 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
436 nick = self.plugin_0045.joinRoom(0, 0) |
1412 | 437 self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) |
438 self.assertTrue(self.plugin._gameExists(ROOM_JID, False)) | |
439 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) | |
440 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
|
441 |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
442 helpers.muteLogging() |
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
443 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE)) |
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
444 helpers.unmuteLogging() |
795
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
445 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
446 self.plugin_0045.joinRoom(0, 1) |
1412 | 447 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
|
448 |
1412 | 449 self.plugin.createGame(ROOM_JID, [Const.JID[1]], PROFILE) |
450 self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) | |
451 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
|
452 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
453 def test_createGame(self): |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
454 |
1271 | 455 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
|
456 nicks = [] |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
457 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
|
458 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
|
459 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
460 # game not exists |
1412 | 461 self.plugin.createGame(ROOM_JID, nicks, PROFILE) |
462 self.assertTrue(self.plugin._gameExists(ROOM_JID, True)) | |
463 self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks) | |
464 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
|
465 for nick in nicks: |
1412 | 466 self.assertEqual('init', self.plugin.games[ROOM_JID]['status'][nick]) |
467 self.assertEqual(self.plugin.player_init, self.plugin.games[ROOM_JID]['players_data'][nick]) | |
468 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
|
469 for nick in nicks: |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
470 # checks that a copy of self.player_init has been done and not a reference |
1412 | 471 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
|
472 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
473 # game exists, current profile is referee |
1271 | 474 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
|
475 self.initGame(0, 0) |
1412 | 476 self.plugin.games[ROOM_JID]['started'] = True |
477 self.plugin.createGame(ROOM_JID, nicks, PROFILE) | |
478 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
|
479 |
6625558371db
test: added tests for the plugin "room game" + rename other test files
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
480 # game exists, current profile is not referee |
1271 | 481 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
|
482 self.initGame(0, 0) |
1412 | 483 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
|
484 self.plugin_0045.joinRoom(0, 1) |
1412 | 485 self.plugin.createGame(ROOM_JID, nicks, OTHER_PROFILE) |
1271 | 486 self.assertEqual(self.host.getSentMessage(0), None) # no sync message has been sent by other_profile |