def test_tweet(self): status = 'This is a Unit Test with random string: %s' % generate_random_string( ) input_statement = 'tweet status : "%s" ;' % status self.execute(input_statement=input_statement) tweet = self.get_most_recent_user_timeline_tweet()[0] self.assertEqual(tweet.text, status)
def test_tweet_optional_parameters(self): input_statement = """ tweet status : "This is a Unit Test with random string: %s", possibly_sensitive : True, lat: 50.834400, long: -0.130240;""" % generate_random_string() self.execute(input_statement=input_statement) timeline_tweet = self.get_most_recent_user_timeline_tweet() self.assertTrue(timeline_tweet[0].place.name, "Brighton")
def test_reply_to_tweet(self): api = self.get_tweepy_api() latest_mention = api.mentions_timeline(count=1) reply_id = latest_mention[0].id username = latest_mention[0].user.screen_name input_statement = 'reply_to_tweet in_reply_to_status_id : %s, status : "Hello @%s, Random Reply %s";' % ( reply_id, username, generate_random_string()) self.execute(input_statement=input_statement) timeline_tweet = self.get_most_recent_user_timeline_tweet() self.assertEqual(reply_id, timeline_tweet[0].in_reply_to_status_id)
def test_schedule_tweet(self): timeline_tweet = self.get_most_recent_user_timeline_tweet() schedule_time = datetime.datetime.now() + timedelta(minutes=1) tweet_status = 'schedule tweet test, random string: %s' % generate_random_string( ) input_statement = 'schedule minute : %s, hour : %s, day_of_month : %s, month : %s, tweet status : "%s" ;' \ % (schedule_time.minute, schedule_time.hour, schedule_time.day, schedule_time.month, tweet_status) self.execute(input_statement=input_statement) self.assertNotEqual(tweet_status, timeline_tweet[0].text) time.sleep(60) updated_timeline_tweet = self.get_most_recent_user_timeline_tweet() self.assertEqual(tweet_status, updated_timeline_tweet[0].text)
def test_tweet(self): status = 'This is a Unit Test with random string: %s' % generate_random_string( ) input_statement = 'tweet status : "%s" ;' % status campaign = self.create_campaign(name="test_tweet_campaign") file_name = "test_tweet.txt" file = self.generate_file(input_statement=input_statement, file_name=file_name, campaign=campaign) campaign.dsl_program_upload.save(file_name, file) self.execute(campaign=campaign) tweet = self.get_most_recent_user_timeline_tweet()[0] self.assertEqual(tweet.text, status)
def test_direct_message(self): # enter personal account recipient id recipient_id = '' text = 'Hello Friend! % s' % generate_random_string() input_statement = 'direct_message recipient_id : %s, text : "%s" ;' % ( recipient_id, text) self.execute(input_statement=input_statement) direct_message = self.get_most_recent_direct_message() self.assertTrue( recipient_id, direct_message[0].message_create.get('target').get('recipient_id')) self.assertTrue( text, direct_message[0].message_create.get("message_data").get("text"))
def test_tweet_optional_parameters(self): input_statement = """ tweet status : "This is a Unit Test with random string: %s", possibly_sensitive : True, lat: 50.834400, long: -0.130240;""" % generate_random_string() campaign = self.create_campaign(name=" test_tweet_optional_parameters") file_name = " test_tweet_optional_parameters.txt" file = self.generate_file(input_statement=input_statement, file_name=file_name, campaign=campaign) campaign.dsl_program_upload.save(file_name, file) self.execute(campaign=campaign) timeline_tweet = self.get_most_recent_user_timeline_tweet() self.assertTrue(timeline_tweet[0].place.name, "Brighton")
def test_reply_to_tweet(self): api = self.get_tweepy_api() latest_mention = api.mentions_timeline(count=1) reply_id = latest_mention[0].id username = latest_mention[0].user.screen_name input_statement = 'reply_to_tweet in_reply_to_status_id : %s, status : "Hello @%s, Random Reply %s";' % ( reply_id, username, generate_random_string()) campaign = self.create_campaign(name="test_reply_to_tweet_campaign") file_name = "test_reply_to_tweet.txt" file = self.generate_file(input_statement=input_statement, file_name=file_name, campaign=campaign) campaign.dsl_program_upload.save(file_name, file) self.execute(campaign=campaign) timeline_tweet = self.get_most_recent_user_timeline_tweet() self.assertEqual(reply_id, timeline_tweet[0].in_reply_to_status_id)
def test_schedule_tweet(self): timeline_tweet = self.get_most_recent_user_timeline_tweet() schedule_time = datetime.datetime.now() + timedelta(minutes=1) tweet_status = 'schedule tweet test, random string: %s' % generate_random_string( ) input_statement = 'schedule minute : %s, hour : %s, day_of_month : %s, month : %s, tweet status : "%s" ;' \ % (schedule_time.minute, schedule_time.hour, schedule_time.day, schedule_time.month, tweet_status) campaign = self.create_campaign(name="test_schedule_tweet") file_name = "test_schedule_tweet.txt" file = self.generate_file(input_statement=input_statement, file_name=file_name, campaign=campaign) campaign.dsl_program_upload.save(file_name, file) self.execute(campaign=campaign) self.assertNotEqual(tweet_status, timeline_tweet[0].text) time.sleep(60) updated_timeline_tweet = self.get_most_recent_user_timeline_tweet() self.assertEqual(tweet_status, updated_timeline_tweet[0].text)
def test_direct_message(self): # enter personal account recipient id recipient_id = '' text = 'Hello Friend! % s' % generate_random_string() input_statement = 'direct_message recipient_id : %s, text : "%s" ;' % ( recipient_id, text) campaign = self.create_campaign(name=" test_direct_message") file_name = "test_direct_message.txt" file = self.generate_file(input_statement=input_statement, file_name=file_name, campaign=campaign) campaign.dsl_program_upload.save(file_name, file) self.execute(campaign=campaign) direct_message = self.get_most_recent_direct_message() self.assertTrue( recipient_id, direct_message[0].message_create.get('target').get('recipient_id')) self.assertTrue( text, direct_message[0].message_create.get("message_data").get("text"))