From 2ac4e73d58cd3e4d938daf8e28105fd8651b17b4 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Fri, 7 Aug 2009 11:51:02 -0500 Subject: [PATCH] More tests. --- tests.py | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/tests.py b/tests.py index 62347ca..fe483ed 100644 --- a/tests.py +++ b/tests.py @@ -82,12 +82,38 @@ class TweepyAPITests(unittest.TestCase): self.assert_(len(dms) > 0) self.assert_(isinstance(dms[0], DirectMessage)) - def testsenddirectmessage(self): - dm = self.api.send_direct_message(self.username, 'test message') - self.assert_(isinstance(dm, DirectMessage)) - self.assertEqual(dm.text, 'test message') - self.assertEqual(dm.sender.screen_name, self.username) - self.assertEqual(dm.recipient.screen_name, self.username) + def testsendanddestroydirectmessage(self): + # send + sent_dm = self.api.send_direct_message(self.username, 'test message') + self.assert_(isinstance(sent_dm, DirectMessage)) + self.assertEqual(sent_dm.text, 'test message') + self.assertEqual(sent_dm.sender.screen_name, self.username) + self.assertEqual(sent_dm.recipient.screen_name, self.username) + + # destroy + destroyed_dm = self.api.destroy_direct_message(sent_dm.id) + self.assert_(isinstance(destroyed_dm, DirectMessage)) + self.assertEqual(destroyed_dm.text, sent_dm.text) + self.assertEqual(destroyed_dm.id, sent_dm.id) + self.assertEqual(destroyed_dm.sender.screen_name, self.username) + self.assertEqual(destroyed_dm.recipient.screen_name, self.username) + + def testcreatefriendship(self): + friend = self.api.create_friendship('twitter') + self.assert_(isinstance(friend, User)) + self.assertEqual(friend.screen_name, 'twitter') + self.assertTrue(self.api.exists_friendship(self.username, 'twitter')) + + def testdestroyfriendship(self): + enemy = self.api.destroy_friendship('twitter') + self.assert_(isinstance(enemy, User)) + self.assertEqual(enemy.screen_name, 'twitter') + self.assertFalse(self.api.exists_friendship(self.username, 'twitter')) + + def testshowfriendship(self): + source, target = self.api.show_friendship(target_screen_name='twtiter') + self.assert_(isinstance(source, Friendship)) + self.assert_(isinstance(target, Friendship)) if __name__ == '__main__': unittest.main() -- 2.25.1