def test_suggestions(self): squares = [['.', '.', '', '', ''], ['B', 'E', 'E', 'C', 'H'], ['A', 'S', 'A', 'H', 'I'], ['T', 'A', 'C', 'O', 'S'], ['H', 'U', 'H', '.', '.']] model = Model(squares) suggestions = model._get_suggestions((0, 2), grid.Mode.ACROSS) print(suggestions[:10])
def test_get_square_info(self, square, text, background, focused): model = Model(squares, dictionary_path=dictionary_path) model.update_focus(2, 3) actual = model.get_square(square[0], square[1]) self.assertEqual(actual.text, text) self.assertEqual(actual.background, background) self.assertEqual(actual.focused, focused)
def test_suggestions(self): squares = [['.', '.', ' ', ' ', ' '], ['B', 'E', 'E', 'C', 'H'], ['A', 'S', 'A', 'H', 'I'], ['T', 'A', 'C', 'O', 'S'], ['H', 'U', 'H', '.', '.']] model = Model(squares) model.update_focus(0, 2) across, down = model.get_suggestions()
def test_toggle(self): model = Model(squares, dictionary_path=dictionary_path) model.mode = grid.Mode.ACROSS model.focus = (3, 1) model.toggle_orientation() self.assertEqual(model.mode, grid.Mode.DOWN) self.assertEqual(model.highlight, [(3, 1), (4, 1)])
def test_fill(self): squares = [['.', '.', '', '', ''], ['B', 'E', 'E', 'C', 'H'], ['A', 'S', 'A', 'H', 'I'], ['T', 'A', 'C', 'O', 'S'], ['H', 'U', 'H', '.', '.']] model = Model(squares) model.fill() self.assertEqual(['.', '.', 'P', 'E', 'C'], model.grid.squares[0])
def __init__(self): super().__init__() self.title = 'Crossword Creator' self.left = 2000 self.top = 10 self.width = 1000 self.height = 480 self.model = Model(filename=FILENAME, size=15) self.init_ui() self.update_views()
def test_update_square_block_symmetry(self): model = Model(squares, dictionary_path=dictionary_path) model.update_square(4, 0, grid.BLOCK) self.assertEqual(model.get_square(4, 0).text, grid.BLOCK) self.assertEqual(model.get_square(0, 4).text, grid.BLOCK) model.update_square(0, 4, 'A') self.assertEqual(model.get_square(4, 0).text, '') self.assertEqual(model.get_square(0, 4).text, 'A')
def test_movement(self): model = Model(squares, dictionary_path=dictionary_path) model.focus = (2, 2) model.move_up() self.assertEqual(model.focus, (1, 2)) model.move_left() self.assertEqual(model.focus, (1, 1)) model.move_down() self.assertEqual(model.focus, (2, 1)) model.move_right() self.assertEqual(model.focus, (2, 2))
def test_get_next_focus(self, current_focus, text, mode, new_focus): model = Model(squares, dictionary_path=dictionary_path) model.mode = mode model.focus = current_focus model.get_next_focus(text) self.assertEqual(model.focus, new_focus)
def test_update_highlighted_squares(self, focus, mode, highlight): model = Model(squares, dictionary_path=dictionary_path) model.mode = mode model.update_focus(focus[0], focus[1]) self.assertEqual(model.focus, focus) self.assertEqual(model.highlight, highlight)
def test_create_from_size(self): model = Model(size=8, dictionary_path=dictionary_path) self.assertEqual(model.size, 8)
def test_create_from_file(self): model = Model(filename="test/crossword.txt", dictionary_path=dictionary_path) self.assertEqual(model.size, 15)
def test_create_from_squares(self): model = Model(squares, dictionary_path=dictionary_path) self.assertEqual(model.size, 5)