test: fix the tests for plugin room game
This commit is contained in:
parent
4bb50c59f7
commit
680dd48587
2 changed files with 13 additions and 8 deletions
|
|
@ -304,7 +304,7 @@ class RoomGame(object):
|
|||
nicks = []
|
||||
for player_jid in [player.userhostJID() for player in players_jids]:
|
||||
# TODO: find a way to make it secure
|
||||
other_nick = self.host.plugins["XEP-0045"].getRoomNickOfUser(room, player_jid, secure=False)
|
||||
other_nick = self.host.plugins["XEP-0045"].getRoomNickOfUser(room, player_jid, secure=self.testing)
|
||||
if other_nick is None:
|
||||
self.host.plugins["XEP-0249"].invite(player_jid, room_jid, {"game": self.name}, profile)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ class RoomGameTest(helpers.SatTestCase):
|
|||
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 @@ class RoomGameTest(helpers.SatTestCase):
|
|||
# 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 @@ class RoomGameTest(helpers.SatTestCase):
|
|||
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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue