comparison src/test/test_plugin_misc_room_game.py @ 1909:0681d69cbe0a

test: add helpers methods muteLogging and unmuteLogging
author souliane <souliane@mailoo.org>
date Fri, 11 Mar 2016 16:41:44 +0100
parents d17772b0fe22
children 2daf7b4c6756
comparison
equal deleted inserted replaced
1908:ffcd7904b655 1909:0681d69cbe0a
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20
21 """ Tests for the plugin room game (base class for MUC games) """ 21 """ Tests for the plugin room game (base class for MUC games) """
22 22
23 from sat.core.i18n import _ 23 from sat.core.i18n import _
24 from sat.core.log import getLogger
25 from constants import Const 24 from constants import Const
26 from sat.test import helpers, helpers_plugins 25 from sat.test import helpers, helpers_plugins
27 from sat.plugins import plugin_misc_room_game as plugin 26 from sat.plugins import plugin_misc_room_game as plugin
28 from twisted.words.protocols.jabber.jid import JID 27 from twisted.words.protocols.jabber.jid import JID
29 from wokkel.muc import User 28 from wokkel.muc import User
428 self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks) 427 self.assertEqual(self.plugin.games[ROOM_JID]['players'], nicks)
429 self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 0) 428 self.assertTrue(len(self.plugin.invitations[ROOM_JID]) == 0)
430 429
431 def test__checkCreateGameAndInit(self): 430 def test__checkCreateGameAndInit(self):
432 self.reinit() 431 self.reinit()
433 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) # print internal error 432 helpers.muteLogging()
433 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE))
434 helpers.unmuteLogging()
434 435
435 nick = self.plugin_0045.joinRoom(0, 0) 436 nick = self.plugin_0045.joinRoom(0, 0)
436 self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE)) 437 self.assertEqual((True, False), self.plugin._checkCreateGameAndInit(ROOM_JID, PROFILE))
437 self.assertTrue(self.plugin._gameExists(ROOM_JID, False)) 438 self.assertTrue(self.plugin._gameExists(ROOM_JID, False))
438 self.assertFalse(self.plugin._gameExists(ROOM_JID, True)) 439 self.assertFalse(self.plugin._gameExists(ROOM_JID, True))
439 self.assertTrue(self.plugin.isReferee(ROOM_JID, nick)) 440 self.assertTrue(self.plugin.isReferee(ROOM_JID, nick))
440 441
441 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE)) # print internal error 442 helpers.muteLogging()
443 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE))
444 helpers.unmuteLogging()
442 445
443 self.plugin_0045.joinRoom(0, 1) 446 self.plugin_0045.joinRoom(0, 1)
444 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE)) 447 self.assertEqual((False, False), self.plugin._checkCreateGameAndInit(ROOM_JID, OTHER_PROFILE))
445 448
446 self.plugin.createGame(ROOM_JID, [Const.JID[1]], PROFILE) 449 self.plugin.createGame(ROOM_JID, [Const.JID[1]], PROFILE)