diff src/test/test_plugin_misc_room_game.py @ 1412:979210da778a

test: fix the tests
author souliane <souliane@mailoo.org>
date Fri, 17 Apr 2015 19:06:39 +0200
parents 069ad98b360d
children d17772b0fe22
line wrap: on
line diff
--- a/src/test/test_plugin_misc_room_game.py	Fri Apr 17 19:05:37 2015 +0200
+++ b/src/test/test_plugin_misc_room_game.py	Fri Apr 17 19:06:39 2015 +0200
@@ -44,7 +44,7 @@
     "description": _("""Dummy plugin to test room game""")
 }
 
-ROOM_JID_S = Const.MUC_STR[0]
+ROOM_JID = JID(Const.MUC_STR[0])
 PROFILE = Const.PROFILE[0]
 OTHER_PROFILE = Const.PROFILE[1]
 
@@ -60,16 +60,12 @@
         self.plugin._init_(self.host, PLUGIN_INFO, (NAMESERVICE, TAG), game_init, player_init)
         self.plugin_0045 = self.host.plugins['XEP-0045'] = helpers_plugins.FakeXEP_0045(self.host)
         self.plugin_0249 = self.host.plugins['XEP-0249'] = helpers_plugins.FakeXEP_0249(self.host)
-        logger = getLogger()
-        level = logger.getEffectiveLevel()
-        logger.setLevel(WARNING)  # remove log.info pollution
         for profile in Const.PROFILE:
             self.host.getClient(profile)  # init self.host.profiles[profile]
-        logger.setLevel(level)
 
     def initGame(self, muc_index, user_index):
         self.plugin_0045.joinRoom(user_index, muc_index)
-        self.plugin._initGame(Const.MUC_STR[muc_index], Const.JID[user_index].user)
+        self.plugin._initGame(JID(Const.MUC_STR[muc_index]), Const.JID[user_index].user)
 
     def _expectedMessage(self, to, type_, tag, players=[]):
         content = "<%s" % tag
@@ -80,38 +76,38 @@
             for i in xrange(0, len(players)):
                 content += "<player index='%s'>%s</player>" % (i, players[i])
             content += "</%s>" % tag
-        return "<message to='%s' type='%s'><%s xmlns='%s'>%s</dummy></message>" % (to, type_, TAG, NAMESERVICE, content)
+        return "<message to='%s' type='%s'><%s xmlns='%s'>%s</dummy></message>" % (to.full(), type_, TAG, NAMESERVICE, content)
 
     def test_createOrInvite_solo(self):
         self.reinit()
         self.plugin_0045.joinRoom(0, 0)
         self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), [], Const.PROFILE[0])
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, True))
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, True))
 
     def test_createOrInvite_multi_not_waiting(self):
         self.reinit()
         self.plugin_0045.joinRoom(0, 0)
-        other_players = [Const.JID_STR[1], Const.JID_STR[2]]
+        other_players = [Const.JID[1], Const.JID[2]]
         self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), other_players, Const.PROFILE[0])
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, True))
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, True))
 
     def test_createOrInvite_multi_waiting(self):
         self.reinit(player_init={'score': 0})
         self.plugin_0045.joinRoom(0, 0)
-        other_players = [Const.JID_STR[1], Const.JID_STR[2]]
+        other_players = [Const.JID[1], Const.JID[2]]
         self.plugin._createOrInvite(self.plugin_0045.getRoom(0, 0), other_players, Const.PROFILE[0])
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, False))
-        self.assertFalse(self.plugin._gameExists(ROOM_JID_S, True))
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, False))
+        self.assertFalse(self.plugin._gameExists(ROOM_JID, True))
 
     def test_initGame(self):
         self.reinit()
         self.initGame(0, 0)
-        self.assertTrue(self.plugin.isReferee(ROOM_JID_S, Const.JID[0].user))
-        self.assertEqual([], self.plugin.games[ROOM_JID_S]['players'])
+        self.assertTrue(self.plugin.isReferee(ROOM_JID, Const.JID[0].user))
+        self.assertEqual([], self.plugin.games[ROOM_JID]['players'])
 
     def test_checkJoinAuth(self):
         self.reinit()
