def test_no_path_given(self): """ Check handling of an invalid path """ # xxxx.txt does not exist path = "../resources/XXXX.txt" start_word = 'cat' end_word = 'dog' test_path = WordPath(path, start_word, end_word) # only the start word is returned self.assertEqual(test_path.__str__() , 'cat')
def test_main(self): """ test the expected paths are generated for the start_word and end_word """ test_data = ['cat -> cot -> cog -> dog', 'pint -> pent -> peat -> prat -> pray', 'fire -> fare -> care -> carp -> camp'] for test in test_data: seperate = test.split() start_word = seperate[0] end_word = seperate[-1] expected = WordPath(self.path, start_word, end_word) self.assertEqual(expected.__str__(), test) # test identical start and end words expected = WordPath(self.path, 'cat', 'cat') self.assertEqual(expected.__str__(), 'cat') # test words not in dict expected = WordPath(self.path, 'xxxxx', 'yyyyy') self.assertEqual(expected.__str__(), 'xxxxx')