def test_validate_piece(self): b = Board() b.clear() for square, piece in self.data.items(): with self.assertRaises(Exception) as context: b._validate_piece(piece) exc_str = f'The piece {piece} is not found on board' self.assertTrue(exc_str in str(context.exception))
def test_clear(self): b = Board() expected_result = dict( [ (Square((x, y)), None) for x in range(8) for y in range(8) ] ) b.clear() self.assertEqual(b.data, expected_result)
def test_add_piece(self): b = Board() b.clear() for square, piece in self.data.items(): b.add_piece(piece, square) # Validate added piece expected_result = b.get_piece(square) self.assertEqual(piece, expected_result) # Validate square for added piece expected_result = b.get_square(piece) self.assertEqual(square, expected_result)
def test_is_empty(self): b = Board() b.clear() for square, _ in self.data.items(): self.assertTrue(b.is_empty(square))