def test_parse_puzzle_returns_the_list_of_words_and_puzzle(self): words_list = PILLAR_SAMPLE_WORD_LIST puzzle_matrix = PILLAR_SAMPLE_PUZZLE_BOARD with open('data/pillar-sample.puzzle') as puzzle_file: words, puzzle = wordsearch.parse_puzzle(puzzle_file) assert words == words_list assert puzzle == puzzle_matrix
def test_parse_puzzle_returns_the_puzzle_contained_in_the_input_file(self): # yapf: disable # pylint: disable=bad-whitespace puzzle_matrix = [ ['M','R','P','P','O','N','E','P','Y','T','H','O','N','C','J'], ['X','X','D','W','R','R','N','G','S','U','X','Q','D','Q','P'], ['C','L','A','V','L','M','W','P','A','E','Z','B','E','G','T'], ['F','O','E','J','S','F','Y','Z','E','U','A','E','D','M','Y'], ['H','T','Y','X','S','Y','F','P','S','P','G','R','S','T','M'], ['G','N','I','M','M','A','R','G','O','R','P','N','C','H','S'], ['Z','R','K','L','K','E','O','O','L','Z','L','E','A','H','A'], ['E','H','T','V','L','I','E','T','V','B','P','T','Q','L','T'], ['A','D','D','Z','G','W','Y','W','E','S','Y','T','N','U','F'], ['X','Q','Z','W','W','Z','T','Q','R','J','H','I','P','W','N'], ['M','U','O','H','K','L','G','K','Z','H','J','R','P','F','N'], ['P','R','I','C','Z','R','N','K','G','H','R','W','L','Z','V'], ['D','E','S','F','J','C','T','T','X','G','D','P','Q','J','F'], ['F','R','Y','O','J','V','T','K','X','Z','G','N','H','B','O'], ['A','O','G','K','U','P','F','Q','A','M','Y','L','W','I','M'] ] # pylint: enable=bad-whitespace # yapf: enable with open('data/sample-puzzle.puzzle') as puzzle_file: _, puzzle = wordsearch.parse_puzzle(puzzle_file) assert puzzle == puzzle_matrix
def test_parse_puzzle_from_command_line_argument(self): argument_parser = wordsearch.build_argument_parser() arguments = argument_parser.parse_args(['data/pillar-sample.puzzle']) words, puzzle = wordsearch.parse_puzzle(arguments.puzzle_file) assert words is not None assert words == PILLAR_SAMPLE_WORD_LIST assert puzzle != [] assert puzzle == PILLAR_SAMPLE_PUZZLE_BOARD
def test_parse_puzzle_returns_the_word_list_in_the_input_file(self): word_list = [ 'LANGUAGE', 'PROGRAMMING', 'PUZZLE', 'PYTHON', 'SEARCH', 'SOLVER', 'THE', 'WORD', 'WRITTEN' ] with open('data/sample-puzzle.puzzle') as puzzle_file: words, _ = wordsearch.parse_puzzle(puzzle_file) assert words == word_list
def setup_method(self, method): self.puzzle_file = open('./data/pillar-sample.puzzle') self.words, self.board = wordsearch.parse_puzzle(self.puzzle_file) self.puzzle = Puzzle(self.board)
def test_parse_puzzle_returns_none_and_empty_list_if_puzzle_is_empty(self): with open('data/empty.puzzle') as puzzle_file: words, puzzle = wordsearch.parse_puzzle(puzzle_file) assert words is None assert puzzle == []
def test_parse_puzzle_raises_value_error_if_puzzle_file_is_null(self): with pytest.raises(ValueError) as e: assert wordsearch.parse_puzzle(None) assert str( e.value) == 'Invalid argument: puzzle_file must not be None.'