Update stream example, update AUTHORS for future example fix
Remove tests that usually caused Travis to fail Made it clear that Authenticaiton IS required for Streaming in the docstring
This commit is contained in:
parent
64b1349993
commit
f879094ea1
5 changed files with 9 additions and 19 deletions
|
|
@ -40,3 +40,5 @@ Patches and Suggestions
|
|||
- `Greg Nofi <https://github.com/nofeet>`_, fixed using built-in Exception attributes for storing & retrieving error message
|
||||
- `Jonathan Vanasco <https://github.com/jvanasco>`_, Debugging support, error_code tracking, Twitter error API tracking, other fixes
|
||||
- `DevDave <https://github.com/devdave>`_, quick fix for longs with helper._transparent_params
|
||||
- `Ruben Varela Rosa <https://github.com/rubenvarela>`_, Fixed search example
|
||||
>>>>>>> Update stream example, update AUTHORS for future example fix
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ History
|
|||
- Updated some internal API code, ``__init__`` didn't need to have ``self.auth`` and ``self.headers`` because they were never used anywhere else but the ``__init__``
|
||||
- Added ``disconnect`` method to ``TwythonStreamer``, allowing users to disconnect as they desire
|
||||
- Updated ``TwythonStreamError`` docstring, also allow importing it from ``twython``
|
||||
- No longer raise ``TwythonStreamError`` when stream line can't be decoded. Instead, sends signal to ``TwythonStreamer.on_error``
|
||||
|
||||
2.10.0 (2013-05-21)
|
||||
++++++++++++++++++
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ from twython import TwythonStreamer
|
|||
|
||||
class MyStreamer(TwythonStreamer):
|
||||
def on_success(self, data):
|
||||
print data
|
||||
if 'text' in data:
|
||||
print data['text'].encode('utf-8')
|
||||
# Want to disconnect after the first result?
|
||||
# self.disconnect()
|
||||
|
||||
|
|
|
|||
|
|
@ -154,22 +154,6 @@ class TwythonAPITestCase(unittest.TestCase):
|
|||
status = self.api.update_status(status='Test post just to get deleted :(')
|
||||
self.api.destroy_status(id=status['id_str'])
|
||||
|
||||
def test_retweet(self):
|
||||
'''Test retweeting a status succeeds'''
|
||||
retweet = self.api.retweet(id='99530515043983360')
|
||||
self.api.destroy_status(id=retweet['id_str'])
|
||||
|
||||
def test_retweet_twice(self):
|
||||
'''Test that trying to retweet a tweet twice raises a TwythonError'''
|
||||
tweets = self.api.search(q='twitter').get('statuses')
|
||||
if tweets:
|
||||
retweet = self.api.retweet(id=tweets[0]['id_str'])
|
||||
self.assertRaises(TwythonError, self.api.retweet,
|
||||
id=tweets[0]['id_str'])
|
||||
|
||||
# Then clean up
|
||||
self.api.destroy_status(id=retweet['id_str'])
|
||||
|
||||
def test_get_oembed_tweet(self):
|
||||
'''Test getting info to embed tweet on Third Party site succeeds'''
|
||||
self.api.get_oembed_tweet(id='99530515043983360')
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class TwythonStreamer(object):
|
|||
def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret,
|
||||
timeout=300, retry_count=None, retry_in=10, headers=None):
|
||||
"""Streaming class for a friendly streaming user experience
|
||||
Authentication IS required to use the Twitter Streaming API
|
||||
|
||||
:param app_key: (required) Your applications key
|
||||
:param app_secret: (required) Your applications secret key
|
||||
|
|
@ -99,8 +100,9 @@ class TwythonStreamer(object):
|
|||
line = line.decode('utf-8')
|
||||
self.on_success(json.loads(line))
|
||||
except ValueError:
|
||||
raise TwythonStreamError('Response was not valid JSON, \
|
||||
unable to decode.')
|
||||
self.on_error(response.status_code, 'Unable to decode response, not vaild JSON.')
|
||||
|
||||
response.close()
|
||||
|
||||
def on_success(self, data):
|
||||
"""Called when data has been successfull received from the stream
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue