def test_equals_case_1(): """ test_equals_case_detected_in_a_bug""" board_set = set() board = Board(6, 4) rook = Rook() queen = Queen() bishop = Bishop() board.put(rook, 2, 1) board.put(queen, 4, 0) board.put(bishop, 5, 2) board_set.add(board) another_board = Board(6, 4) rook = Rook() queen = Queen() bishop = Bishop() another_board.put(rook, 2, 1) another_board.put(queen, 4, 0) another_board.put(bishop, 5, 2) assert another_board in board_set board_set.add(another_board) assert len(board_set) == 1
def test_free_bug(): queen = Queen() queen_2 = Queen() board = Board(7, 7) assert len(board.free_positions()) == 49 board.put(queen, 4, 3) assert len(board.free_positions()) == 26 board.put(queen, 0, 0) assert len(board.free_positions()) == 12 board.clean(0, 0) assert len(board.free_positions()) == 26
def test_queen_identification_q(): """ docstrings should comply to pep257 for every public class and method and module function (except from tests) """ queen = Queen() assert queen.piece_identification == 'Q'
def test_queen_positions_to_take(): """ docstrings should comply to pep257 for every public class and method and module function (except from tests) """ board = Board(3, 3) queen = Queen() board.put(queen, 1, 1) expected = [ (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2), ] res = queen.positions_to_take(board, 1, 1) assert set([pos for pos in res]) == set(expected)
def test_conflict_case(): """test_conflict_special_case_found""" board = Board(6, 4) rook = Rook() queen = Queen() board.put(rook, 2, 1) assert board.conflict(4, 0) is False assert board.conflict(5, 2) is False assert (5, 2) in board.free_positions() board.put(queen, 4, 0) assert (5, 2) in board.free_positions() assert board.conflict(5, 2) is False
def test_free_with_pieces(): """test_free_with_a_king_in_the_board_happy_path """ king = King() queen = Queen() board = Board(7, 7) assert len(board.free_positions()) == 49 board.put(king, 5, 5) assert len(board.free_positions()) == 40 board.clean(5, 5) assert len(board.free_positions()) == 49 board.put(queen, 4, 3) assert len(board.free_positions()) == 26 board.clean(4, 3) assert len(board.free_positions()) == 49
def test_takes_valid_ones(): """test_takes_in_diagonal_vertical_and_horizontal""" queen = Queen() small_board = Board(3, 3) small_board.put(queen, 0, 0) valid_positions = [ (0, 0), (1, 1), (2, 2), (0, 1), (0, 2), (1, 0), (2, 0), ] verify_piece_movement(queen, small_board, valid_positions, 0, 0)