def test_set_square(self): """ Placing a piece should set that square to the specified piece. """ board = Board() self.assertEqual(None, board.get_square(5)) board.set_square(5, 'X') self.assertEqual('X', board.get_square(5))
def test_get_filled_square(self): """ Getting a filled square should return a string of that piece. (For now, might change to using a separate class for pieces later on.) """ board = Board() board.set_square(1, 'X') self.assertEqual('X', board.get_square(1))
def test_get_index_values(self): """ Squares should be fetched using a pattern like a num-pad on a keyboard. The bottom-left square should be square '1', and the top-right square should be square '9'. """ board = Board() board.set_square(3, 'X') self.assertEqual(board.squares[2], board.get_square(3))
def test_copy_with_blank_board(self): """ Copying a blank board should create a new blank board. Modifying the squares on one should not change the squares on the other. """ board = Board() new_board = board.copy() self.assertListEqual([None] * 9, new_board.squares) new_board.set_square(1, 'X') self.assertIsNone(board.get_square(1)) self.assertEqual(new_board.get_square(1), 'X')
def test_get_emtpy_square(self): """ Trying to get an empty square should return None. """ board = Board() self.assertEqual(None, board.get_square(1))