Beispiel #1
0
    def test_add_piece_validation(self):
        b = Board()

        for square, piece in self.data.items():
            with self.assertRaises(Exception) as context:
                b.add_piece(piece, square)

            exc_str = (
                f'The piece {piece} already '
                f'exists on the board at {square} '
                'cannot add it again!'
            )
            self.assertTrue(exc_str in str(context.exception))
Beispiel #2
0
    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)