Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
ca31b55b
Commit
ca31b55b
authored
Aug 01, 2012
by
Joshua Roesslein
Browse files
Merge pull request #185 from alejandrogomez/master
Add missing parameters to `verify_credentials`
parents
62c14aad
3060cf12
Changes
3
Hide whitespace changes
Inline
Side-by-side
tests.py
View file @
ca31b55b
...
...
@@ -3,7 +3,8 @@ import random
from
time
import
sleep
import
os
from
tweepy
import
*
from
tweepy
import
(
API
,
BasicAuthHandler
,
OAuthHandler
,
Friendship
,
Cursor
,
MemoryCache
,
FileCache
)
"""Configurations"""
# Must supply twitter account credentials for tests
...
...
@@ -59,7 +60,7 @@ class TweepyAPITests(unittest.TestCase):
self
.
api
.
retweets
(
123
)
def
testgetstatus
(
self
):
s
=
self
.
api
.
get_status
(
id
=
123
)
self
.
api
.
get_status
(
id
=
123
)
def
testupdateanddestroystatus
(
self
):
# test update
...
...
@@ -134,6 +135,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
)
...
...
@@ -386,4 +395,3 @@ class TweepyCacheTests(unittest.TestCase):
if
__name__
==
'__main__'
:
unittest
.
main
()
tweepy/api.py
View file @
ca31b55b
...
...
@@ -7,7 +7,7 @@ import mimetypes
from
tweepy.binder
import
bind_api
from
tweepy.error
import
TweepError
from
tweepy.parsers
import
ModelParser
,
RawParser
from
tweepy.parsers
import
ModelParser
from
tweepy.utils
import
list_to_csv
...
...
@@ -308,13 +308,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
...
...
@@ -727,7 +728,7 @@ class API(object):
try
:
if
os
.
path
.
getsize
(
filename
)
>
(
max_size
*
1024
):
raise
TweepError
(
'File is too big, must be less than 700kb.'
)
except
os
.
error
,
e
:
except
os
.
error
:
raise
TweepError
(
'Unable to access file'
)
# image must be gif, jpeg, or png
...
...
tweepy/models.py
View file @
ca31b55b
...
...
@@ -233,6 +233,8 @@ class List(Model):
for
k
,
v
in
json
.
items
():
if
k
==
'user'
:
setattr
(
lst
,
k
,
User
.
parse
(
api
,
v
))
elif
k
==
'created_at'
:
setattr
(
lst
,
k
,
parse_datetime
(
v
))
else
:
setattr
(
lst
,
k
,
v
)
return
lst
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment