aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/web_refs.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/tests/web_refs.py')
-rw-r--r--python/tests/web_refs.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/python/tests/web_refs.py b/python/tests/web_refs.py
new file mode 100644
index 00000000..bceb8557
--- /dev/null
+++ b/python/tests/web_refs.py
@@ -0,0 +1,54 @@
+
+import json
+import pytest
+
+from fatcat_web.search import get_elastic_container_random_releases
+from fatcat_openapi_client.rest import ApiException
+from fixtures import *
+
+
+def test_basic_refs(app, mocker):
+
+ with open('tests/files/elastic_refs_in_release.json') as f:
+ elastic_resp_in = json.loads(f.read())
+ with open('tests/files/elastic_refs_out_release.json') as f:
+ elastic_resp_out = json.loads(f.read())
+ with open('tests/files/elastic_empty.json') as f:
+ elastic_resp_empty = json.loads(f.read())
+
+ es_raw = mocker.patch('elasticsearch.connection.Urllib3HttpConnection.perform_request')
+ es_raw.side_effect = [
+ (200, {}, json.dumps(elastic_resp_in)),
+ (200, {}, json.dumps(elastic_resp_in)),
+ (200, {}, json.dumps(elastic_resp_empty)),
+ (200, {}, json.dumps(elastic_resp_out)),
+ (200, {}, json.dumps(elastic_resp_out)),
+ (200, {}, json.dumps(elastic_resp_empty)),
+ ]
+
+ # render refs-in
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/refs-in')
+ assert rv.status_code == 200
+ assert b"Why Most Published Research Findings Are False" in rv.data
+
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/refs-in.json')
+ assert rv.status_code == 200
+
+ # empty (in)
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/refs-in')
+ assert rv.status_code == 200
+ assert b"No References Found" in rv.data
+
+ # render refs-out
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/refs-out')
+ assert rv.status_code == 200
+ assert b"Why Most Published Research Findings Are False" in rv.data
+
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/refs-out.json')
+ assert rv.status_code == 200
+
+ # empty (out)
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/refs-out')
+ assert rv.status_code == 200
+ assert b"No References Found" in rv.data
+