aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-07-28 11:34:09 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-07-30 18:28:03 -0700
commite41c4073103c8df070843af54541127ee9f55981 (patch)
tree7bbd2308b5918fdbde3326f7e129c9cbd7abeb1f /python/tests
parent241259da5fbda87b93f18d85d180b4829312b3bc (diff)
downloadfatcat-e41c4073103c8df070843af54541127ee9f55981.tar.gz
fatcat-e41c4073103c8df070843af54541127ee9f55981.zip
coverage search: 'recent' endpoint test (minimal)
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/web_coverage.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/python/tests/web_coverage.py b/python/tests/web_coverage.py
index d446fba6..4407934f 100644
--- a/python/tests/web_coverage.py
+++ b/python/tests/web_coverage.py
@@ -1,6 +1,7 @@
import json
import pytest
+import datetime
from fatcat_openapi_client.rest import ApiException
from fixtures import *
@@ -123,18 +124,48 @@ def test_coverage_search(app, mocker):
},
}
+ # preservation by date histogram
+ today = str(datetime.date.today())
+ elastic_resp3 = {
+ 'took': 294,
+ 'timed_out': False,
+ '_shards': {'total': 5, 'successful': 5, 'skipped': 0, 'failed': 0},
+ 'hits': {'total': 4327, 'max_score': 0.0, 'hits': []},
+ 'aggregations': {
+ 'date_preservation': {
+ 'buckets': [
+ {'key': {'date': f'{today}T00:00.000Z', 'preservation': 'bright'}, 'doc_count': 444},
+ {'key': {'date': f'{today}T00:00.000Z', 'preservation': 'dark'}, 'doc_count': 111},
+ ],
+ 'sum_other_doc_count': 0,
+ },
+ },
+ }
+
es_raw = mocker.patch('elasticsearch.connection.Urllib3HttpConnection.perform_request')
es_raw.side_effect = [
# counts summary
(200, {}, json.dumps(ES_CONTAINER_STATS_RESP)),
+ # by type
+ (200, {}, json.dumps(elastic_resp2)),
# by year
(200, {}, json.dumps(elastic_resp1)),
+ ]
+
+ rv = app.get('/coverage/search?q=*')
+ assert rv.status_code == 200
+
+ es_raw.side_effect = [
+ # counts summary
+ (200, {}, json.dumps(ES_CONTAINER_STATS_RESP)),
# by type
(200, {}, json.dumps(elastic_resp2)),
+ # by date
+ (200, {}, json.dumps(elastic_resp3)),
]
- rv = app.get('/coverage/search?q=*')
+ rv = app.get('/coverage/search?recent=1&q=*')
assert rv.status_code == 200