예제 #1
0
    def test_write_results_failure(self, mock_logger):
        expected_results = OrderedDict()
        expected_results['DIAMOND'] = [(7, 1), (1, 1)]

        ws = WordSearch('data/farm.pzl')
        ws.read()
        ws.solve()
        ws.write()
예제 #2
0
    def test_solve_horizontal_valid(self):
        expected_results = OrderedDict()
        expected_results['DIAMOND'] = [(7, 1), (1, 1)]

        ws = WordSearch('data/suits.pzl')
        ws.read()
        for word in ws.words_to_search:
            word_reversed = word[::-1]
            ws._solve_horizontal(word, word_reversed)
        self.assertEqual(ws.results, expected_results)
예제 #3
0
    def test_solve_vertical_valid(self):
        expected_results = OrderedDict()
        expected_results['HEART'] = [(5, 7), (5, 3)]

        ws = WordSearch('data/suits.pzl')
        ws.read()
        for word in ws.words_to_search:
            word_reversed = word[::-1]
            ws._solve_vertical(word, word_reversed)
        self.assertEqual(ws.results, expected_results)
예제 #4
0
 def test_read_valid_file(self):
     expected_puzzle = [
         'GXWRVZNZXVAXBXN', 'LOOFIDSEOJAATMW', 'CFKDIZWOKRLMGMN',
         'UOVXRNPTUCGDZIG', 'OJEUZMDMIMIGVLX', 'AWOCYQWQHXPHJLD',
         'BEJNKRFDPKNYCFT', 'EGWFTZKRNFEFMWZ', 'WPTXSMWLNEYCBFD',
         'AGZZZDJWMKLJJYN', 'BJTUPFCLWSVXREE', 'QFINRMZMYDNNLKB',
         'HYLLWPTYNLCPKCH', 'TCAUNJVTWOQKXUF', 'JFPVOPYTFYIPAPB'
     ]
     expected_words = ['CHICKEN', 'COW', 'PIG']
     ws = WordSearch('data/farm.pzl')
     ws.read()
     self.assertEqual(expected_words, ws.words_to_search)
     self.assertEqual(expected_puzzle, ws.puzzle)
예제 #5
0
    def test_write_results_valid(self):
        expected_results = [
            'CHICKEN Not Found \n', 'COW (4, 6) (2, 6) \n',
            'PIG (11, 6) (11, 4) \n'
        ]

        ws = WordSearch('data/farm.pzl')
        ws.read()
        ws.solve()
        ws.write()

        with open(ws.file_name + '.out', 'rw') as f:
            data = f.readlines()
            self.assertEquals(data, expected_results)
예제 #6
0
    def test_solve_valid_data(self):
        expected_results = OrderedDict()
        expected_results['DICTIONARY'] = [(1, 5), (1, 14)]
        expected_results['INTEGER'] = 'Not Found'
        expected_results['LIST'] = 'Not Found'
        expected_results['PIP'] = [(6, 10), (8, 10)]
        expected_results['PYTHON'] = [(15, 14), (10, 14)]
        expected_results['STRING'] = 'Not Found'
        expected_results['TUPLE'] = [(8, 6), (8, 2)]

        ws = WordSearch('data/python.pzl')
        ws.read()
        ws.solve()
        self.assertEquals(ws.results, expected_results)