def test_extract_ats_strings_with_ats(self): """ Verify that extract_ats returns twitter usernames from string in the order in which they occur. """ self.assertEqual( ParseTools.extract_ats("String with a few @twitter @names"), ["@twitter", "@names"]) self.assertEqual( ParseTools.extract_ats( "@twitter String with names @cool in wide varitey of places @names" ), ["@twitter", "@cool", "@names"])
def test_extract_ats_at_with_symbols(self): """ Verify that extract_ats can catch twitter names when they are surrounded by symbols. """ self.assertEqual( ParseTools.extract_ats( "String @realDonaldTrump: that has twitter name-colon combo"), ["@realDonaldTrump"]) self.assertEqual( ParseTools.extract_ats( ".@realDonaldTrump String that has twitter name-period combo"), ["@realDonaldTrump"])
def test_extract_ats_strings_without_ats(self): """ Verify that extract_ats correctly indicates that a string has no twitter usernames. """ self.assertEqual( ParseTools.extract_ats("String with no twitter names"), []) self.assertEqual( ParseTools.extract_ats( "String with a twitter name without the at: realDonaldTrump"), []) self.assertEqual( ParseTools.extract_ats("String with just the @ symbol"), []) self.assertEqual( ParseTools.extract_ats("String with name like phrase @000"), [])