diff --git a/HISTORY.rst b/HISTORY.rst index 4d066bf..962d581 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,7 @@ History - Developers can now pass an array as a parameter to Twitter API methods and they will be automatically joined by a comma and converted to a string - ``endpoints.py`` now contains ``EndpointsMixin`` (rather than the previous ``api_table`` dict) for Twython, which enables Twython to use functions declared in the Mixin. - Added OAuth 2 authentication (Application Only) for when you want to make read-only calls to Twitter without having to go through the whole user authentication ritual (see docs for usage) +- ``construct_api_url`` now accepts keyword arguments like other Twython methods (e.g. instead of passing ``{'q': 'twitter', 'result_type': 'recent'}``, pass ``q='twitter', result_type='recent'``) 2.10.1 (2013-05-29) ++++++++++++++++++ diff --git a/test_twython.py b/test_twython.py index 5b5f876..f5caf30 100644 --- a/test_twython.py +++ b/test_twython.py @@ -57,18 +57,9 @@ class TwythonAPITestCase(unittest.TestCase): def test_construct_api_url(self): """Test constructing a Twitter API url works as we expect""" url = 'https://api.twitter.com/1.1/search/tweets.json' - constructed_url = self.api.construct_api_url(url, {'q': '#twitter'}) + constructed_url = self.api.construct_api_url(url, q='#twitter') self.assertEqual(constructed_url, 'https://api.twitter.com/1.1/search/tweets.json?q=%23twitter') - def test_shorten_url(self): - """Test shortening a url works""" - self.api.shorten_url('http://google.com') - - def test_shorten_url_no_shortner(self): - """Test shortening a url with no shortener provided raises TwythonError""" - self.assertRaises(TwythonError, self.api.shorten_url, - 'http://google.com', '') - def test_get(self): """Test Twython generic GET request works""" self.api.get('account/verify_credentials') @@ -386,10 +377,6 @@ class TwythonAPITestCase(unittest.TestCase): self.api.delete_list(list_id=list_id) - def test_get_list_memberships(self): - """Test list of lists the authenticated user is a member of succeeds""" - self.api.get_list_memberships() - def test_get_list_subscribers(self): """Test list of subscribers of a specific list succeeds""" self.api.get_list_subscribers(list_id=test_list_id) diff --git a/twython/api.py b/twython/api.py index e16d26d..a68af69 100644 --- a/twython/api.py +++ b/twython/api.py @@ -59,6 +59,8 @@ class Twython(EndpointsMixin, object): if self.access_token: # If they pass an access token, force OAuth 2 oauth_version = 2 + self.oauth_version = oauth_version + # OAuth 2 if oauth_version == 2: self.request_token_url = self.api_url % 'oauth2/token' diff --git a/twython/endpoints.py b/twython/endpoints.py index d8ede51..3ca3c71 100644 --- a/twython/endpoints.py +++ b/twython/endpoints.py @@ -34,14 +34,14 @@ class EndpointsMixin(object): """ return self.get('statuses/user_timeline', params=params) - def get_home_timline(self, **params): + def get_home_timeline(self, **params): """Returns a collection of the most recent Tweets and retweets posted by the authenticating user and the users they follow. Docs: https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline """ - return self.get('statuses/home_timline', params=params) + return self.get('statuses/home_timeline', params=params) def retweeted_of_me(self, **params): """Returns the most recent tweets authored by the authenticating user @@ -89,7 +89,7 @@ class EndpointsMixin(object): Docs: https://dev.twitter.com/docs/api/1.1/post/statuses/update """ - return self.post('statuses/update_status', params=params) + return self.post('statuses/update', params=params) def retweet(self, **params): """Retweets a tweet specified by the id parameter @@ -119,7 +119,7 @@ class EndpointsMixin(object): """ return self.get('statuses/oembed', params=params) - def get_retweeters_id(self, **params): + def get_retweeters_ids(self, **params): """Returns a collection of up to 100 user IDs belonging to users who have retweeted the tweet specified by the id parameter. @@ -479,7 +479,7 @@ class EndpointsMixin(object): Docs: https://dev.twitter.com/docs/api/1.1/get/users/suggestions/%3Aslug/members """ - return self.get('users/suggestions/%s/members' % param['slug'], params=params) + return self.get('users/suggestions/%s/members' % params['slug'], params=params) # Favorites def get_favorites(self, **params): @@ -531,7 +531,6 @@ class EndpointsMixin(object): """ return self.post('lists/members/destroy', params=params) - def get_list_subscribers(self, **params): """Returns the subscribers of the specified list. @@ -562,11 +561,11 @@ class EndpointsMixin(object): Docs: https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/destroy """ - return self.get('lists/subscribers/destroy', params=params) + return self.post('lists/subscribers/destroy', params=params) def create_list_members(self, **params): """Adds multiple members to a list, by specifying a comma-separated - list of member ids or screen names. + list of member ids or screen names. Docs: https://dev.twitter.com/docs/api/1.1/post/lists/members/create_all