-        check = lambda value: getattr(self, "assert%s" % value)(self.plugin._checkJoinAuth(ROOM_JID_S, Const.JID_STR[0], Const.JID[0].user))
+        check = lambda value: getattr(self, "assert%s" % value)(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[0], Const.JID[0].user))
         check(False)
         # to test the "invited" mode, the referee must be different than the user to test
         self.initGame(0, 1)
@@ -119,59 +115,59 @@
         check(True)
         self.plugin.join_mode = self.plugin.INVITED
         check(False)
-        self.plugin.invitations[ROOM_JID_S] = [(None, [Const.JID[0].userhost()])]
+        self.plugin.invitations[ROOM_JID] = [(None, [Const.JID[0].userhostJID()])]
         check(True)
         self.plugin.join_mode = self.plugin.NONE
         check(False)
-        self.plugin.games[ROOM_JID_S]['players'].append(Const.JID[0].user)
+        self.plugin.games[ROOM_JID]['players'].append(Const.JID[0].user)
         check(True)
 
     def test_updatePlayers(self):
         self.reinit()
         self.initGame(0, 0)
-        self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], [])
-        self.plugin._updatePlayers(ROOM_JID_S, [], True, Const.PROFILE[0])
-        self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], [])
-        self.plugin._updatePlayers(ROOM_JID_S, ["user1"], True, Const.PROFILE[0])
-        self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1"])
-        self.plugin._updatePlayers(ROOM_JID_S, ["user2", "user3"], True, Const.PROFILE[0])
-        self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1", "user2", "user3"])
-        self.plugin._updatePlayers(ROOM_JID_S, ["user2", "user3"], True, Const.PROFILE[0])  # should not be stored twice
-        self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], ["user1", "user2", "user3"])
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], [])
+        self.plugin._updatePlayers(ROOM_JID, [], True, Const.PROFILE[0])
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], [])
+        self.plugin._updatePlayers(ROOM_JID, ["user1"], True, Const.PROFILE[0])
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], ["user1"])
+        self.plugin._updatePlayers(ROOM_JID, ["user2", "user3"], True, Const.PROFILE[0])
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], ["user1", "user2", "user3"])
+        self.plugin._updatePlayers(ROOM_JID, ["user2", "user3"], True, Const.PROFILE[0])  # should not be stored twice
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], ["user1", "user2", "user3"])
 
     def test_synchronizeRoom(self):
         self.reinit()
         self.initGame(0, 0)
-        self.plugin._synchronizeRoom(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0])
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "players", []))
-        self.plugin.games[ROOM_JID_S]['players'].append("test1")
-        self.plugin._synchronizeRoom(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0])
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "players", ["test1"]))
-        self.plugin.games[ROOM_JID_S]['started'] = True
-        self.plugin.games[ROOM_JID_S]['players'].append("test2")
-        self.plugin._synchronizeRoom(ROOM_JID_S, [Const.MUC[0]], Const.PROFILE[0])
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "started", ["test1", "test2"]))
-        self.plugin.games[ROOM_JID_S]['players'].append("test3")
-        self.plugin.games[ROOM_JID_S]['players'].append("test4")
-        user1 = JID(ROOM_JID_S + "/" + Const.JID[0].user)
-        user2 = JID(ROOM_JID_S + "/" + Const.JID[1].user)
-        self.plugin._synchronizeRoom(ROOM_JID_S, [user1, user2], Const.PROFILE[0])
-        self.assertEqualXML(self.host.getSentMessageXml(0), self._expectedMessage(user1.full(), "normal", "started", ["test1", "test2", "test3", "test4"]))
-        self.assertEqualXML(self.host.getSentMessageXml(0), self._expectedMessage(user2.full(), "normal", "started", ["test1", "test2", "test3", "test4"]))
+        self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0])
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", []))
+        self.plugin.games[ROOM_JID]['players'].append("test1")
+        self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0])
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", ["test1"]))
+        self.plugin.games[ROOM_JID]['started'] = True
+        self.plugin.games[ROOM_JID]['players'].append("test2")
+        self.plugin._synchronizeRoom(ROOM_JID, [Const.MUC[0]], Const.PROFILE[0])
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", ["test1", "test2"]))
+        self.plugin.games[ROOM_JID]['players'].append("test3")
+        self.plugin.games[ROOM_JID]['players'].append("test4")
+        user1 = JID(ROOM_JID.userhost() + "/" + Const.JID[0].user)
+        user2 = JID(ROOM_JID.userhost() + "/" + Const.JID[1].user)
+        self.plugin._synchronizeRoom(ROOM_JID, [user1, user2], Const.PROFILE[0])
+        self.assertEqualXML(self.host.getSentMessageXml(0), self._expectedMessage(user1, "normal", "started", ["test1", "test2", "test3", "test4"]))
+        self.assertEqualXML(self.host.getSentMessageXml(0), self._expectedMessage(user2, "normal", "started", ["test1", "test2", "test3", "test4"]))
 
     def test_invitePlayers(self):
         self.reinit()
         self.initGame(0, 0)
         self.plugin_0045.joinRoom(0, 1)
-        self.assertEqual(self.plugin.invitations[ROOM_JID_S], [])
+        self.assertEqual(self.plugin.invitations[ROOM_JID], [])
         room = self.plugin_0045.getRoom(0, 0)
-        nicks = self.plugin._invitePlayers(room, [Const.JID_STR[1], Const.JID_STR[2]], Const.JID[0].user, Const.PROFILE[0])
-        self.assertEqual(self.plugin.invitations[ROOM_JID_S][0][1], [Const.JID[1].userhost(), Const.JID[2].userhost()])
+        nicks = self.plugin._invitePlayers(room, [Const.JID[1], Const.JID[2]], Const.JID[0].user, Const.PROFILE[0])
+        self.assertEqual(self.plugin.invitations[ROOM_JID][0][1], [Const.JID[1].userhostJID(), Const.JID[2].userhostJID()])
         # the following assertion is True because Const.JID[1] and Const.JID[2] have the same userhost
         self.assertEqual(nicks, [Const.JID[1].user, Const.JID[2].user])
 
-        nicks = self.plugin._invitePlayers(room, [Const.JID_STR[1], Const.JID_STR[3]], Const.JID[0].user, Const.PROFILE[0])
-        self.assertEqual(self.plugin.invitations[ROOM_JID_S][1][1], [Const.JID[1].userhost(), Const.JID[3].userhost()])
+        nicks = self.plugin._invitePlayers(room, [Const.JID[1], Const.JID[3]], Const.JID[0].user, Const.PROFILE[0])
+        self.assertEqual(self.plugin.invitations[ROOM_JID][1][1], [Const.JID[1].userhostJID(), Const.JID[3].userhostJID()])
         # this time Const.JID[1] and Const.JID[3] have the same user but the host differs
         self.assertEqual(nicks, [Const.JID[1].user])
 
@@ -179,7 +175,7 @@
 
         def check(value, index):
             nick = self.plugin_0045.getNick(0, index)
-            getattr(self, "assert%s" % value)(self.plugin._checkInviteAuth(ROOM_JID_S, nick))
+            getattr(self, "assert%s" % value)(self.plugin._checkInviteAuth(ROOM_JID, nick))
 
         self.reinit()
 
@@ -198,7 +194,7 @@
         check(True, 0)
         check(False, 1)
         user_nick = self.plugin_0045.joinRoom(0, 1)
-        self.plugin.games[ROOM_JID_S]['players'].append(user_nick)
+        self.plugin.games[ROOM_JID]['players'].append(user_nick)
         self.plugin.invite_mode = self.plugin.FROM_PLAYERS
         check(True, 0)
         check(True, 1)
@@ -207,17 +203,17 @@
     def test_isReferee(self):
         self.reinit()
         self.initGame(0, 0)
-        self.assertTrue(self.plugin.isReferee(ROOM_JID_S, self.plugin_0045.getNick(0, 0)))
-        self.assertFalse(self.plugin.isReferee(ROOM_JID_S, self.plugin_0045.getNick(0, 1)))
+        self.assertTrue(self.plugin.isReferee(ROOM_JID, self.plugin_0045.getNick(0, 0)))
+        self.assertFalse(self.plugin.isReferee(ROOM_JID, self.plugin_0045.getNick(0, 1)))
 
     def test_isPlayer(self):
         self.reinit()
         self.initGame(0, 0)
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, self.plugin_0045.getNick(0, 0)))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNick(0, 0)))
         user_nick = self.plugin_0045.joinRoom(0, 1)
