Update test for API.send_direct_message and API.destroy_direct_message
authorHarmon <Harmon758@gmail.com>
Fri, 21 Jun 2019 17:00:22 +0000 (12:00 -0500)
committerHarmon <Harmon758@gmail.com>
Fri, 21 Jun 2019 17:00:22 +0000 (12:00 -0500)
tests/test_api.py

index 92ca6d49444a5b08550c943a4bcf5711be7193cf..5db03625835f531cad652a06bd28e30f0ecb8cf0 100644 (file)
@@ -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):