From 7a701662c17467a9eb3402cf8641a7dd15f5ad1c Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 13 Apr 2021 17:13:55 -0700 Subject: make fmt --- tests/test_utils.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_utils.py b/tests/test_utils.py index 24be9d1..381c44e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -99,11 +99,22 @@ def test_zstdlines(): with open(fn) as f: assert [s.strip() for s in f.readlines()] == list(zstdlines(zfn)) + def test_es_compat_hits_total(): cases = ( - ({"hits": {"total": 6}}, 6), - ({"hits": {"total": {"value": 7, "relation": "eq"}}}, 7), + ({ + "hits": { + "total": 6 + } + }, 6), + ({ + "hits": { + "total": { + "value": 7, + "relation": "eq" + } + } + }, 7), ) for r, expected in cases: assert es_compat_hits_total(r) == expected - -- cgit v1.2.3 From 79b6476827f80ed86019804b7293ff1a8fd4af9a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 13 Apr 2021 17:57:58 -0700 Subject: dynaconf: switch to fuzzycat.config import across project This is the recommended way to use dynaconf. --- fuzzycat/config.py | 4 ++++ fuzzycat/matching.py | 2 +- tests/test_matching.py | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 fuzzycat/config.py (limited to 'tests') diff --git a/fuzzycat/config.py b/fuzzycat/config.py new file mode 100644 index 0000000..61050d1 --- /dev/null +++ b/fuzzycat/config.py @@ -0,0 +1,4 @@ + +from dynaconf import Dynaconf + +settings = Dynaconf(envvar_prefix="FUZZYCAT") diff --git a/fuzzycat/matching.py b/fuzzycat/matching.py index 9ccb62b..55a5833 100644 --- a/fuzzycat/matching.py +++ b/fuzzycat/matching.py @@ -13,8 +13,8 @@ from fatcat_openapi_client.rest import ApiException from fuzzycat.entities import entity_from_dict, entity_from_json from fuzzycat.utils import es_compat_hits_total +from fuzzycat.config import settings -settings = Dynaconf(envvar_prefix="FUZZYCAT") FATCAT_API_URL = settings.get("FATCAT_API_URL", "https://api.fatcat.wiki/v0") diff --git a/tests/test_matching.py b/tests/test_matching.py index 7d8b7af..56999e6 100644 --- a/tests/test_matching.py +++ b/tests/test_matching.py @@ -1,14 +1,13 @@ from fuzzycat.matching import anything_to_entity, match_release_fuzzy +from fuzzycat.config import settings from fatcat_openapi_client import ReleaseEntity import pytest import elasticsearch import logging -from dynaconf import Dynaconf logger = logging.getLogger('test_matching') logger.setLevel(logging.DEBUG) -settings = Dynaconf(envvar_prefix="FUZZYCAT") FATCAT_SEARCH_URL = settings.get("FATCAT_SEARCH_URL", "https://search.fatcat.wiki:443") -- cgit v1.2.3