-        self.plugin.games[ROOM_JID_S]['players'].append(user_nick)
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, user_nick))
-        self.assertFalse(self.plugin.isPlayer(ROOM_JID_S, self.plugin_0045.getNick(0, 2)))
+        self.plugin.games[ROOM_JID]['players'].append(user_nick)
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick))
+        self.assertFalse(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNick(0, 2)))
 
     def test_checkWaitAuth(self):
 
@@ -253,132 +249,132 @@
     def test_prepareRoom_trivial(self):
         self.reinit()
         other_players = []
-        self.plugin.prepareRoom(other_players, ROOM_JID_S, PROFILE)
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, True))
-        self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID_S, Const.JID_STR[0], Const.JID[0].user))
-        self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID_S, Const.JID[0].user))
-        self.assertEqual((True, [], []), self.plugin._checkWaitAuth(ROOM_JID_S, []))
-        self.assertTrue(self.plugin.isReferee(ROOM_JID_S, Const.JID[0].user))
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, Const.JID[0].user))
-        self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID_S, PROFILE))
+        self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE)
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, True))
+        self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[0], Const.JID[0].user))
+        self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[0].user))
+        self.assertEqual((True, [], []), self.plugin._checkWaitAuth(ROOM_JID, []))
+        self.assertTrue(self.plugin.isReferee(ROOM_JID, Const.JID[0].user))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, Const.JID[0].user))
+        self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE))
 
     def test_prepareRoom_invite(self):
         self.reinit()
-        other_players = [Const.JID_STR[1], Const.JID_STR[2]]
-        self.plugin.prepareRoom(other_players, ROOM_JID_S, PROFILE)
+        other_players = [Const.JID[1], Const.JID[2]]
+        self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE)
         room = self.plugin_0045.getRoom(0, 0)
 
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, True))
-        self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID_S, Const.JID_STR[1], Const.JID[1].user))
-        self.assertFalse(self.plugin._checkJoinAuth(ROOM_JID_S, Const.JID_STR[3], Const.JID[3].user))
-        self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID_S, Const.JID[1].user))
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, True))
+        self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[1], Const.JID[1].user))
+        self.assertFalse(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[3], Const.JID[3].user))
+        self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[1].user))
         self.assertEqual((True, [], other_players), self.plugin._checkWaitAuth(room, other_players))
 
         player2_nick = self.plugin_0045.joinRoom(0, 1)
         self.plugin.userJoinedTrigger(room, room.roster[player2_nick], PROFILE)
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, player2_nick))
-        self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID_S, player2_nick))
-        self.assertFalse(self.plugin.isReferee(ROOM_JID_S, player2_nick))
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, player2_nick))
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, self.plugin_0045.getNickOfUser(0, 2, 0)))
-        self.assertFalse(self.plugin.isPlayer(ROOM_JID_S, Const.JID_STR[3]))
-        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID_S, Const.PROFILE[1]))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, player2_nick))
+        self.assertTrue(self.plugin._checkInviteAuth(ROOM_JID, player2_nick))
+        self.assertFalse(self.plugin.isReferee(ROOM_JID, player2_nick))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, player2_nick))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNickOfUser(0, 2, 0)))
+        self.assertFalse(self.plugin.isPlayer(ROOM_JID, "xxx"))
+        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, Const.PROFILE[1]))
 
     def test_prepareRoom_score1(self):
         self.reinit(player_init={'score': 0})
-        other_players = [Const.JID_STR[1], Const.JID_STR[2]]
-        self.plugin.prepareRoom(other_players, ROOM_JID_S, PROFILE)
+        other_players = [Const.JID[1], Const.JID[2]]
+        self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE)
         room = self.plugin_0045.getRoom(0, 0)
 
