def test_empty_mention_inthe_end(self): """Test extract_mentions with mention character appearing int the end. """ actual = tweets.extract_mentions('hardwork is inspiring, @people!') expected = ['people'] self.assertEqual(expected, actual)
def test_double(self): '''Double @ character with an invalid mention''' arg = '@@hello' actual = tweets.extract_mentions(arg) expected = [] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_single_word(self): """Test extract_mentions with a single word but without mention character """ actual = tweets.extract_mentions('TheEarth') expected = [] self.assertEqual(expected, actual)
def test_single_mention(self): """Test extract_mentions with a single word """ actual = tweets.extract_mentions('@TheEarth') expected = ['theearth'] self.assertEqual(expected, actual)
def test_at_end(self): '''Invalid mention with an at symbol at the end''' arg = 'hello my name is @' actual = tweets.extract_mentions(arg) expected = [] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_lower_uppercase(self): '''Duplicate mentions of different cases''' arg = '@wing, @WING' actual = tweets.extract_mentions(arg) expected = ['wing', 'wing'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_single(self): '''Nonempty mention with one single character''' arg = '@i' actual = tweets.extract_mentions(arg) expected = ['i'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_single_mention(self): '''Nonempty mention with one single mention''' arg = '@ohio' actual = tweets.extract_mentions(arg) expected = ['ohio'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_multiple_mentions(self): '''Nonempty mention with multiple mentions''' arg = '@ohio @vermont @nyc' actual = tweets.extract_mentions(arg) expected = ['ohio', 'vermont', 'nyc'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_mentions_behind(self): '''Mentions directly behind text''' arg = 'many@cats@meow' actual = tweets.extract_mentions(arg) expected = [] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_invalid_single(self): '''Invalid single mention with a single not valid character''' arg = '@!' actual = tweets.extract_mentions(arg) expected = [] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_no_mention(self): '''Non-empty tweet with no mentions.''' arg = 'tweet test case' actual = tweets.extract_mentions(arg) expected = [] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_empty(self): '''Empty tweet.''' arg = '' actual = tweets.extract_mentions(arg) expected = [] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_incorrect_mentions(self): '''Non-empty tweet with incorrect mention formats''' arg = '@ @!a @!1 @@! @@a @@1' actual = tweets.extract_mentions(arg) expected = [] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_special_mentions(self): '''Non-empty tweet with special mentions.''' arg = 'it is your @\\\boy @jason_,,,,hu in this @house....!!!litttt' actual = tweets.extract_mentions(arg) expected = ['jason', 'house'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_invalid_mentions(self): '''Non-empty tweet with an invalid mention.''' arg = 'omg I\'m gonna be @late for @work @tmwr @||||////\\' actual = tweets.extract_mentions(arg) expected = ['late', 'work', 'tmwr'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_all_mentions(self): '''Non-empty tweet with all mentions.''' arg = '@how @are @you @today @I @good @thanks' actual = tweets.extract_mentions(arg) expected = ['how', 'are', 'you', 'today', 'i', 'good', 'thanks'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_multiple_repeated_mentions(self): '''Non-empty tweet with multiple repeated mentions''' arg = '@tweet @tweet @123 @123 @ab12 @ab12' actual = tweets.extract_mentions(arg) expected = ['tweet', 'tweet', '123', '123', 'ab12', 'ab12'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_mixed_mentions(self): '''Non-empty tweet with mentions of differnet types''' arg = '@tweet test case @123 456 789 @ab12 cd34 ef56' actual = tweets.extract_mentions(arg) expected = ['tweet', '123', 'ab12'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_more_than_one_alphanumeric_mention(self): '''Non-empty tweet with more than one alphanumeric mentions.''' arg = 'tweet test case 123 456 789 @ab12 @cd34 ef56' actual = tweets.extract_mentions(arg) expected = ['ab12', 'cd34'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_one_numeric_mention(self): '''Non-empty tweet with one numeric mention.''' arg = 'tweet test case @123 456 789 ab12 cd34 ef56' actual = tweets.extract_mentions(arg) expected = ['123'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_more_than_alpha_mentions(self): '''Non-empty tweet with more than one alpha mentions.''' arg = '@tweet @test case 123 456 789 ab12 cd34 ef56' actual = tweets.extract_mentions(arg) expected = ['tweet', 'test'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_repeated_mentions(self): '''Non-empty tweet with repeated mentions.''' arg = 'it is @your @boy @jason @jason @jason @jason' actual = tweets.extract_mentions(arg) expected = ['your', 'boy', 'jason', 'jason', 'jason', 'jason'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_ordered_mentions(self): '''Non-empty tweet with specifically-ordered mentions.''' arg = '@this is @mention1, @mention2, and the @3rdmention.' actual = tweets.extract_mentions(arg) expected = ['this', 'mention1', 'mention2', '3rdmention'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_all_invalid_mentions(self): '''Non-empty tweet with all invalid mentions.''' arg = '@@&#^*#@^@*&^#&@^@%^#&!, @||?|?|\/\/\/' actual = tweets.extract_mentions(arg) expected = [] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_uppercase_mentions(self): '''Non-empty tweet with mentions of upper case''' arg = '@TWEET TEST case @123 456 789 @AB12 CD34 ef56' actual = tweets.extract_mentions(arg) expected = ['tweet', '123', 'ab12'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_uppercase_mentions(self): '''Non-empty tweet with uppercase mentions.''' arg = 'HELLO @WORLD IT IS A @wonderful @DAY!!!!TODAY' actual = tweets.extract_mentions(arg) expected = ['world', 'wonderful', 'day'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_mixed_content(self): '''Non-empty tweet with mentions, hashtags and URL's''' arg = '@tweet #test case @123 #456 789 @ab12 http://cd34 ef56' actual = tweets.extract_mentions(arg) expected = ['tweet', '123', 'ab12'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_numerical_mentions(self): '''Non-empty tweet with numerical mentions.''' arg = '@11111?????, @343523 @LOLOLOL420' actual = tweets.extract_mentions(arg) expected = ['11111', '343523', 'lololol420'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)
def test_nonempty_bad_trail_mentions(self): '''Non-empty tweet with mentions with trailing non-alphanumerics''' arg = '@tweet! test case @123? 456 789 @ab12% cd34 ef56' actual = tweets.extract_mentions(arg) expected = ['tweet', '123', 'ab12'] msg = "Expected {}, but returned {}".format(expected, actual) self.assertEqual(actual, expected, msg)