http testing

This commit is contained in:
boyska 2014-10-27 00:44:55 +01:00
parent 6f9e4b199b
commit 2bc118bfd9
4 changed files with 27 additions and 8 deletions

8
conftest.py Normal file
View file

@ -0,0 +1,8 @@
from gevent.queue import Queue
import pytest
@pytest.fixture
def queue():
print('fixture q')
return Queue()

2
rpc.py
View file

@ -1,3 +1,4 @@
from __future__ import print_function
import logging import logging
from flask import current_app, Blueprint, Flask from flask import current_app, Blueprint, Flask
@ -25,7 +26,6 @@ def rpc_index():
@rpc.route('/refresh') @rpc.route('/refresh')
def rpc_refresh(): def rpc_refresh():
print current_app.queue
send_to_parent('rpc') send_to_parent('rpc')
return 'ok, put' return 'ok, put'

View file

@ -5,7 +5,6 @@ monkey.patch_all(subprocess=True)
import pytest import pytest
import gevent import gevent
from gevent.queue import Queue
from mpc import Timer, ParentedLet from mpc import Timer, ParentedLet
@ -13,12 +12,6 @@ from mpc import Timer, ParentedLet
# messages on the queue # messages on the queue
@pytest.fixture
def queue():
print('fixture q')
return Queue()
@pytest.fixture @pytest.fixture
def range_parentlet(): def range_parentlet():
class RangeLet(ParentedLet): class RangeLet(ParentedLet):

18
test_web.py Normal file
View file

@ -0,0 +1,18 @@
from __future__ import print_function
from gevent import monkey
monkey.patch_all(subprocess=True)
import pytest
from rpc import create_app
@pytest.fixture
def app(queue):
return create_app(queue)
def test_refresh(app):
assert app.queue.empty()
app.test_client().get('/api/refresh')
assert not app.queue.empty()