Mercurial > libervia-backend
diff src/test/test_plugin_misc_room_game.py @ 857:3c270d691e56
test: fix the tests for plugin room game
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 20 Feb 2014 17:51:51 +0100 |
parents | 187d2443c82d |
children | 301b342c697a |
line wrap: on
line diff
--- a/src/test/test_plugin_misc_room_game.py Thu Feb 20 16:37:05 2014 +0100 +++ b/src/test/test_plugin_misc_room_game.py Thu Feb 20 17:51:51 2014 +0100 @@ -377,7 +377,7 @@ self.plugin.prepareRoom(other_players, ROOM_JID_S, PROFILE) room = self.plugin_0045.getRoom(0, 0) nicks = [self.plugin_0045.getNick(0, 0)] - self.assertTrue(self.plugin.invitations[ROOM_JID_S][0], [Const.JID[1].userhost(), Const.JID[3].userhost(), Const.JID[4].userhost()]) + self.assertEqual(self.plugin.invitations[ROOM_JID_S][0][1], [Const.JID[1].userhost(), Const.JID[3].userhost(), Const.JID[4].userhost()]) # one user joins user_nick = self.plugin_0045.joinRoom(0, 1) @@ -387,14 +387,17 @@ # the user leaves self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], nicks) room = self.plugin_0045.getRoom(0, 1) - self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[1]), Const.PROFILE[1]) # wrong profile + # to not call self.plugin_0045.leaveRoom(0, 1) here, we are testing the trigger with a wrong profile + self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[1]), Const.PROFILE[1]) # not the referee self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], nicks) room = self.plugin_0045.getRoom(0, 0) - self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[1]), PROFILE) # referee profile + user_nick = self.plugin_0045.leaveRoom(0, 1) + self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[1]), PROFILE) # referee nicks.pop() self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], nicks) # all the users join + user_nick = self.plugin_0045.joinRoom(0, 1) self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), PROFILE) nicks.append(user_nick) user_nick = self.plugin_0045.joinRoom(0, 3) @@ -407,20 +410,22 @@ self.assertTrue(len(self.plugin.invitations[ROOM_JID_S]) == 0) # one user leaves + user_nick = self.plugin_0045.leaveRoom(0, 4) self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[4]), PROFILE) nicks.pop() - self.assertTrue(self.plugin.invitations[ROOM_JID_S][0], [Const.JID[4].userhost()]) + self.assertEqual(self.plugin.invitations[ROOM_JID_S][0][1], [Const.JID[4].userhost()]) # another leaves + user_nick = self.plugin_0045.leaveRoom(0, 3) self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[3]), PROFILE) nicks.pop() - self.assertTrue(self.plugin.invitations[ROOM_JID_S][0], [Const.JID[4].userhost(), Const.JID[3].userhost()]) + self.assertEqual(self.plugin.invitations[ROOM_JID_S][0][1], [Const.JID[4].userhost(), Const.JID[3].userhost()]) # they can join again - user_nick = self.plugin_0045.getNickOfUser(0, 3, 0) + user_nick = self.plugin_0045.joinRoom(0, 3) self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[3]), PROFILE) nicks.append(user_nick) - user_nick = self.plugin_0045.getNickOfUser(0, 4, 0) + user_nick = self.plugin_0045.joinRoom(0, 4) self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[4]), PROFILE) nicks.append(user_nick) self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], nicks)