From: Harmon Date: Fri, 21 Jun 2019 17:00:22 +0000 (-0500) Subject: Update test for API.send_direct_message and API.destroy_direct_message X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=eab2de69ba2df4e10e9e3dbaa5ad9ebe478ac248;p=tweepy.git Update test for API.send_direct_message and API.destroy_direct_message --- diff --git a/tests/test_api.py b/tests/test_api.py index 92ca6d4..5db0362 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -160,18 +160,16 @@ class TweepyAPITests(TweepyTestCase): @tape.use_cassette('testsendanddestroydirectmessage.json') def testsendanddestroydirectmessage(self): + me = self.api.me() + # send - sent_dm = self.api.send_direct_message(username, text='test message') - self.assertEqual(sent_dm.text, 'test message') - self.assertEqual(sent_dm.sender.screen_name, username) - self.assertEqual(sent_dm.recipient.screen_name, username) + sent_dm = self.api.send_direct_message(me.id, text='test message') + self.assertEqual(sent_dm.message_create['message_data']['text'], 'test message') + self.assertEqual(int(sent_dm.message_create['sender_id']), me.id) + self.assertEqual(int(sent_dm.message_create['target']['recipient_id']), me.id) # destroy - destroyed_dm = self.api.destroy_direct_message(sent_dm.id) - self.assertEqual(destroyed_dm.text, sent_dm.text) - self.assertEqual(destroyed_dm.id, sent_dm.id) - self.assertEqual(destroyed_dm.sender.screen_name, username) - self.assertEqual(destroyed_dm.recipient.screen_name, username) + self.api.destroy_direct_message(sent_dm.id) @tape.use_cassette('testcreatedestroyfriendship.json') def testcreatedestroyfriendship(self):