def test_create_grid_clue_numbers(self): """Check that numbers have been added to the correct squares.""" grid = create_grid(create_small_puzzle(), 3) expected_numbers = [[1, None, 2], [None, None, None], [3, None, None]] for row in range(3): for col in range(3): self.assertEqual(grid[row][col]['number'], expected_numbers[row][col])
def test_create_grid_letters(self): """Check that letters of the solution have been added to the correct squares.""" grid = create_grid(create_small_puzzle(), 3) expected_letters = [['A', 'B', 'C'], ['M', None, 'N'], ['X', 'Y', 'Z']] for row in range(3): for col in range(3): self.assertEqual(grid[row][col]['letter'], expected_letters[row][col])
def test_create_grid_borders(self): """Check that topmost and leftmost attributes have been applied to the borders.""" grid = create_grid(create_small_puzzle(), 3) for row in range(3): for col in range(3): if row == 0: self.assertIn('topmost', grid[row][col]['type']) else: self.assertNotIn('topmost', grid[row][col]['type']) if col == 0: self.assertIn('leftmost', grid[row][col]['type']) else: self.assertNotIn('leftmost', grid[row][col]['type'])
def test_create_grid_pattern(self): """Check that the small 3x3 grid is rendered with the correct block pattern.""" grid = create_grid(create_small_puzzle(), 3) for row in range(3): for col in range(3): self.assertEqual(grid[row][col]['row'], row) self.assertEqual(grid[row][col]['col'], col) if row == 1 and col == 1: self.assertNotIn('light', grid[row][col]['type']) self.assertIn('block', grid[row][col]['type']) else: self.assertIn('light', grid[row][col]['type']) self.assertNotIn('block', grid[row][col]['type'])
def test_get_clues(self): """Create and check the clue lists for the small 3x3 puzzle.""" puz = create_small_puzzle() grid = create_grid(puz, 3) across_clues = get_clues(puz, grid, False) self.assertEqual(len(across_clues), 2) self.assertEqual(across_clues[0]['number'], 1) self.assertEqual(across_clues[0]['clue'], '1a') self.assertEqual(across_clues[0]['numeration'], '2,1') self.assertEqual(across_clues[1]['number'], 3) self.assertEqual(across_clues[1]['clue'], '3a') self.assertEqual(across_clues[1]['numeration'], '1-2') down_clues = get_clues(puz, grid, True) self.assertEqual(len(down_clues), 2) self.assertEqual(down_clues[0]['number'], 1) self.assertEqual(down_clues[0]['clue'], '1d') self.assertEqual(down_clues[0]['numeration'], '3') self.assertEqual(down_clues[1]['number'], 2) self.assertEqual(down_clues[1]['clue'], '2d') self.assertEqual(down_clues[1]['numeration'], '3')