def test_toss(self): game = Game() ws = web.WebSocketResponse() game.add_player(Player(id=str(uuid.uuid4()), ws=ws)) game.add_player(Player(id=str(uuid.uuid4()), ws=ws)) game.toss() for player in game.players: self.assertNotEqual(player.box_type, BoxType.empty) self.assertIn(game.whose_turn, game.players) self.assertEqual(game.status, GameStatus.in_progress)
def test_turn(self): game = Game() ws = web.WebSocketResponse() game.add_player(Player(id=str(uuid.uuid4()), ws=ws)) game.add_player(Player(id=str(uuid.uuid4()), ws=ws)) game.toss() player = [p for p in game.players if p.id != game.whose_turn.id][0] with self.assertRaises(NotYourTurnError): game.turn(player, 0) player = game.whose_turn game.turn(player, 0) self.assertTrue(game.whose_turn.id != player.id) self.assertEqual(game.grid[0], player.box_type)