Add missing parameters to `verify_credentials`
authorAlejandro Gómez <alejandroogomez@gmail.com>
Thu, 5 Jul 2012 19:32:30 +0000 (21:32 +0200)
committerAlejandro Gómez <alejandroogomez@gmail.com>
Thu, 5 Jul 2012 19:32:30 +0000 (21:32 +0200)
As described in the Twitter API docs, the `verify_credentials`
method accepts the optional `include_entities` and `skip_status`
parameters.

    https://dev.twitter.com/docs/api/1/get/account/verify_credentials

I've modified `tweepy.API.verify_credentials` for allowing these
parameters and expanded `tests.testverifycredentials` to test the
new functionality

tests.py
tweepy/api.py

index 4929cd353ca783b31622991a3bd744a58a63b606..3905c6b07239f87224f5ba798b8bf50f2501532c 100644 (file)
--- a/tests.py
+++ b/tests.py
@@ -130,6 +130,14 @@ class TweepyAPITests(unittest.TestCase):
     def testverifycredentials(self):
         self.assertNotEqual(self.api.verify_credentials(), False)
 
+        # make sure that `me.status.entities` is not an empty dict
+        me = self.api.verify_credentials(include_entities=True)
+        self.assertTrue(me.status.entities)
+
+        # `status` shouldn't be included
+        me = self.api.verify_credentials(skip_status=True)
+        self.assertFalse(hasattr(me, 'status'))
+
         api = API(BasicAuthHandler('bad', 'password'))
         self.assertEqual(api.verify_credentials(), False)
 
index 7692ce4a6409319dc43f0f0cab2c8ca151261a9e..c6bd5d0b077d002c25feeb516462e1f1fda513c5 100644 (file)
@@ -307,13 +307,14 @@ class API(object):
     )
 
     """ account/verify_credentials """
-    def verify_credentials(self):
+    def verify_credentials(self, **kargs):
         try:
             return bind_api(
                 path = '/account/verify_credentials.json',
                 payload_type = 'user',
-                require_auth = True
-            )(self)
+                require_auth = True,
+                allowed_param = ['include_entities', 'skip_status'],
+            )(self, **kargs)
         except TweepError, e:
             if e.response and e.response.status == 401:
                 return False