def test_sudoku_boxes_hold_thier_location(self): from sudoku_board import SudokuBoard board = SudokuBoard() for row in range(1, 10): for column in range(1, 10): self.assertEqual(board.get_sudoku_box(row, column).row, row) self.assertEqual( board.get_sudoku_box(row, column).column, column)
def test_add_answer_stored_in_right_location(self): from sudoku_board import SudokuBoard, SudokuBox board = SudokuBoard() board.add_answer(1, 2, 4) # board uses indexing starting at 1 instead of 0 self.assertEqual(board.get_sudoku_box(1, 2), SudokuBox(4)) with self.assertRaises(IndexError): board.add_answer(0, 0, 4)
def test_sudoku_boxes_hold_thier_location_import_board(self): from sudoku_board import SudokuBoard sudoku_board = [ [1, 2, 3, 4, 5, 6, 7, 8, 9], # this sudoku board is not right but it [2, 3, 4, 5, 6, 7, 8, 9, 1], # doesn't matter we are testing if the board [3, 4, 5, 6, 7, 8, 9, 1, 2], # is correctly implemented in sudoku board [4, 5, 6, 7, 8, 9, 1, 2, 3], [5, 6, 7, 8, 9, 1, 2, 3, 4], [6, 7, 8, 9, 1, 2, 3, 4, 5], [7, 8, 9, 1, 2, 3, 4, 5, 6], [8, 9, 1, 2, 3, 4, 5, 6, 7], [9, 1, 2, 3, 4, 5, 6, 7, 8] ] board = SudokuBoard(sudoku_board) for row in range(1, 10): for column in range(1, 10): self.assertEqual(board.get_sudoku_box(row, column).row, row) self.assertEqual( board.get_sudoku_box(row, column).column, column)
def test_get_sudoku_box_number_not_between_one_through_nine(self): from sudoku_board import SudokuBoard board = SudokuBoard() with self.assertRaises(IndexError): board.get_sudoku_box(0, 0)
def test_get_sudoku_box_number_not_between(self): from sudoku_board import SudokuBoard, SudokuBox board = SudokuBoard() board.add_answer(1, 1, 1) self.assertEqual(board.get_sudoku_box(1, 1), SudokuBox(1))