-        self.assertFalse(self.plugin._gameExists(ROOM_JID_S, True))
-        self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID_S, Const.JID_STR[1], Const.JID[1].user))
-        self.assertFalse(self.plugin._checkJoinAuth(ROOM_JID_S, Const.JID_STR[3], Const.JID[3].user))
-        self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID_S, Const.JID[1].user))
+        self.assertFalse(self.plugin._gameExists(ROOM_JID, True))
+        self.assertTrue(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[1], Const.JID[1].user))
+        self.assertFalse(self.plugin._checkJoinAuth(ROOM_JID, Const.JID[3], Const.JID[3].user))
+        self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, Const.JID[1].user))
         self.assertEqual((False, [], other_players), self.plugin._checkWaitAuth(room, other_players))
 
         user_nick = self.plugin_0045.joinRoom(0, 1)
         self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE)
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, user_nick))
-        self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID_S, user_nick))
-        self.assertFalse(self.plugin.isReferee(ROOM_JID_S, user_nick))
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, user_nick))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick))
+        self.assertFalse(self.plugin._checkInviteAuth(ROOM_JID, user_nick))
+        self.assertFalse(self.plugin.isReferee(ROOM_JID, user_nick))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, user_nick))
         # the following assertion is True because Const.JID[1] and Const.JID[2] have the same userhost
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, self.plugin_0045.getNickOfUser(0, 2, 0)))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, self.plugin_0045.getNickOfUser(0, 2, 0)))
         # the following assertion is True because Const.JID[1] nick in the room is equal to Const.JID[3].user
-        self.assertTrue(self.plugin.isPlayer(ROOM_JID_S, Const.JID[3].user))
+        self.assertTrue(self.plugin.isPlayer(ROOM_JID, Const.JID[3].user))
         # but Const.JID[3] is actually not in the room
         self.assertEqual(self.plugin_0045.getNickOfUser(0, 3, 0), None)
-        self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID_S, Const.PROFILE[0]))
+        self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, Const.PROFILE[0]))
 
     def test_prepareRoom_score2(self):
         self.reinit(player_init={'score': 0})
-        other_players = [Const.JID_STR[1], Const.JID_STR[4]]
-        self.plugin.prepareRoom(other_players, ROOM_JID_S, PROFILE)
+        other_players = [Const.JID[1], Const.JID[4]]
+        self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE)
         room = self.plugin_0045.getRoom(0, 0)
 
         user_nick = self.plugin_0045.joinRoom(0, 1)
         self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE)
-        self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID_S, PROFILE))
+        self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE))
         user_nick = self.plugin_0045.joinRoom(0, 4)
         self.plugin.userJoinedTrigger(room, room.roster[user_nick], PROFILE)
-        self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID_S, PROFILE))
+        self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE))
 
     def test_userJoinedTrigger(self):
         self.reinit(player_init={"xxx": "xyz"})
-        other_players = [Const.JID_STR[1], Const.JID_STR[3]]
-        self.plugin.prepareRoom(other_players, ROOM_JID_S, PROFILE)
+        other_players = [Const.JID[1], Const.JID[3]]
+        self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE)
         nicks = [self.plugin_0045.getNick(0, 0)]
 
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "players", nicks))
-        self.assertTrue(len(self.plugin.invitations[ROOM_JID_S]) == 1)
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", nicks))
+        self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 1)
 
         # wrong profile
         user_nick = self.plugin_0045.joinRoom(0, 1)
         room = self.plugin_0045.getRoom(0, 1)
         self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), OTHER_PROFILE)
         self.assertEqual(self.host.getSentMessage(0), None)  # no new message has been sent
