Browse Source

http testing

boyska 9 years ago
parent
commit
2bc118bfd9
4 changed files with 27 additions and 8 deletions
  1. 8 0
      conftest.py
  2. 1 1
      rpc.py
  3. 0 7
      test_parented.py
  4. 18 0
      test_web.py

+ 8 - 0
conftest.py

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

+ 1 - 1
rpc.py

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

+ 0 - 7
test_parented.py

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

+ 18 - 0
test_web.py

@@ -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()