def test_grid_ok_1(self): grid_test_case = [[5, 3, 4, 6, 7, 8, 9, 1, 2], [6, 7, 2, 1, 9, 5, 3, 4, 8], [1, 9, 8, 3, 4, 2, 5, 6, 7], [8, 5, 9, 7, 6, 1, 4, 2, 3], [4, 2, 6, 8, 5, 3, 7, 9, 1], [7, 1, 3, 9, 2, 4, 8, 5, 6], [9, 6, 1, 5, 3, 7, 2, 8, 4], [2, 8, 7, 4, 1, 9, 6, 3, 5], [3, 4, 5, 2, 8, 6, 1, 7, 9]] self.assertEqual(app.sudoku_check(grid_test_case), True)
def test_grid_ok_4(self): # non standard sudoku grid 4x4, square 2x2 grid_test_case = [[7, 4, 6, 9], [8, 9, 1, 3], [2, 1, 3, 8], [3, 6, 9, 5]] # set new shape app.SHAPE_GRID = 4 app.SHAPE_SQUARE = 2 self.assertEqual(app.sudoku_check(grid_test_case), True) # return old shape app.SHAPE_GRID = 9 app.SHAPE_SQUARE = 3
def test_grid_ok_3(self): grid_test_case = [[7, 4, 6, 9, 3, 2, 1, 5, 8], [8, 9, 1, 6, 4, 5, 3, 7, 2], [2, 3, 5, 8, 1, 7, 4, 6, 9], [3, 6, 9, 5, 2, 4, 7, 8, 1], [4, 7, 2, 1, 8, 9, 5, 3, 6], [5, 1, 8, 7, 6, 3, 2, 9, 4], [1, 5, 7, 2, 9, 6, 8, 4, 3], [9, 2, 3, 4, 7, 8, 6, 1, 5], [6, 8, 4, 3, 5, 1, 9, 2, 7]] self.assertEqual(app.sudoku_check(grid_test_case), True)
def test_grid_ok_2(self): grid_test_case = [[4, 1, 6, 7, 5, 8, 2, 3, 9], [8, 7, 9, 4, 2, 3, 1, 5, 6], [3, 5, 2, 1, 9, 6, 7, 8, 4], [1, 3, 5, 8, 7, 9, 6, 4, 2], [6, 2, 8, 3, 1, 4, 5, 9, 7], [9, 4, 7, 2, 6, 5, 3, 1, 8], [2, 8, 3, 5, 4, 7, 9, 6, 1], [5, 6, 1, 9, 8, 2, 4, 7, 3], [7, 9, 4, 6, 3, 1, 8, 2, 5]] self.assertEqual(app.sudoku_check(grid_test_case), True)
def test_grid_er_7(self): # bad shape grid_test_case = [[7, 4, 6, 9, 3, 2, 1, 5, 8], [8, 9, 1, 6, 4, 5, 3, 7, 2], [2, 3, 5, 8, 1, 7, 4, 6, 9], [3, 6, 9, 5, 2, 4, 7, 8, 1], [4, 7, 2, 1, 8, 9, 5, 3, 6], [5, 1, 8, 7, 6, 3, 2, 9, 4], [1, 5, 7, 2, 9, 6, 8, 4, 3], [9, 2, 3, 4, 7, 8, 6, 1, 5]] self.assertEqual(app.sudoku_check(grid_test_case), False)
def test_grid_er_4(self): # bad element = "i" grid_test_case = [[4, 1, 6, 7, 5, 8, 2, 3, 9], [8, 7, 9, 4, 2, 3, 1, 5, 6], [3, 5, 2, 1, 9, 6, 7, 8, 4], [1, 3, 5, 8, 7, 9, 6, 4, 2], [6, 2, 8, 3, 1, 4, 5, 9, 7], [9, 4, 7, 2, 6, 5, 3, 1, 8], [2, 8, 3, 5, 4, 7, 9, 6, 1], [5, 6, 1, 9, 8, 2, 4, 7, 3], [7, 9, 4, 6, 3, 1, 8, 2, "i"]] self.assertEqual(app.sudoku_check(grid_test_case), False)
def test_grid_er_2(self): # bad row and col grid_test_case = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9]] self.assertEqual(app.sudoku_check(grid_test_case), False)
def test_read_from_file_er_2(self): grid_test_case = app.read_from_file("./bad_path.txt") self.assertEqual(app.sudoku_check(grid_test_case), False)
def test_read_from_file_ok_1(self): grid_test_case = app.read_from_file("./test_case_file_ok_1.txt") self.assertEqual(app.sudoku_check(grid_test_case), True)