aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2020-12-23 03:31:03 +0100
committerMartin Czygan <martin.czygan@gmail.com>2020-12-23 03:31:03 +0100
commit42415e0e7b272de9006123ea983a5b6bb8c5b4a7 (patch)
tree7c878ff8a1d382acc177b5b4a33ee926c906646a
parent68dd0f00ff17ad9d2e1df2b28c1eb677bda4e450 (diff)
downloadfuzzycat-42415e0e7b272de9006123ea983a5b6bb8c5b4a7.tar.gz
fuzzycat-42415e0e7b272de9006123ea983a5b6bb8c5b4a7.zip
inject configuration
-rw-r--r--fuzzycat/matching.py6
-rw-r--r--tests/test_matching.py6
2 files changed, 10 insertions, 2 deletions
diff --git a/fuzzycat/matching.py b/fuzzycat/matching.py
index 13634e0..4573053 100644
--- a/fuzzycat/matching.py
+++ b/fuzzycat/matching.py
@@ -7,11 +7,15 @@ import elasticsearch
import elasticsearch_dsl
import fatcat_openapi_client
import requests
+from dynaconf import Dynaconf
from fatcat_openapi_client import ContainerEntity, DefaultApi, ReleaseEntity
from fatcat_openapi_client.rest import ApiException
from fuzzycat.entities import entity_from_dict, entity_from_json
+settings = Dynaconf(envvar_prefix="FUZZYCAT")
+FATCAT_API_URL = settings.get("FATCAT_API_URL", "https://api.fatcat.wiki/v0")
+
def match_release_fuzzy(
release: ReleaseEntity,
@@ -120,7 +124,7 @@ def retrieve_entity_list(
that are accessible.
"""
if api is None:
- api = public_api("https://api.fatcat.wiki/v0")
+ api = public_api(FATCAT_API_URL)
result = []
if entity_type == ReleaseEntity:
for id in ids:
diff --git a/tests/test_matching.py b/tests/test_matching.py
index 9601bcb..7d8b7af 100644
--- a/tests/test_matching.py
+++ b/tests/test_matching.py
@@ -3,14 +3,18 @@ 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")
+
@pytest.fixture
def es_client():
- return elasticsearch.Elasticsearch(["https://search.fatcat.wiki:443"])
+ return elasticsearch.Elasticsearch([FATCAT_SEARCH_URL])
@pytest.mark.skip(reason="we cannot use POST on es, which client uses: https://git.io/JLssk")