aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/fixtures.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-07-24 13:00:04 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-07-30 18:28:03 -0700
commit1f6f9c0e251f45f220dd48242d48fa61922fe55f (patch)
tree41a85d22339279c6bc29661e3541f2696d580f23 /python/tests/fixtures.py
parent86c150edadad347df31393742c2de091ff21da83 (diff)
downloadfatcat-1f6f9c0e251f45f220dd48242d48fa61922fe55f.tar.gz
fatcat-1f6f9c0e251f45f220dd48242d48fa61922fe55f.zip
refactor coverage tests/mocks
Diffstat (limited to 'python/tests/fixtures.py')
-rw-r--r--python/tests/fixtures.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py
index 3263f243..d71ac21d 100644
--- a/python/tests/fixtures.py
+++ b/python/tests/fixtures.py
@@ -8,13 +8,53 @@ import fatcat_openapi_client
from fatcat_openapi_client import *
from fatcat_tools import authenticated_api
+
+ES_CONTAINER_STATS_RESP = {
+ 'timed_out': False,
+ 'aggregations': {
+ 'container_stats': {'buckets': {
+ 'is_preserved': {'doc_count': 461939},
+ 'in_kbart': {'doc_count': 461939},
+ 'in_web': {'doc_count': 2797},
+ }},
+ 'preservation': {
+ 'buckets': [
+ {'key': 'bright', 'doc_count': 444},
+ {'key': 'dark', 'doc_count': 111},
+ ],
+ 'sum_other_doc_count': 0,
+ },
+ 'release_type': {
+ 'buckets': [
+ {'key': 'article-journal', 'doc_count': 456},
+ {'key': 'book', 'doc_count': 123},
+ ],
+ 'sum_other_doc_count': 0,
+ },
+ },
+ 'hits': {'total': 461939, 'hits': [], 'max_score': 0.0},
+ '_shards': {'successful': 5, 'total': 5, 'skipped': 0, 'failed': 0},
+ 'took': 50
+}
+
+# TODO: this should not be empty
+ES_CONTAINER_RANDOM_RESP = {
+ 'timed_out': False,
+ 'hits': {'total': 461939, 'hits': [], 'max_score': 0.0},
+ '_shards': {'successful': 5, 'total': 5, 'skipped': 0, 'failed': 0},
+ 'took': 50
+}
+
@pytest.fixture
-def full_app():
+def full_app(mocker):
load_dotenv(dotenv_path="./example.env")
fatcat_web.app.testing = True
fatcat_web.app.debug = False
fatcat_web.app.config['WTF_CSRF_ENABLED'] = False
+
+ # mock out ES client requests, so they at least fail fast
fatcat_web.app.es_client = elasticsearch.Elasticsearch("mockbackend")
+ mocker.patch('elasticsearch.connection.Urllib3HttpConnection.perform_request')
return fatcat_web.app
@pytest.fixture