-        self.assertFalse(self.plugin._gameExists(ROOM_JID_S, True))  # game not started
+        self.assertFalse(self.plugin._gameExists(ROOM_JID, True))  # game not started
 
         # referee profile, user is allowed, wait for one more
         room = self.plugin_0045.getRoom(0, 0)
         self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[1]), PROFILE)
         nicks.append(user_nick)
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "players", nicks))
-        self.assertFalse(self.plugin._gameExists(ROOM_JID_S, True))  # game not started
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "players", nicks))
+        self.assertFalse(self.plugin._gameExists(ROOM_JID, True))  # game not started
 
         # referee profile, user is not allowed
         user_nick = self.plugin_0045.joinRoom(0, 4)
         self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[4]), PROFILE)
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S + '/' + user_nick, "normal", "players", nicks))
-        self.assertFalse(self.plugin._gameExists(ROOM_JID_S, True))  # game not started
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(JID(ROOM_JID.userhost() + '/' + user_nick), "normal", "players", nicks))
+        self.assertFalse(self.plugin._gameExists(ROOM_JID, True))  # game not started
 
         # referee profile, user is allowed, everybody here
         user_nick = self.plugin_0045.joinRoom(0, 3)
         self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[3]), PROFILE)
         nicks.append(user_nick)
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "started", nicks))
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, True))  # game started
-        self.assertTrue(len(self.plugin.invitations[ROOM_JID_S]) == 0)
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks))
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, True))  # game started
+        self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 0)
 
         # wait for none
         self.reinit()
-        self.plugin.prepareRoom(other_players, ROOM_JID_S, PROFILE)
+        self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE)
         self.assertNotEqual(self.host.getSentMessage(0), None)  # init messages
         room = self.plugin_0045.getRoom(0, 0)
         nicks = [self.plugin_0045.getNick(0, 0)]
         user_nick = self.plugin_0045.joinRoom(0, 3)
         self.plugin.userJoinedTrigger(room, User(user_nick, Const.JID[3]), PROFILE)
         nicks.append(user_nick)
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "started", nicks))
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, True))
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks))
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, True))
 
     def test_userLeftTrigger(self):
         self.reinit(player_init={"xxx": "xyz"})
-        other_players = [Const.JID_STR[1], Const.JID_STR[3], Const.JID_STR[4]]
-        self.plugin.prepareRoom(other_players, ROOM_JID_S, PROFILE)
+        other_players = [Const.JID[1], Const.JID[3], Const.JID[4]]
+        self.plugin.prepareRoom(other_players, ROOM_JID, PROFILE)
         room = self.plugin_0045.getRoom(0, 0)
         nicks = [self.plugin_0045.getNick(0, 0)]
-        self.assertEqual(self.plugin.invitations[ROOM_JID_S][0][1], [Const.JID[1].userhost(), Const.JID[3].userhost(), Const.JID[4].userhost()])
+        self.assertEqual(self.plugin.invitations[ROOM_JID][0][1], [Const.JID[1].userhostJID(), Const.JID[3].userhostJID(), Const.JID[4].userhostJID()])
 
         # one user joins
         user_nick = self.plugin_0045.joinRoom(0, 1)
@@ -386,16 +382,16 @@
         nicks.append(user_nick)
 
         # the user leaves
-        self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], nicks)
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks)
         room = self.plugin_0045.getRoom(0, 1)
         # 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)
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks)
         room = self.plugin_0045.getRoom(0, 0)
         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)
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks)
 
         # all the users join
         user_nick = self.plugin_0045.joinRoom(0, 1)
@@ -407,20 +403,20 @@
         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)
-        self.assertTrue(len(self.plugin.invitations[ROOM_JID_S]) == 0)
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks)
+        self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 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.assertEqual(self.plugin.invitations[ROOM_JID_S][0][1], [Const.JID[4].userhost()])
+        self.assertEqual(self.plugin.invitations[ROOM_JID][0][1], [Const.JID[4].userhostJID()])
 
         # another leaves
         user_nick = self.plugin_0045.leaveRoom(0, 3)
         self.plugin.userLeftTrigger(room, User(user_nick, Const.JID[3]), PROFILE)
         nicks.pop()
-        self.assertEqual(self.plugin.invitations[ROOM_JID_S][0][1], [Const.JID[4].userhost(), Const.JID[3].userhost()])
+        self.assertEqual(self.plugin.invitations[ROOM_JID][0][1], [Const.JID[4].userhostJID(), Const.JID[3].userhostJID()])
 
         # they can join again
         user_nick = self.plugin_0045.joinRoom(0, 3)
@@ -429,27 +425,27 @@
         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)
