Merge pull request #107 from codl/fix-streaming-tests
fix streaming tests
This commit is contained in:
commit
5b811b719d
S'han modificat 1 arxius amb 9 adicions i 4 eliminacions
|
@ -1,7 +1,9 @@
|
|||
import six
|
||||
import pytest
|
||||
import itertools
|
||||
from mastodon.streaming import StreamListener, MalformedEventError
|
||||
from mastodon.streaming import StreamListener
|
||||
from mastodon.Mastodon import MastodonMalformedEventError
|
||||
|
||||
|
||||
|
||||
class Listener(StreamListener):
|
||||
|
@ -20,6 +22,9 @@ class Listener(StreamListener):
|
|||
def on_delete(self, status_id):
|
||||
self.deletes.append(status_id)
|
||||
|
||||
def on_blahblah(self, data):
|
||||
pass
|
||||
|
||||
def handle_heartbeat(self):
|
||||
self.heartbeats += 1
|
||||
|
||||
|
@ -101,7 +106,7 @@ def test_unknown_event():
|
|||
|
||||
def test_missing_event_name():
|
||||
listener = Listener()
|
||||
with pytest.raises(MalformedEventError):
|
||||
with pytest.raises(MastodonMalformedEventError):
|
||||
listener.handle_stream_([
|
||||
'data: {}',
|
||||
'',
|
||||
|
@ -115,7 +120,7 @@ def test_missing_event_name():
|
|||
|
||||
def test_missing_data():
|
||||
listener = Listener()
|
||||
with pytest.raises(MalformedEventError):
|
||||
with pytest.raises(MastodonMalformedEventError):
|
||||
listener.handle_stream_([
|
||||
'event: update',
|
||||
'',
|
||||
|
@ -169,7 +174,7 @@ def test_valid_utf8():
|
|||
def test_invalid_utf8():
|
||||
"""Cat Face With Tears O"""
|
||||
listener = Listener()
|
||||
with pytest.raises(MalformedEventError):
|
||||
with pytest.raises(MastodonMalformedEventError):
|
||||
listener.handle_stream_([
|
||||
'event: update',
|
||||
'data: {"foo": "\xF0\x9F\x98"}',
|
||||
|
|
Loading…
Referencia en una nova incidència