Vendoring octorest
This commit is contained in:
parent
3275563a18
commit
bee6f3b69a
76 changed files with 13557 additions and 0 deletions
projects/octorest/test
37
projects/octorest/test/test_xhrstreaming.py
Normal file
37
projects/octorest/test/test_xhrstreaming.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import pytest
|
||||
|
||||
from octorest import XHRStreamingEventHandler
|
||||
|
||||
from _common import URL
|
||||
|
||||
|
||||
def on_message(api, message):
|
||||
api.message = message
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('betamax_recorder')
|
||||
@pytest.fixture
|
||||
def client(betamax_recorder):
|
||||
betamax_recorder.current_cassette.match_options.remove('uri')
|
||||
session = betamax_recorder.session
|
||||
return XHRStreamingEventHandler(url=URL,
|
||||
session=session,
|
||||
on_message=on_message)
|
||||
|
||||
|
||||
class TestXHRStreamingGenerator:
|
||||
@pytest.mark.usefixtures('betamax_session')
|
||||
def test_init_works(self, betamax_session):
|
||||
XHRStreamingEventHandler(url=URL, session=betamax_session)
|
||||
|
||||
@pytest.mark.xfail(reason="OctoPrint\'s tornado server returns 404")
|
||||
def test_send(self, client):
|
||||
r = client.send({"throttle": 10})
|
||||
assert r.status_code in [200, 204]
|
||||
|
||||
def test_run(self, client):
|
||||
client.run()
|
||||
assert client.thread.is_alive()
|
||||
client.wait()
|
||||
assert client.message.get("connected", None)
|
||||
Loading…
Add table
Add a link
Reference in a new issue