def test_try_move_without_capture(self, board): rook_position = Position(4, 4) rook = Rook(board, constants.WHITE, rook_position) board.in_check.return_value = False game = Game() game._board = board self.assertTrue(game.try_move(rook, Position(5, 4))) self.assertEqual(rook.position, rook_position) board.in_check.return_value = True self.assertFalse(game.try_move(rook, Position(5, 4))) self.assertEqual(rook.position, rook_position)
def test_try_move_with_capture(self, board): white_rook_position = Position(4, 4) white_rook = Rook(board, constants.WHITE, white_rook_position) to_position = Position(5, 4) black_rook = Rook(board, constants.BLACK, to_position) board.in_check.return_value = False game = Game() game._board = board self.assertTrue(game.try_move(white_rook, to_position)) self.assertEqual(white_rook.position, white_rook_position) self.assertEqual(black_rook.position, to_position) board.in_check.return_value = True self.assertFalse(game.try_move(white_rook, to_position)) self.assertEqual(white_rook.position, white_rook_position) self.assertEqual(black_rook.position, to_position)