comparison src/test/test_plugin_misc_room_game.py @ 828:8f335c03eebb

plugins room_games, radiocol, libervia: small changes like refactorization to ease the maintenance
author souliane <souliane@mailoo.org>
date Fri, 17 Jan 2014 15:02:46 +0100
parents 1fe00f0c9a91
children 187d2443c82d
comparison
equal deleted inserted replaced
827:215a2cb15e2d 828:8f335c03eebb
127 127
128 def test_updatePlayers(self): 128 def test_updatePlayers(self):
129 self.init() 129 self.init()
130 self.initGame(0, 0) 130 self.initGame(0, 0)
131 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], []) 131 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], [])
132 self.plugin._updatePlayers(ROOM_JID_S, [], Const.PROFILE[0]) 132 self.plugin._updatePlayers(ROOM_JID_S, [], True, Const.PROFILE[0])
133 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], []) 133 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], [])
134 self.plugin._updatePlayers(ROOM_JID_S, ["user1"], Const.PROFILE[0]) 134 self.plugin._updatePlayers(ROOM_JID_S, ["user1"], True, Const.PROFILE[0])
135 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1"]) 135 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1"])
136 self.plugin._updatePlayers(ROOM_JID_S, ["user2", "user3"], Const.PROFILE[0]) 136 self.plugin._updatePlayers(ROOM_JID_S, ["user2", "user3"], True, Const.PROFILE[0])
137 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1", "user2", "user3"]) 137 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1", "user2", "user3"])
138 self.plugin._updatePlayers(ROOM_JID_S, ["user2", "user3"], Const.PROFILE[0]) # should not be stored twice 138 self.plugin._updatePlayers(ROOM_JID_S, ["user2", "user3"], True, Const.PROFILE[0]) # should not be stored twice
139 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1", "user2", "user3"]) 139 self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1", "user2", "user3"])
140 140
141 def test_signalPlayers(self): 141 def test_synchronizeRoom(self):
142 self.init() 142 self.init()
143 self.initGame(0, 0) 143 self.initGame(0, 0)
144 self.plugin._signalPlayers(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0]) 144 self.plugin._synchronizeRoom(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0])
145 self.assertEqual(self.host.getSentMessage(0, 0), self.expectedMessage(ROOM_JID_S, "groupchat", "players", [])) 145 self.assertEqual(self.host.getSentMessage(0, 0), self.expectedMessage(ROOM_JID_S, "groupchat", "players", []))
146 self.plugin.games[ROOM_JID_S]['players'].append("test1") 146 self.plugin.games[ROOM_JID_S]['players'].append("test1")
147 self.plugin._signalPlayers(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0]) 147 self.plugin._synchronizeRoom(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0])
148 self.assertEqual(self.host.getSentMessage(1, 0), self.expectedMessage(ROOM_JID_S, "groupchat", "players", ["test1"])) 148 self.assertEqual(self.host.getSentMessage(1, 0), self.expectedMessage(ROOM_JID_S, "groupchat", "players", ["test1"]))
149 self.plugin.games[ROOM_JID_S]['started'] = True 149 self.plugin.games[ROOM_JID_S]['started'] = True
150 self.plugin.games[ROOM_JID_S]['players'].append("test2") 150 self.plugin.games[ROOM_JID_S]['players'].append("test2")
151 self.plugin._signalPlayers(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0]) 151 self.plugin._synchronizeRoom(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0])
152 self.assertEqual(self.host.getSentMessage(2, 0), self.expectedMessage(ROOM_JID_S, "groupchat", "started", ["test1", "test2"])) 152 self.assertEqual(self.host.getSentMessage(2, 0), self.expectedMessage(ROOM_JID_S, "groupchat", "started", ["test1", "test2"]))
153 self.plugin.games[ROOM_JID_S]['players'].append("test3") 153 self.plugin.games[ROOM_JID_S]['players'].append("test3")
154 self.plugin.games[ROOM_JID_S]['players'].append("test4") 154 self.plugin.games[ROOM_JID_S]['players'].append("test4")
155 user1 = JID(ROOM_JID_S + "/" + Const.JID[0].user) 155 user1 = JID(ROOM_JID_S + "/" + Const.JID[0].user)
156 user2 = JID(ROOM_JID_S + "/" + Const.JID[1].user) 156 user2 = JID(ROOM_JID_S + "/" + Const.JID[1].user)
157 self.plugin._signalPlayers(ROOM_JID_S, [user1, user2], Const.PROFILE[0]) 157 self.plugin._synchronizeRoom(ROOM_JID_S, [user1, user2], Const.PROFILE[0])
158 self.assertEqualXML(self.host.getSentMessage(3, 0), self.expectedMessage(user1.full(), "normal", "started", ["test1", "test2", "test3", "test4"])) 158 self.assertEqualXML(self.host.getSentMessage(3, 0), self.expectedMessage(user1.full(), "normal", "started", ["test1", "test2", "test3", "test4"]))
159 self.assertEqualXML(self.host.getSentMessage(4, 0), self.expectedMessage(user2.full(), "normal", "started", ["test1", "test2", "test3", "test4"])) 159 self.assertEqualXML(self.host.getSentMessage(4, 0), self.expectedMessage(user2.full(), "normal", "started", ["test1", "test2", "test3", "test4"]))
160 160
161 def test_invitePlayers(self): 161 def test_invitePlayers(self):
162 self.init() 162 self.init()