-        self.assertTrue(len(self.plugin.invitations[ROOM_JID_S]) == 0)
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks)
+        self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 0)
 
     def test__checkCreateGameAndInit(self):
         self.reinit()
-        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID_S, PROFILE))  # print internal error
+        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE))  # print internal error
 
         nick = self.plugin_0045.joinRoom(0, 0)
-        self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID_S, PROFILE))
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, False))
-        self.assertFalse(self.plugin._gameExists(ROOM_JID_S, True))
-        self.assertTrue(self.plugin.isReferee(ROOM_JID_S, nick))
+        self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE))
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, False))
+        self.assertFalse(self.plugin._gameExists(ROOM_JID, True))
+        self.assertTrue(self.plugin.isReferee(ROOM_JID, nick))
 
-        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID_S, OTHER_PROFILE))  # print internal error
+        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE))  # print internal error
 
         self.plugin_0045.joinRoom(0, 1)
-        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID_S, OTHER_PROFILE))
+        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE))
 
-        self.plugin.createGame(ROOM_JID_S, [Const.JID_STR[1]], PROFILE)
-        self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID_S, PROFILE))
-        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID_S, OTHER_PROFILE))
+        self.plugin.createGame(ROOM_JID, [Const.JID[1]], PROFILE)
+        self.assertEqual((False, True), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE))
+        self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE))
 
     def test_createGame(self):
 
@@ -459,29 +455,29 @@
             nicks.append(self.plugin_0045.joinRoom(0, i))
 
         # game not exists
-        self.plugin.createGame(ROOM_JID_S, nicks, PROFILE)
-        self.assertTrue(self.plugin._gameExists(ROOM_JID_S, True))
-        self.assertEqual(self.plugin.games[ROOM_JID_S]['players'], nicks)
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "started", nicks))
+        self.plugin.createGame(ROOM_JID, nicks, PROFILE)
+        self.assertTrue(self.plugin._gameExists(ROOM_JID, True))
+        self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks)
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks))
         for nick in nicks:
-            self.assertEqual('init', self.plugin.games[ROOM_JID_S]['status'][nick])
-            self.assertEqual(self.plugin.player_init, self.plugin.games[ROOM_JID_S]['players_data'][nick])
-            self.plugin.games[ROOM_JID_S]['players_data'][nick]["xxx"] = nick
+            self.assertEqual('init', self.plugin.games[ROOM_JID]['status'][nick])
+            self.assertEqual(self.plugin.player_init, self.plugin.games[ROOM_JID]['players_data'][nick])
+            self.plugin.games[ROOM_JID]['players_data'][nick]["xxx"] = nick
         for nick in nicks:
             # checks that a copy of self.player_init has been done and not a reference
-            self.assertEqual(nick, self.plugin.games[ROOM_JID_S]['players_data'][nick]['xxx'])
+            self.assertEqual(nick, self.plugin.games[ROOM_JID]['players_data'][nick]['xxx'])
 
         # game exists, current profile is referee
         self.reinit(player_init={"xxx": "xyz"})
         self.initGame(0, 0)
-        self.plugin.games[ROOM_JID_S]['started'] = True
-        self.plugin.createGame(ROOM_JID_S, nicks, PROFILE)
-        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID_S, "groupchat", "started", nicks))
+        self.plugin.games[ROOM_JID]['started'] = True
+        self.plugin.createGame(ROOM_JID, nicks, PROFILE)
+        self.assertEqual(self.host.getSentMessageXml(0), self._expectedMessage(ROOM_JID, "groupchat", "started", nicks))
 
         # game exists, current profile is not referee
         self.reinit(player_init={"xxx": "xyz"})
         self.initGame(0, 0)
-        self.plugin.games[ROOM_JID_S]['started'] = True
+        self.plugin.games[ROOM_JID]['started'] = True
         self.plugin_0045.joinRoom(0, 1)
-        self.plugin.createGame(ROOM_JID_S, nicks, OTHER_PROFILE)
+        self.plugin.createGame(ROOM_JID, nicks, OTHER_PROFILE)
         self.assertEqual(self.host.getSentMessage(0), None)  # no sync message has been sent by other_profile