From baf6170a99154f147ddd4819621793c20f7e8642 Mon Sep 17 00:00:00 2001 From: Jeremy Low Date: Sun, 18 Feb 2018 21:20:50 -0500 Subject: [PATCH] cleanup funcs to reflect twitter defaults & update docs --- doc/changelog.rst | 14 +++++++------- tests/test_api_30.py | 18 +++++++++--------- twitter/api.py | 19 ++++++++++--------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index 05b79fdb..91f4145c 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -5,7 +5,7 @@ Version 3.4 =========== Deprecations ------------- +++++++++++++ * :py:func:`twitter.api.Api.UpdateBackgroundImage`. Please make sure that your code does not call this function as it will now return a hard error. There is no replacement function. This was deprecated by Twitter around July 2015. @@ -46,7 +46,7 @@ Version 3.2 =========== Deprecations ------------- +++++++++++++ Nothing is being deprecationed this version, however here's what's being deprecated as of v. 3.3.0: @@ -62,7 +62,7 @@ Nothing is being deprecationed this version, however here's what's being depreca What's New ----------- +++++++++++ * We've added new deprecation warnings, so it's easier to track when things go away. All of python-twitter's deprecation warnings will be a subclass of :py:class:`twitter.error.PythonTwitterDeprecationWarning` and will have a version number associated with them such as :py:class:`twitter.error.PythonTwitterDeprecationWarning330`. @@ -80,7 +80,7 @@ What's New * `video_info` is now available on a `twitter.models.Media` object, which allows access to video urls/bitrates/etc. in the `extended_entities` node of a tweet. What's Changed --------------- +++++++++++++++ * :py:class:`twitter.models.Trend`'s `volume` attribute has been renamed `tweet_volume` in line with Twitter's naming convention. This change should allow users to access the number of tweets being tweeted for a given Trend. `PR #375 `_ @@ -90,7 +90,7 @@ What's Changed Bugfixes --------- +++++++++ * :py:class:`twitter.models.Media` again contains a ``sizes`` attribute, which was missed back in the Version 3.0 release. `PR #360 `_ @@ -106,7 +106,7 @@ Version 3.1 ========== What's New -____________ +++++++++++ * :py:func:`twitter.api.Api.PostMediaMetadata()` Method allows the posting of alt text (hover text) to a photo on Twitter. Note that it appears that you have to call this method prior to attaching the photo to a status. @@ -125,7 +125,7 @@ ____________ What's Changed -______________ +++++++++++++++ * :py:func:`twitter.api.Api.GetStatus()` Now accepts the keyword argument ``include_ext_alt_text`` which will request alt text to be included with the Status object being returned (if available). Defaults to ``True``. diff --git a/tests/test_api_30.py b/tests/test_api_30.py index 99e00bf0..dd4baa6d 100644 --- a/tests/test_api_30.py +++ b/tests/test_api_30.py @@ -219,7 +219,7 @@ def testGetBlocks(self): resp_data = f.read() responses.add( responses.GET, - 'https://api.twitter.com/1.1/blocks/list.json?cursor=-1&tweet_mode=compat', + 'https://api.twitter.com/1.1/blocks/list.json?cursor=-1&stringify_ids=False&include_entities=False&skip_status=False&tweet_mode=compat', body=resp_data, match_querystring=True, status=200) @@ -227,7 +227,7 @@ def testGetBlocks(self): resp_data = f.read() responses.add( responses.GET, - 'https://api.twitter.com/1.1/blocks/list.json?cursor=1524574483549312671&tweet_mode=compat', + 'https://api.twitter.com/1.1/blocks/list.json?cursor=1524574483549312671&stringify_ids=False&include_entities=False&skip_status=False&tweet_mode=compat', body=resp_data, match_querystring=True, status=200) @@ -278,7 +278,7 @@ def testGetBlocksIDs(self): resp_data = f.read() responses.add( responses.GET, - 'https://api.twitter.com/1.1/blocks/ids.json?cursor=-1&tweet_mode=compat', + 'https://api.twitter.com/1.1/blocks/ids.json?cursor=-1&stringify_ids=False&include_entities=True&skip_status=False&tweet_mode=compat', body=resp_data, match_querystring=True, status=200) @@ -286,7 +286,7 @@ def testGetBlocksIDs(self): resp_data = f.read() responses.add( responses.GET, - 'https://api.twitter.com/1.1/blocks/ids.json?cursor=1524566179872860311&tweet_mode=compat', + 'https://api.twitter.com/1.1/blocks/ids.json?cursor=1524566179872860311&stringify_ids=False&include_entities=True&skip_status=False&tweet_mode=compat', body=resp_data, match_querystring=True, status=200) @@ -1367,7 +1367,7 @@ def testGetMutes(self): resp_data = f.read() responses.add( responses.GET, - 'https://api.twitter.com/1.1/mutes/users/list.json?cursor=-1&tweet_mode=compat&include_entities=True', + 'https://api.twitter.com/1.1/mutes/users/list.json?cursor=-1&stringify_ids=False&include_entities=True&skip_status=False&tweet_mode=compat', body=resp_data, match_querystring=True, status=200) @@ -1377,7 +1377,7 @@ def testGetMutes(self): resp_data = f.read() responses.add( responses.GET, - 'https://api.twitter.com/1.1/mutes/users/list.json?cursor=1535206520056388207&include_entities=True&tweet_mode=compat', + 'https://api.twitter.com/1.1/mutes/users/list.json?cursor=1535206520056388207&stringify_ids=False&include_entities=True&skip_status=False&tweet_mode=compat', body=resp_data, match_querystring=True, status=200) @@ -1392,7 +1392,7 @@ def testGetMutesIDs(self): resp_data = f.read() responses.add( responses.GET, - 'https://api.twitter.com/1.1/mutes/users/ids.json?tweet_mode=compat&cursor=-1', + 'https://api.twitter.com/1.1/mutes/users/ids.json?cursor=-1&stringify_ids=False&include_entities=True&skip_status=False&tweet_mode=compat', body=resp_data, match_querystring=True, status=200) @@ -1402,7 +1402,7 @@ def testGetMutesIDs(self): resp_data = f.read() responses.add( responses.GET, - 'https://api.twitter.com/1.1/mutes/users/ids.json?tweet_mode=compat&cursor=1535206520056565155', + 'https://api.twitter.com/1.1/mutes/users/ids.json?cursor=1535206520056565155&stringify_ids=False&include_entities=True&skip_status=False&tweet_mode=compat', body=resp_data, match_querystring=True, status=200) @@ -1416,7 +1416,7 @@ def testCreateBlock(self): resp_data = f.read() responses.add( POST, - 'https://api.twitter.com/1.1/blocks/create.json', + DEFAULT_URL, body=resp_data, match_querystring=True, status=200) diff --git a/twitter/api.py b/twitter/api.py index c6fc525e..c59b0bac 100644 --- a/twitter/api.py +++ b/twitter/api.py @@ -1655,7 +1655,8 @@ def GetRetweeters(self, url = '%s/statuses/retweeters/ids.json' % (self.base_url) parameters = { 'id': enf_type('id', int, status_id), - 'stringify_ids': enf_type('stringify_ids', bool, stringify_ids) + 'stringify_ids': enf_type('stringify_ids', bool, stringify_ids), + 'count': count, } result = [] @@ -1742,7 +1743,7 @@ def _GetBlocksMutesPaged(self, action, cursor=-1, skip_status=False, - include_entities=False, + include_entities=True, stringify_ids=False): """ Fetch a page of the users (as twitter.User instances) blocked or muted by the currently authenticated user. @@ -1779,12 +1780,12 @@ def _GetBlocksMutesPaged(self, url = urls[endpoint][action] result = [] - parameters = {} - if skip_status: - parameters['skip_status'] = True - if include_entities: - parameters['include_entities'] = True - parameters['cursor'] = cursor + parameters = { + 'skip_status': bool(skip_status), + 'include_entities': bool(include_entities), + 'stringify_ids': bool(stringify_ids), + 'cursor': cursor, + } resp = self._RequestUrl(url, 'GET', data=parameters) data = self._ParseAndCheckTwitter(resp.content.decode('utf-8')) @@ -1901,7 +1902,7 @@ def GetBlocksIDsPaged(self, return self._GetBlocksMutesPaged(endpoint='block', action='ids', cursor=cursor, - stringify_ids=False) + stringify_ids=stringify_ids) def GetMutes(self, skip_status=False,