def test_current_player_name(self): instance = BaseInstance() game = BaseGame(instance, default_user, default_players, args) player = BasePlayer(default_user) with self.assertRaises(GameInvalidOperation) as e: game.current_player_name() game.add_player(player, args.password) self.assertEqual(default_user, game.current_player_name())
def test_find_player_by_name(self): instance = BaseInstance() game = BaseGame(instance, default_user, default_players, args) player = BasePlayer(default_user) game.add_player(player, args.password) with self.assertRaises(GameInvalidOperation) as e: game.find_player_by_name('not found') p = game.find_player_by_name(default_user) self.assertEqual(p, player)
def test_my_turn(self): """ This tests both 'my_turn' and 'advance_to_next_players """ instance = BaseInstance() game = BaseGame(instance, default_user, default_players, args) me = BasePlayer(default_user) other = BasePlayer('other player') game.add_player(me, args.password) self.assertTrue(game.my_turn(me.name)) self.assertFalse(game.my_turn(other.name)) game.add_player(other, args.password) game.advance_to_next_player() self.assertTrue(game.my_turn(other.name)) self.assertFalse(game.my_turn(me.name))
def test_add_player(self): instance = BaseInstance() game = BaseGame(instance, default_user, default_players, args) player = BasePlayer(default_user) other_player = BasePlayer('some guy') game.add_player(player, args.password) with self.assertRaises(GamePermissionError) as exception: game.add_player(other_player, 'bad password') with self.assertRaises(GameInvalidOperation) as exception: game.add_player(player, args.password) with self.assertRaises(RuntimeError) as exception: game.add_player('x', args.password)