Attempting to exclude lines that we can't necessarily hit in tests, added a test, fixed function name

update_profile_background_image has been in endpoints.py twice for a
bit, my bad.

Using update_profile_banner_image for the function name to update
profile banner image (that's what it was called previously)
This commit is contained in:
Mike Helmick 2013-06-12 10:54:28 -04:00
parent 672c8db77e
commit 7cab9d5dd1
7 changed files with 27 additions and 28 deletions

View file

@ -1,2 +1,8 @@
[run] [run]
omit = twython/advisory.py omit = twython/advisory.py
[report]
exclude_lines =
pragma: no cover
def __repr__

View file

@ -104,6 +104,11 @@ class TwythonAPITestCase(unittest.TestCase):
self.assertRaises(TwythonAuthError, self.api.get_user_timeline, self.assertRaises(TwythonAuthError, self.api.get_user_timeline,
screen_name=protected_twitter_2) screen_name=protected_twitter_2)
def test_retweeted_of_me(self):
"""Test that getting recent tweets by authenticated user that have
been retweeted by others succeeds"""
self.api.retweeted_of_me()
def test_get_home_timeline(self): def test_get_home_timeline(self):
"""Test returning home timeline for authenticated user succeeds""" """Test returning home timeline for authenticated user succeeds"""
self.api.get_home_timeline() self.api.get_home_timeline()

View file

@ -16,18 +16,6 @@ class TwythonStreamTestCase(unittest.TestCase):
def on_error(self, status_code, data): def on_error(self, status_code, data):
raise TwythonStreamError(data) raise TwythonStreamError(data)
def on_delete(self, data):
return
def on_limit(self, data):
return
def on_disconnect(self, data):
return
def on_timeout(self, data):
return
self.api = MyStreamer(app_key, app_secret, self.api = MyStreamer(app_key, app_secret,
oauth_token, oauth_token_secret) oauth_token, oauth_token_secret)

View file

@ -93,7 +93,7 @@ class EndpointsMixin(object):
""" """
return self.post('statuses/retweet/%s' % params.get('id')) return self.post('statuses/retweet/%s' % params.get('id'))
def update_status_with_media(self, **params): def update_status_with_media(self, **params): # pragma: no cover
"""Updates the authenticating user's current status and attaches media """Updates the authenticating user's current status and attaches media
for upload. In other words, it creates a Tweet with a picture attached. for upload. In other words, it creates a Tweet with a picture attached.
@ -323,7 +323,7 @@ class EndpointsMixin(object):
""" """
return self.post('account/update_profile', params=params) return self.post('account/update_profile', params=params)
def update_profile_background_image(self, **params): def update_profile_banner_image(self, **params): # pragma: no cover
"""Updates the authenticating user's profile background image. """Updates the authenticating user's profile background image.
Docs: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_background_image Docs: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_background_image
@ -340,7 +340,7 @@ class EndpointsMixin(object):
""" """
return self.post('account/update_profile_colors', params=params) return self.post('account/update_profile_colors', params=params)
def update_profile_image(self, **params): def update_profile_image(self, **params): # pragma: no cover
"""Updates the authenticating user's profile image. """Updates the authenticating user's profile image.
Docs: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_image Docs: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_image
@ -431,13 +431,13 @@ class EndpointsMixin(object):
""" """
return self.post('account/remove_profile_banner', params=params) return self.post('account/remove_profile_banner', params=params)
def update_profile_Background_image(self, **params): def update_profile_background_image(self, **params):
"""Uploads a profile banner on behalf of the authenticating user. """Uploads a profile banner on behalf of the authenticating user.
Docs: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_banner Docs: https://dev.twitter.com/docs/api/1.1/post/account/update_profile_banner
""" """
return self.post('ccount/update_profile_background_image', params=params) return self.post('account/update_profile_background_image', params=params)
def get_profile_banner_sizes(self, **params): def get_profile_banner_sizes(self, **params):
"""Returns a map of the available size variations of the specified user's profile banner. """Returns a map of the available size variations of the specified user's profile banner.
@ -712,7 +712,7 @@ class EndpointsMixin(object):
""" """
return self.get('geo/similar_places', params=params) return self.get('geo/similar_places', params=params)
def create_place(self, **params): def create_place(self, **params): # pragma: no cover
"""Creates a new place object at the given latitude and longitude. """Creates a new place object at the given latitude and longitude.
Docs: https://dev.twitter.com/docs/api/1.1/post/geo/place Docs: https://dev.twitter.com/docs/api/1.1/post/geo/place

View file

@ -29,7 +29,7 @@ class TwythonError(Exception):
super(TwythonError, self).__init__(msg) super(TwythonError, self).__init__(msg)
@property @property
def msg(self): def msg(self): # pragma: no cover
return self.args[0] return self.args[0]
@ -41,7 +41,7 @@ class TwythonAuthError(TwythonError):
pass pass
class TwythonRateLimitError(TwythonError): class TwythonRateLimitError(TwythonError): # pragma: no cover
"""Raised when you've hit a rate limit. """Raised when you've hit a rate limit.
The amount of seconds to retry your request in will be appended The amount of seconds to retry your request in will be appended

View file

@ -16,7 +16,7 @@ def _transparent_params(_params):
files = {} files = {}
for k, v in _params.items(): for k, v in _params.items():
if hasattr(v, 'read') and callable(v.read): if hasattr(v, 'read') and callable(v.read):
files[k] = v files[k] = v # pragma: no cover
elif isinstance(v, bool): elif isinstance(v, bool):
if v: if v:
params[k] = 'true' params[k] = 'true'
@ -27,5 +27,5 @@ def _transparent_params(_params):
elif isinstance(v, list): elif isinstance(v, list):
params[k] = ','.join(v) params[k] = ','.join(v)
else: else:
continue continue # pragma: no cover
return params, files return params, files

View file

@ -113,7 +113,7 @@ class TwythonStreamer(object):
response.close() response.close()
def on_success(self, data): def on_success(self, data): # pragma: no cover
"""Called when data has been successfull received from the stream """Called when data has been successfull received from the stream
Feel free to override this to handle your streaming data how you Feel free to override this to handle your streaming data how you
@ -132,7 +132,7 @@ class TwythonStreamer(object):
elif 'disconnect' in data: elif 'disconnect' in data:
self.on_disconnect(data.get('disconnect')) self.on_disconnect(data.get('disconnect'))
def on_error(self, status_code, data): def on_error(self, status_code, data): # pragma: no cover
"""Called when stream returns non-200 status code """Called when stream returns non-200 status code
Feel free to override this to handle your streaming data how you Feel free to override this to handle your streaming data how you
@ -146,7 +146,7 @@ class TwythonStreamer(object):
""" """
return return
def on_delete(self, data): def on_delete(self, data): # pragma: no cover
"""Called when a deletion notice is received """Called when a deletion notice is received
Feel free to override this to handle your streaming data how you Feel free to override this to handle your streaming data how you
@ -159,7 +159,7 @@ class TwythonStreamer(object):
""" """
return return
def on_limit(self, data): def on_limit(self, data): # pragma: no cover
"""Called when a limit notice is received """Called when a limit notice is received
Feel free to override this to handle your streaming data how you Feel free to override this to handle your streaming data how you
@ -172,7 +172,7 @@ class TwythonStreamer(object):
""" """
return return
def on_disconnect(self, data): def on_disconnect(self, data): # pragma: no cover
"""Called when a disconnect notice is received """Called when a disconnect notice is received
Feel free to override this to handle your streaming data how you Feel free to override this to handle your streaming data how you
@ -185,7 +185,7 @@ class TwythonStreamer(object):
""" """
return return
def on_timeout(self): def on_timeout(self): # pragma: no cover
""" Called when the request has timed out """ """ Called when the request has timed out """
return return