def test_tweet1(self): test_obj = json.loads( '{"direct_message" : {"text" : "8:45 : AM : 12/26 : Wake up!", "sender_screen_name" : "myTwitterHandle", "sender" : {"time_zone" : "Atlantic Time (Canada)"}, "recipient" : { "following" : "true"}}}' ) tested_Tweet = create_tweet(test_obj) self.assertEqual(tested_Tweet.hour, 8) self.assertEqual(tested_Tweet.minute, 45) self.assertEqual(tested_Tweet.period, "AM") self.assertEqual(tested_Tweet.month, 12) self.assertEqual(tested_Tweet.day, 26) self.assertEqual(tested_Tweet.msg, " Wake up!")
def test_tweet9(self): test_obj = json.loads( '{"direct_message" : {"text" : "!@:%^ : AM : 12/26 : Wake up!", "sender_screen_name" : "myTwitterHandle", "sender" : {"time_zone" : "Atlantic Time (Canada)"}, "recipient" : { "following" : "true"}}}' ) tested_Tweet = create_tweet(test_obj) self.assertRaises(CreateTweetError)
def test_tweet14(self): test_obj = json.loads( '{"direct_message" : {"text" : " : : : !!!", "sender_screen_name" : "myTwitterHandle", "sender" : {"time_zone" : ""}, "recipient" : { "following" : "true"}}}' ) tested_Tweet = create_tweet(test_obj) self.assertRaises(CreateTweetError)
" {2}, '{3}', '{4}', {5}, {6}, '{7}', {8});".format(tweet_obj.sender, tweet_obj.hour, tweet_obj.minute, tweet_obj.period, tweet_obj.time_zone, tweet_obj.month, tweet_obj.day, tweet_obj.msg, tweet_obj.following) cursor.execute(reminder_str) conn.commit() cursor.close() conn.close() return for msg in twitter_userstream.user(): if 'direct_message' in msg: try: tweet_obj = create_tweet(msg) if tweet_obj is None: raise CreateTweetError if (filter_tweet(tweet_obj) == False): raise FilterError if (time_check(tweet_obj) == False): raise TimePassedError except CreateTweetError: print("Could not create tweet_obj") update_log("Console", "Could not create tweet_obj") continue except FilterError: print("Profanity in tweet") update_log(tweet_obj.sender, "Profanity in tweet") continue except TimePassedError: