aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/fixtures.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2021-11-02 18:13:14 -0700
committerBryan Newbold <bnewbold@robocracy.org>2021-11-02 18:13:14 -0700
commitcdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7 (patch)
tree5e4034027b51f3ee4d2a488bb2cbb7a75c3bd0d8 /python/tests/fixtures.py
parent78f08280edea4ff65ca613ad30005c45cc48dea6 (diff)
downloadfatcat-cdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7.tar.gz
fatcat-cdfd6b85b386b7bbf9d5a5179ef26970b6e5a4e7.zip
fmt (black): tests/
Diffstat (limited to 'python/tests/fixtures.py')
-rw-r--r--python/tests/fixtures.py75
1 files changed, 41 insertions, 34 deletions
diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py
index a9b81bda..0950087f 100644
--- a/python/tests/fixtures.py
+++ b/python/tests/fixtures.py
@@ -1,4 +1,3 @@
-
import elasticsearch
import fatcat_openapi_client
import pytest
@@ -9,73 +8,77 @@ import fatcat_web
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},
+ "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,
+ "sum_other_doc_count": 0,
},
- 'release_type': {
- 'buckets': [
- {'key': 'article-journal', 'doc_count': 456},
- {'key': 'book', 'doc_count': 123},
+ "release_type": {
+ "buckets": [
+ {"key": "article-journal", "doc_count": 456},
+ {"key": "book", "doc_count": 123},
],
- 'sum_other_doc_count': 0,
+ "sum_other_doc_count": 0,
},
},
- 'hits': {'total': 461939, 'hits': [], 'max_score': 0.0},
- '_shards': {'successful': 5, 'total': 5, 'skipped': 0, 'failed': 0},
- 'took': 50
+ "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
+ "timed_out": False,
+ "hits": {"total": 461939, "hits": [], "max_score": 0.0},
+ "_shards": {"successful": 5, "total": 5, "skipped": 0, "failed": 0},
+ "took": 50,
}
ES_RELEASE_EMPTY_RESP = {
- 'timed_out': False,
- 'hits': {'total': 0, 'hits': [], 'max_score': 0.0},
- '_shards': {'successful': 5, 'total': 5, 'skipped': 0, 'failed': 0},
- 'took': 50
+ "timed_out": False,
+ "hits": {"total": 0, "hits": [], "max_score": 0.0},
+ "_shards": {"successful": 5, "total": 5, "skipped": 0, "failed": 0},
+ "took": 50,
}
+
@pytest.fixture
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
+ 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')
+ mocker.patch("elasticsearch.connection.Urllib3HttpConnection.perform_request")
return fatcat_web.app
+
@pytest.fixture
def app(full_app):
return full_app.test_client()
+
@pytest.fixture
def app_admin(app):
ADMIN_DEV_TOKEN = "AgEPZGV2LmZhdGNhdC53aWtpAhYyMDE5MDEwMS1kZXYtZHVtbXkta2V5AAImZWRpdG9yX2lkID0gYWFhYWFhYWFhYWFhYmt2a2FhYWFhYWFhYWkAAht0aW1lID4gMjAxOS0wNC0wNFQyMzozMjo0NloAAAYgrN3jjy0mgEqIydTFfsOLYSS55dz6Fh2d1CGMNQFLwcQ="
- rv = app.post('/auth/token_login',
- data=dict(token=ADMIN_DEV_TOKEN),
- follow_redirects=True)
+ rv = app.post("/auth/token_login", data=dict(token=ADMIN_DEV_TOKEN), follow_redirects=True)
assert rv.status_code == 200
return app
+
@pytest.fixture
def api():
load_dotenv(dotenv_path="./example.env")
@@ -83,6 +86,7 @@ def api():
api_client.editor_id = "aaaaaaaaaaaabkvkaaaaaaaaae"
return api_client
+
@pytest.fixture
def api_dummy_entities(api):
"""
@@ -121,13 +125,16 @@ def api_dummy_entities(api):
"work": w1,
}
+
def test_get_changelog_entry(api):
"""Check that fixture is working"""
cl = api.get_changelog_entry(1)
assert cl
+
## Helpers ##################################################################
+
def quick_eg(api_inst):
eg = api_inst.create_editgroup(fatcat_openapi_client.Editgroup())
return eg