Commit ca31b55b authored by Joshua Roesslein's avatar Joshua Roesslein
Browse files

Merge pull request #185 from alejandrogomez/master

Add missing parameters to `verify_credentials`
parents 62c14aad 3060cf12
...@@ -3,7 +3,8 @@ import random ...@@ -3,7 +3,8 @@ import random
from time import sleep from time import sleep
import os import os
from tweepy import * from tweepy import (API, BasicAuthHandler, OAuthHandler, Friendship, Cursor,
MemoryCache, FileCache)
"""Configurations""" """Configurations"""
# Must supply twitter account credentials for tests # Must supply twitter account credentials for tests
...@@ -59,7 +60,7 @@ class TweepyAPITests(unittest.TestCase): ...@@ -59,7 +60,7 @@ class TweepyAPITests(unittest.TestCase):
self.api.retweets(123) self.api.retweets(123)
def testgetstatus(self): def testgetstatus(self):
s = self.api.get_status(id=123) self.api.get_status(id=123)
def testupdateanddestroystatus(self): def testupdateanddestroystatus(self):
# test update # test update
...@@ -134,6 +135,14 @@ class TweepyAPITests(unittest.TestCase): ...@@ -134,6 +135,14 @@ class TweepyAPITests(unittest.TestCase):
def testverifycredentials(self): def testverifycredentials(self):
self.assertNotEqual(self.api.verify_credentials(), False) 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')) api = API(BasicAuthHandler('bad', 'password'))
self.assertEqual(api.verify_credentials(), False) self.assertEqual(api.verify_credentials(), False)
...@@ -386,4 +395,3 @@ class TweepyCacheTests(unittest.TestCase): ...@@ -386,4 +395,3 @@ class TweepyCacheTests(unittest.TestCase):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
...@@ -7,7 +7,7 @@ import mimetypes ...@@ -7,7 +7,7 @@ import mimetypes
from tweepy.binder import bind_api from tweepy.binder import bind_api
from tweepy.error import TweepError from tweepy.error import TweepError
from tweepy.parsers import ModelParser, RawParser from tweepy.parsers import ModelParser
from tweepy.utils import list_to_csv from tweepy.utils import list_to_csv
...@@ -308,13 +308,14 @@ class API(object): ...@@ -308,13 +308,14 @@ class API(object):
) )
""" account/verify_credentials """ """ account/verify_credentials """
def verify_credentials(self): def verify_credentials(self, **kargs):
try: try:
return bind_api( return bind_api(
path = '/account/verify_credentials.json', path = '/account/verify_credentials.json',
payload_type = 'user', payload_type = 'user',
require_auth = True require_auth = True,
)(self) allowed_param = ['include_entities', 'skip_status'],
)(self, **kargs)
except TweepError, e: except TweepError, e:
if e.response and e.response.status == 401: if e.response and e.response.status == 401:
return False return False
...@@ -727,7 +728,7 @@ class API(object): ...@@ -727,7 +728,7 @@ class API(object):
try: try:
if os.path.getsize(filename) > (max_size * 1024): if os.path.getsize(filename) > (max_size * 1024):
raise TweepError('File is too big, must be less than 700kb.') raise TweepError('File is too big, must be less than 700kb.')
except os.error, e: except os.error:
raise TweepError('Unable to access file') raise TweepError('Unable to access file')
# image must be gif, jpeg, or png # image must be gif, jpeg, or png
......
...@@ -233,6 +233,8 @@ class List(Model): ...@@ -233,6 +233,8 @@ class List(Model):
for k,v in json.items(): for k,v in json.items():
if k == 'user': if k == 'user':
setattr(lst, k, User.parse(api, v)) setattr(lst, k, User.parse(api, v))
elif k == 'created_at':
setattr(lst, k, parse_datetime(v))
else: else:
setattr(lst, k, v) setattr(lst, k, v)
return lst return lst
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment