From fbf579645b4c30b967b6a50acf0538fbbd57d8e4 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Fri, 7 Aug 2009 11:32:41 -0500 Subject: [PATCH] Added some more tests. Applied a fix to direct message parsing. --- tests.py | 26 ++++++++++++++++++++++++-- tweepy/parsers.py | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/tests.py b/tests.py index 6bce512..62347ca 100644 --- a/tests.py +++ b/tests.py @@ -25,8 +25,8 @@ class TweepyAPITests(unittest.TestCase): self.assert_(isinstance(s[0],Status)) def testfriendstimeline(self): - s = self.api.friends_timeline(count=5) - self.assert_(len(s) == 5) + s = self.api.friends_timeline(count=1) + self.assert_(len(s) == 1) self.assert_(isinstance(s[0],Status)) def testusertimeline(self): @@ -67,6 +67,28 @@ class TweepyAPITests(unittest.TestCase): self.assert_(isinstance(me,User)) self.assertEqual(me.screen_name, self.username) + def testfriends(self): + friends = self.api.friends() + self.assert_(len(friends) > 0) + self.assert_(isinstance(friends[0], User)) + + def testfollowers(self): + followers = self.api.followers() + self.assert_(len(followers) > 0) + self.assert_(isinstance(followers[0], User)) + + def testdirectmessages(self): + dms = self.api.direct_messages() + 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) + if __name__ == '__main__': unittest.main() diff --git a/tweepy/parsers.py b/tweepy/parsers.py index e54b3c6..f7704e8 100644 --- a/tweepy/parsers.py +++ b/tweepy/parsers.py @@ -85,7 +85,7 @@ def _parse_dm(obj, api): dm = api.classes['direct_message']() dm._api = api for k,v in obj.items(): - if k == 'sender': + if k == 'sender' or k == 'recipient': setattr(dm, k, _parse_user(v, api)) elif k == 'created_at': setattr(dm, k, _parse_datetime(v)) -- 2.25.1