Example #1
0
def test_game_one_or_ten_players():
    # 1 player: error
    player1 = Player("player1")
    with pytest.raises(UnoRuleException):
        game = Game()
        game.players.append(player1)
        game.start()

    # 11 players: error
    players = [Player(f"player{i}") for i in range(11)]
    with pytest.raises(UnoRuleException):
        game = Game()
        game.players = [player for player in players]
        game.start()
Example #2
0
def test_game_initial():
    player1 = Player("player1")
    player2 = Player("player2")

    # start game
    global game
    game = Game()
    game.players.append(player2)
    game.players.append(player1)
    game.start()

    # if game.id is not a UUID, will throw exception
    assert isinstance(UUID(game.id), UUID)

    assert len(game.deck.cards) == int(DECK_SIZE - (2 * STARTING_CARDS))

    for player in game.players:
        assert len(player.cards) == STARTING_CARDS