示例#1
0
def test_reset() -> None:
    # arrange
    tetris: TetrisBase = TetrisBase(seed=0)
    tetris.glob_info['Score'] = 128
    tetris.glob_info['Lines'] = 6

    board = Board(seed=0)
    board.get_board = MagicMock()
    board.get_board.return_value = "TEST"
    tetris.board = board

    # act
    result = tetris.reset()

    # assert
    assert result == "TEST"
    assert tetris.glob_info['Score'] == 0
    assert tetris.glob_info['Lines'] == 0
示例#2
0
def test_render() -> None:
    # arrange
    tetris: TetrisBase = TetrisBase(seed=0)

    board = Board(seed=0)
    board.get_board = MagicMock()
    board.get_board.return_value = "TEST"
    tetris.board = board

    gui = Gui(20, 10)
    gui.render = MagicMock()

    tetris.gui = gui

    # act
    tetris.render()

    # assert
    gui.render.assert_called_once()
示例#3
0
def test_step_get_info() -> None:
    # arrange
    tetris: TetrisBase = TetrisBase(seed=0)
    board = Board(seed=0)
    board.get_board = MagicMock()
    board.move_down = MagicMock()

    board.get_board.return_value = "TEST"
    board.move_down.return_value = {"lines": 1, "reward": 50, "done": True}

    tetris.board = board

    # act
    result = tetris.step(constants.DOWN)

    # assert
    assert result == ("TEST", 50, True, {
        'Score': 50,
        'Lines': 1,
        'Next': 0,
        'NewLine': True
    })