Esempio n. 1
0
def test_game_add_play():
    """"""
    game = Game()

    for idx, play in enumerate(['a', 'b', 'c'], 1):
        game.add_play(play)
        assert len(game.play_by_play) == idx
Esempio n. 2
0
def test_add_player():
    """Test adding player to game."""
    game = Game()
    players = ['Alice', 'Bob', 'Charlie', 'Dianne', 'Erszebet']

    for idx, p in enumerate(players, 1):
        game.add_player(p)
        game_players = game.get_players()
        assert p in game_players
        assert len(game_players) == idx
Esempio n. 3
0
def test_game_get_plays_exceed_range():
    """Test get_plays with index out of range."""
    game = Game()
    plays = ['a', 'b', 'c']

    for idx, play in enumerate(plays, 1):
        game.add_play(play)

    next_idx, game_plays = game.get_plays(len(plays) + 1)
    assert next_idx == len(plays)
    assert game_plays == []
Esempio n. 4
0
def test_game_get_plays_all():
    """Test getting all of the play-by-play."""
    game = Game()
    plays = ['a', 'b', 'c']

    for idx, play in enumerate(plays, 1):
        game.add_play(play)
        next_idx, game_plays = game.get_plays(0)
        assert len(game_plays) == idx
        assert idx == next_idx
        assert game_plays == plays[:idx]
Esempio n. 5
0
def test_game_get_plays_some():
    """Test getting some of the play-by-play."""
    game = Game()
    plays = ['a', 'b', 'c']

    for idx, play in enumerate(plays, 1):
        game.add_play(play)

    for idx in range(len(plays)):
        next_idx, game_plays = game.get_plays(idx)
        assert next_idx == len(plays)
        assert len(game_plays) == len(plays) - idx
        assert game_plays == plays[idx:]
Esempio n. 6
0
def new_game(game_id):
    """Create a new game page."""
    free_spaces = False
    if request.form['free'] == "true":
        free_spaces = True
    app.games[game_id] = Game(app.buzzwords, free_spaces)
    return f'new game: {game_id}'
Esempio n. 7
0
def test_game_construction():
    """"""
    game = Game()

    assert game.play_by_play == []