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