def setUp(self):
     self.board = ChessBoard(size=5)
class PlacingQueensTests(unittest.TestCase):
    def setUp(self):
        self.board = ChessBoard(size=5)

    def test_place_black_queen_on_black_place(self):
        black_places = self.board.black_places[0]
        self.board.place_black_queen(black_places)
        self.assertEqual(self.board.black_queens(),
                         [BlackQueen(row=0, column=0)])

    def test_place_black_queen_on_white_place_should_raise_exception(self):
        white_place = self.board.white_places[0]
        with self.assertRaises(BadQueenPlacementException):
            self.board.place_black_queen(white_place)

    def test_place_white_queen_on_white_place(self):
        white_places = self.board.white_places[0]
        self.board.place_white_queen(white_places)
        self.assertEqual(self.board.white_queens(),
                         [WhiteQueen(row=0, column=1)])

    def test_place_white_queen_on_black_place_should_raise_exception(self):
        black_place = self.board.black_places[0]
        with self.assertRaises(BadQueenPlacementException):
            self.board.place_white_queen(black_place)

    def test_place_two_black_queens_on_same_place_should_raise_exception(self):
        black_queen = BlackQueen(row=0, column=0)
        self.board.place_black_queen(black_queen)
        with self.assertRaises(BadQueenPlacementException):
            self.board.place_black_queen(black_queen)

    def test_place_two_white_queens_on_same_place_should_raise_exception(self):
        white_queen = WhiteQueen(row=0, column=1)
        self.board.place_white_queen(white_queen)
        with self.assertRaises(BadQueenPlacementException):
            self.board.place_white_queen(white_queen)

    def test_place_two_attacking_queens_opposite_color(self):
        self.fail("Work for tomorrow")
 def test_board_of_size_two_should_have_two_black_and_two_white_places(
         self):
     board = ChessBoard(size=2)
     self.assertEqual(board.black_places, [(0, 0), (1, 1)])
     self.assertEqual(board.white_places, [(0, 1), (1, 0)])
 def test_board_of_size_one_should_have_one_black_and_zero_white_places(
         self):
     board = ChessBoard(size=1)
     self.assertEqual(board.black_places, [(0, 0)])
     self.assertEqual(board.white_places, [])
 def test_available_places_for_odd_size_board(self):
     odd_sized_board = ChessBoard(size=5)
     self.assertEqual(odd_sized_board.board_size,
                      BoardSize(black_size=13, white_size=12))
 def test_available_places_for_even_size_board(self):
     even_sized_board = ChessBoard(size=8)
     self.assertEqual(even_sized_board.board_size,
                      BoardSize(black_size=32, white_size=32))