summaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-28 16:13:20 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-28 16:13:20 -0700
commit1855e07ea846126bc27b1419f104a024d78623c7 (patch)
tree2958d839c9840091db3949993162eb8ed1db0ebe /python/tests
parentf3c9fa0a311dc5413c4964d6183004bff6a5783a (diff)
downloadfatcat-1855e07ea846126bc27b1419f104a024d78623c7.tar.gz
fatcat-1855e07ea846126bc27b1419f104a024d78623c7.zip
refactor python web interface to work with API backend
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/api_client.py5
-rw-r--r--python/tests/fixtures.py21
-rw-r--r--python/tests/routes.py43
3 files changed, 45 insertions, 24 deletions
diff --git a/python/tests/api_client.py b/python/tests/api_client.py
index 37e3da56..9d2ec302 100644
--- a/python/tests/api_client.py
+++ b/python/tests/api_client.py
@@ -4,8 +4,9 @@ import fatcat.api_client
from fixtures import *
-def test_client_health(api_client):
- assert api_client.health() != None
+# TODO:
+#def test_client_health(api_client):
+# assert api_client.health() != None
def test_import_crossref(api_client):
diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py
index 9092421f..b1682e79 100644
--- a/python/tests/fixtures.py
+++ b/python/tests/fixtures.py
@@ -21,15 +21,18 @@ def app(full_app):
@pytest.fixture(scope="function")
def api_client(full_app):
- pid = os.fork()
- if pid == 0:
- full_app.testing = False
- full_app.run(host="localhost", port=8444, debug=False)
- os._exit(0)
-
- time.sleep(0.2)
- yield fatcat.api_client.FatCatApiClient("http://localhost:8444")
- os.kill(pid, signal.SIGKILL)
+ # TODO:
+ #pid = os.fork()
+ #if pid == 0:
+ # full_app.testing = False
+ # full_app.run(host="localhost", port=8444, debug=False)
+ # os._exit(0)
+ #
+ #time.sleep(0.2)
+ #yield fatcat.api_client.FatCatApiClient("http://localhost:8444")
+ #os.kill(pid, signal.SIGKILL)
+
+ yield fatcat.api_client.FatCatApiClient("http://localhost:9411")
## Helpers ##################################################################
diff --git a/python/tests/routes.py b/python/tests/routes.py
index 80eb15fe..e11d024e 100644
--- a/python/tests/routes.py
+++ b/python/tests/routes.py
@@ -3,6 +3,7 @@ import json
import tempfile
import pytest
import fatcat
+from fatcat_client.rest import ApiException
from fixtures import *
@@ -17,12 +18,32 @@ def test_static_routes(app):
def test_all_views(app):
for route in ('work', 'release', 'creator', 'container', 'file'):
print(route)
- rv = app.get('/{}/1'.format(route))
- assert rv.status_code == 200
+ #with pytest.raises(ApiException) as api_fail:
+ # rv = app.get('/{}/999999999999'.format(route))
+ rv = app.get('/{}/9999999999'.format(route))
+ assert rv.status_code == 400
- rv = app.get('/{}/999999999999'.format(route))
+ rv = app.get('/{}/f1f046a3-45c9-ffff-ffff-ffffffffffff'.format(route))
assert rv.status_code == 404
+ rv = app.get('/{}/random'.format(route))
+ assert rv.status_code == 302
+
+ rv = app.get('/container/00000000-0000-0000-1111-000000000002'.format(route))
+ assert rv.status_code == 200
+
+ rv = app.get('/creator/00000000-0000-0000-2222-000000000002'.format(route))
+ assert rv.status_code == 200
+
+ rv = app.get('/file/00000000-0000-0000-3333-000000000002'.format(route))
+ assert rv.status_code == 200
+
+ rv = app.get('/release/00000000-0000-0000-4444-000000000002'.format(route))
+ assert rv.status_code == 200
+
+ rv = app.get('/work/00000000-0000-0000-5555-000000000002'.format(route))
+ assert rv.status_code == 200
+
rv = app.get('/work/random')
rv = app.get(rv.location)
assert rv.status_code == 200
@@ -36,26 +57,22 @@ def test_all_views(app):
rv = app.get('/release/random')
assert rv.status_code == 302
- rv = app.get('/release/1/changelog')
- assert rv.status_code == 200
+ #rv = app.get('/release/00000000-0000-0000-4444-000000000002/changelog')
+ #assert rv.status_code == 200
rv = app.get('/editgroup/1')
assert rv.status_code == 200
rv = app.get('/editgroup/99999999')
+ print(rv)
+ print(rv.data)
assert rv.status_code == 404
- rv = app.get('/editgroup/current')
- assert rv.status_code == 302
+ #rv = app.get('/editgroup/current')
+ #assert rv.status_code == 302
rv = app.get('/editor/admin')
assert rv.status_code == 200
- rv = app.get('/editor/bizzaro')
- assert rv.status_code == 404
-
rv = app.get('/editor/admin/changelog')
assert rv.status_code == 200
-
- rv = app.get('/editor/bizarro/changelog')
- assert rv.status_code == 404