Board Module

This module contain all the unit tests for the board module.

test_board.color_position(color: Color, white_positions: tuple, black_positions: tuple) tuple[source]

Returns converted tuple for start and end positions based on color.

Parameters
  • color (Color) – Color.WHITE (True), Color.BLACK (false)

  • white_positions (tuple) – two strings for start and end

  • black_positions (tuple) – two strings for start and end

Returns

two two-item integer tuples for start``and ``end

Return type

tuple

test_board.test_add_piece(empty_board: Board) None[source]

Add 12 invidiual pieces (six per color) to empty board.

test_board.test_add_piece_set_high(empty_board: Board) None[source]

Add set (16 pieces per color) to empty board

test_board.test_check_end_position_empty(empty_board: Board) None[source]

Adds two rooks (different colors) to empty board and check for empty end position.

test_board.test_check_end_position_capture(empty_board: Board) None[source]

Adds two rooks (different color) to empty board and check for capture at end position.

test_board.test_check_end_position_black_blocked(empty_board: Board) None[source]

Adds two rooks (same color) to empty board and check for blocked end position.

test_board.test_convert_position_not_implemented() None[source]

Raises NotImplementedError exception for non-supported value type.

test_board.test_convert_position_string() None[source]

Converts string, 'a1', to two-item tuple, (97, 1).

test_board.test_convert_position_string_valueerror() None[source]

Raises ValueError exception for string, 'z9'.

test_board.test_convert_position_string_runtimeerror() None[source]

Raises RuntimeError exception for string, 'a1h8'.

test_board.test_convert_position_tuple() None[source]

Converts tuple, (97, 1), into string, 'a1'.

test_board.test_convert_position_tuple_valueerror() None[source]

Raises ValueError exception for tuple, (122, 9).

test_board.test_convert_position_tuple_runtimeerror() None[source]

Raises RuntimeError exception for three-item tuple, (0, 0, 0).

test_board.test_has_empty_positions_diagonal(empty_board: Board) None[source]

Checks for empty diagonal positions between start and end positions.

test_board.test_has_empty_positions_diagonal_blocked(empty_board: Board) None[source]

Checks for blocked diagonal positions between start and end positions.

test_board.test_has_empty_positions_horizontal(empty_board: Board) None[source]

Checks for horizontal positions between start and end positions.

test_board.test_has_empty_positions_horizontal_blocked(empty_board: Board) None[source]

Checks for blocked horizontal positions between start and end positions.

test_board.test_has_empty_positions_sidebyside(empty_board: Board) None[source]

Checks for side-by-side start and end positions.

test_board.test_has_empty_positions_vertical(empty_board: Board) None[source]

Checks for empty vertical positions between start and end positions.

test_board.test_has_empty_positions_vertical_blocked(empty_board: Board) None[source]

Checks for blocked vertical positions between start and end positions.

test_board.test_is_diagonal_move_a_to_h(empty_board: Board) None[source]

Test for diangonal moves with valid values.

test_board.test_is_diagonal_move_h_to_a(empty_board: Board) None[source]

Test for diangonal moves with valid values.

test_board.test_is_diagonal_move_invalid(empty_board: Board) None[source]

Test for diangonal moves with invalid values.

test_board.test_validate_move_pawn_white_two(board_set: Board) None[source]

Pawn forward two squares on the first move.

Parameters

board_set (Board) – pytest fixture

test_board.test_validate_move_pawn_white_two_blocked(board_set: Board) None[source]

Pawn forward two squares NOT on the first move. Invalid move.

Parameters

board_set (Board) – pytest fixture

test_board.test_validate_move_pawn_white_two_invalid(empty_board: Board) None[source]

Pawn forward two squares NOT on the first move. Invalid move.

Parameters

board_set (Board) – pytest fixture

test_board.test_validate_move_pawn_white_one(board_set: Board) None[source]

Pawn forward one square.

Parameters

board_set (Board) – pytest fixture

test_board.test_validate_move_pawn_white_one_invalid(board_set: Board) None[source]

Pawn backward one square. Invalid move.

Parameters

board_set (Board) – pytest fixture

test_board.test_validate_move_pawn_white_capture(board_set: Board) None[source]

Pawn forward diagonally one square for capture.

test_board.test_validate_move_pawn_white_capture_invalid(board_set: Board) None[source]

Pawn forward diagonally one square for capture. Invalid move.