aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-04-14 23:00:07 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-04-14 23:00:07 +0200
commit1a096a775e13b8b2c6f90d706a5805cb047a6372 (patch)
tree1558d52cd780aaa3f03ac01268227951b2d6f49a
parent5e79faaa4e741ca15f9f12306a81496aaccc6705 (diff)
downloadfuzzycat-1a096a775e13b8b2c6f90d706a5805cb047a6372.tar.gz
fuzzycat-1a096a775e13b8b2c6f90d706a5805cb047a6372.zip
test: skip if configured search server is not reachable
-rw-r--r--tests/test_matching.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_matching.py b/tests/test_matching.py
index 48f7b3a..8d70d15 100644
--- a/tests/test_matching.py
+++ b/tests/test_matching.py
@@ -13,11 +13,25 @@ settings = Dynaconf(envvar_prefix="FUZZYCAT")
FATCAT_SEARCH_URL = settings.get("FATCAT_SEARCH_URL", "https://search.fatcat.wiki:443")
+def is_not_reachable(url, timeout=3):
+ return not is_reachable(url)
+
+def is_reachable(url, timeout=3):
+ """
+ Return true, if URL is reachable and returns HTTP 200.
+ """
+ try:
+ return requests.get(url, verify=False, timeout=timeout).ok
+ except Exception:
+ return False
+
@pytest.fixture
def es_client():
return elasticsearch.Elasticsearch([FATCAT_SEARCH_URL])
+@pytest.mark.skipif(is_not_reachable(FATCAT_SEARCH_URL),
+ reason="{} not reachable, use e.g. FUZZYCAT_FATCAT_SEARCH_URL=localhost:9200 to override".format(FATCAT_SEARCH_URL))
def test_match_release_fuzzy(es_client, caplog):
cases = (
("wtv64ahbdzgwnan7rllwr3nurm", 1),