def test_black_pawn_cannot_move_down_two_squares_if_already_moved(): # Arrange board = Board.empty() pawn = Pawn(Player.BLACK) starting_square = Square.at(6, 4) board.set_piece(starting_square, pawn) intermediate_square = Square.at(5, 4) pawn.move_to(board, intermediate_square) # Act moves = pawn.get_available_moves(board) # Assert assert Square.at(3, 4) not in moves
def test_white_pawn_gets_promoted(): # Arrange board = Board.empty() pawn = Pawn(Player.WHITE) starting_square = Square.at(6, 4) board.set_piece(starting_square, pawn) intermediate_square = Square.at(7, 4) pawn.move_to(board, intermediate_square) piece = board.get_piece(intermediate_square) # Act moves = piece.get_available_moves(board) # Assert assert isinstance(piece, Queen)
def test_white_pawn_cannot_move_up_two_squares_if_already_moved(): # Arrange board = Board.empty() pawn = Pawn(Player.WHITE) starting_square = Square.at(1, 4) board.set_piece(starting_square, pawn) intermediate_square = Square.at(2, 4) pawn.move_to(board, intermediate_square) # Act moves = pawn.get_available_moves(board) # Assert assert Square.at(4, 4) not in moves
def test_black_pawn_can_be_captured_by_en_pessant(): # Arrange board = Board.empty() pawn1 = Pawn(Player.BLACK) # MAKE BLACK PAWN starting_square1 = Square.at(6, 4) board.set_piece(starting_square1, pawn1) pawn2 = Pawn(Player.WHITE) # MAKE WHITE PAWN starting_square2 = Square.at(4, 3) board.set_piece(starting_square2, pawn2) intermediate_square = Square.at(4, 4) # move black pawn pawn1.move_to(board, intermediate_square) # Act moves = pawn2.get_available_moves(board) # Assert assert Square.at(5, 4) in moves