Exemplo n.º 1
0
    def test_move_returns_False_if_move_string_is_not_a_move(self):
        game = Game()
        game.reset()

        assert not game.move("invalid move")
        assert not game.move("5.5-4.4")
        assert not game.move("18 14")
        assert not game.move("18_14")
Exemplo n.º 2
0
    def test_valid_moves_do_not_include_backwards_moves(self):
        game = Game()
        game.reset()

        game.move("26-23")
        game.move("7-11")

        assert "23-26" not in game.valid_moves("white")
        assert "11-7" not in game.valid_moves("black")
Exemplo n.º 3
0
    def test_that_move_returns_True_if_move_made(self):
        game = Game(None, None)
        game._board.reset()

        move_made = game.move("25-22")
        assert move_made

        move_made = game.move("11-1")
        assert not move_made
Exemplo n.º 4
0
    def test_that_move_returns_True_if_move_made(self):
        game = Game()
        game._board.reset()

        move_made = game.move("25-22")
        assert move_made
        assert game.turn == "black"

        move_made = game.move("11-1")
        assert not move_made
        assert game.turn == "black"
Exemplo n.º 5
0
    def test_that_move_removes_piece_if_white_takes_black(self):
        game = Game()
        game.reset()

        game.move("25-22")
        game.move("5-9")
        game.move("22-18")
        game.move("9-14")

        # White takes black in this move
        game.move("18-9")

        assert game.turn == "white"
        assert game._pieces_remaining["black"] == 7
Exemplo n.º 6
0
    def test_that_cant_move_if_game_is_over(self):
        game = Game()
        game._board = mock.Mock(autospec=Board)

        for _ in range(8):
            game._remove_piece()

        move_made = game.move("25-22")
        assert not move_made

        # Confirm that move wasn't validated (because the game was over anyway)
        assert game._board.validate_move.call_count == 0
Exemplo n.º 7
0
    def test_that_move_removes_piece_if_black_takes_white(self):
        game = Game()
        game.reset()

        game.move("25-22")
        game.move("5-9")
        game.move("22-18")
        game.move("9-14")
        game.move("29-25")

        # Black takes white in this move
        game.move("14-23")

        assert game.turn == "black"
        assert game._pieces_remaining["white"] == 7