From dd3727c6f544eda3cb68885d22b3fe672848ab60 Mon Sep 17 00:00:00 2001 From: Mike Helmick Date: Sat, 20 Jul 2013 17:22:07 -0400 Subject: [PATCH 1/2] Fixes #243 --- HISTORY.rst | 1 + tests/test_core.py | 4 ++++ twython/endpoints.py | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 4d60acb..e9a8054 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,6 +12,7 @@ History - When an actual request error happens and a ``RequestException`` is raised, it is caught and a ``TwythonError`` is raised instead for convenience. - Added "cursor"-like functionality. Endpoints with the attribute ``iter_mode`` will be able to be passed to ``Twython.cursor`` and returned as a generator. - ``Twython.search_gen`` has been deprecated. Please use ``twitter.cursor(twitter.search, q='your_query')`` instead, where ``twitter`` is your ``Twython`` instance. +- Added method ``get_list_memberships`` 3.0.0 (2013-06-18) ++++++++++++++++++ diff --git a/tests/test_core.py b/tests/test_core.py index b54f729..3e0cfcc 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -385,6 +385,10 @@ class TwythonAPITestCase(unittest.TestCase): self.api.delete_list(list_id=list_id) + def test_get_list_memberships(self): + """Test list of memberhips the authenticated user 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(slug=test_list_slug, diff --git a/twython/endpoints.py b/twython/endpoints.py index bb70f0e..7f709e0 100644 --- a/twython/endpoints.py +++ b/twython/endpoints.py @@ -552,6 +552,16 @@ class EndpointsMixin(object): """ return self.post('lists/members/destroy', params=params) + def get_list_memberships(self, **params): + """Returns the lists the specified user has been added to. + + Docs: https://dev.twitter.com/docs/api/1.1/get/lists/memberships + + """ + return self.get('lists/memberships', params=params) + get_list_memberships.iter_mode = 'cursor' + get_list_memberships.iter_key = 'lists' + def get_list_subscribers(self, **params): """Returns the subscribers of the specified list. From 06f542572498e4a38ee3b1d7575783b4daa07789 Mon Sep 17 00:00:00 2001 From: Mike Helmick Date: Sat, 20 Jul 2013 17:46:13 -0400 Subject: [PATCH 2/2] Fixes #244 --- HISTORY.rst | 2 +- tests/test_core.py | 16 ++++++++++++++++ twython/endpoints.py | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index e9a8054..de27f4d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -12,7 +12,7 @@ History - When an actual request error happens and a ``RequestException`` is raised, it is caught and a ``TwythonError`` is raised instead for convenience. - Added "cursor"-like functionality. Endpoints with the attribute ``iter_mode`` will be able to be passed to ``Twython.cursor`` and returned as a generator. - ``Twython.search_gen`` has been deprecated. Please use ``twitter.cursor(twitter.search, q='your_query')`` instead, where ``twitter`` is your ``Twython`` instance. -- Added method ``get_list_memberships`` +- Added methods ``get_list_memberships``, ``get_twitter_configuration``, ``get_supported_languages``, ``get_privacy_policy``, ``get_tos`` 3.0.0 (2013-06-18) ++++++++++++++++++ diff --git a/tests/test_core.py b/tests/test_core.py index 3e0cfcc..710ba1b 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -482,6 +482,22 @@ class TwythonAPITestCase(unittest.TestCase): self.api.get_closest_trends(lat='37', long='-122') # Help + def test_get_twitter_configuration(self): + """Test getting Twitter's configuration succeeds""" + self.api.get_twitter_configuration() + + def test_get_supported_languages(self): + """Test getting languages supported by Twitter succeeds""" + self.api.get_supported_languages() + + def test_privacy_policy(self): + """Test getting Twitter's Privacy Policy succeeds""" + self.api.get_privacy_policy() + + def test_get_tos(self): + """Test getting the Twitter Terms of Service succeeds""" + self.api.get_tos() + def test_get_application_rate_limit_status(self): """Test getting application rate limit status succeeds""" self.oauth2_api.get_application_rate_limit_status() diff --git a/twython/endpoints.py b/twython/endpoints.py index 7f709e0..87db2a3 100644 --- a/twython/endpoints.py +++ b/twython/endpoints.py @@ -814,6 +814,39 @@ class EndpointsMixin(object): return self.post('oauth2/invalidate_token', params=params) # Help + def get_twitter_configuration(self, **params): + """Returns the current configuration used by Twitter + + Docs: https://dev.twitter.com/docs/api/1.1/get/help/configuration + + """ + return self.get('help/configuration', params=params) + + def get_supported_languages(self, **params): + """Returns the list of languages supported by Twitter along with + their ISO 639-1 code. + + Docs: https://dev.twitter.com/docs/api/1.1/get/help/languages + + """ + return self.get('help/languages', params=params) + + def get_privacy_policy(self, **params): + """Returns Twitter's Privacy Policy + + Docs: https://dev.twitter.com/docs/api/1.1/get/help/privacy + + """ + return self.get('help/privacy', params=params) + + def get_tos(self, **params): + """Return the Twitter Terms of Service + + Docs: https://dev.twitter.com/docs/api/1.1/get/help/tos + + """ + return self.get('help/tos', params=params) + def get_application_rate_limit_status(self, **params): """Returns the current rate limits for methods belonging to the specified resource families.