Esempio n. 1
0
    def test_game_is_over_if_no_pieces_remaining(self):
        game = Game(None, None)
        assert not game.game_over()

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

        assert game.game_over()
Esempio n. 2
0
    def test_black_wins_if_white_has_no_pieces(self):
        game = Game()
        game.reset()
        game.change_turn()

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

        assert game.game_over()
        assert game.result == "black"
Esempio n. 3
0
    def test_game_is_over_if_no_pieces_remaining(self):
        game = Game()
        game.reset()
        assert not game.game_over()

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

        assert game.game_over()
        assert game.result == "white"
Esempio n. 4
0
    def test_remove_piece_removes_from_opposite_player(self):
        game = Game()
        assert game._pieces_remaining == {"white": 8, "black": 8}

        game._remove_piece()
        assert game._pieces_remaining == {"white": 8, "black": 7}

        game.change_turn()
        game._remove_piece()
        assert game._pieces_remaining == {"white": 7, "black": 7}
Esempio n. 5
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