summaryrefslogtreecommitdiffstats
path: root/python/tests/web_refs.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-08-06 11:58:16 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-08-06 11:58:16 -0700
commit99885b458ad505ebb63b3e7cf5b1bae3dd2a459e (patch)
treede3fbb3e42b0bb7f6e447d2e13ac3f92a8bb90b2 /python/tests/web_refs.py
parent950d3f08bd439aed92d01dbc3cca9747570aa82c (diff)
parent56e4ce2d8347cdfedd492d54fde080772f3d8725 (diff)
downloadfatcat-99885b458ad505ebb63b3e7cf5b1bae3dd2a459e.tar.gz
fatcat-99885b458ad505ebb63b3e7cf5b1bae3dd2a459e.zip
Merge branch 'bnewbold-refs-apis'
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
+