def test_find_nearest_string_on_ats(self): """ Verify that closest twitter username candidate can be found. """ test_candidates = {"@realDonalTrump", "@FES", "@jack"} self.assertEqual( ParseTools.find_nearest_string("@trump", test_candidates), "@realDonalTrump") self.assertEqual(ParseTools.find_nearest_string("@j", test_candidates), "@jack")
def test_find_nearest_string_string_in_candidates(self): """ Verify that find_nearest_string can correctly match a string in the candidates with itself. """ test_candidates = {"Oranges", "Tomatoes", "Grapes"} self.assertEqual( ParseTools.find_nearest_string("Oranges", test_candidates), "Oranges") self.assertEqual( ParseTools.find_nearest_string("Tomatoes", test_candidates), "Tomatoes") self.assertEqual( ParseTools.find_nearest_string("Grapes", test_candidates), "Grapes")
def test_find_nearest_string_string_not_in_candidates(self): """ Verify that find_nearest_string can correctly match a string with its closest candidate. """ test_candidates = {"Oranges", "Tomatoes", "Grapes"} self.assertEqual( ParseTools.find_nearest_string("oranges", test_candidates), "Oranges") self.assertEqual( ParseTools.find_nearest_string("iranges", test_candidates), "Oranges") self.assertEqual( ParseTools.find_nearest_string("Oranges ", test_candidates), "Oranges") self.assertEqual( ParseTools.find_nearest_string(" Oranges", test_candidates), "Oranges") self.assertEqual( ParseTools.find_nearest_string("Orion", test_candidates), "Oranges") self.assertEqual( ParseTools.find_nearest_string("Tommmmatoes", test_candidates), "Tomatoes") self.assertEqual( ParseTools.find_nearest_string("Bomatoes ", test_candidates), "Tomatoes")