diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-11-16 21:13:46 +0100 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-11-16 21:13:46 +0100 |
commit | d104f8d0ba8eef5563555de82be66bbf17f961db (patch) | |
tree | 47ebb2ee3816b5d65bea0c184b8f8d733ea91681 /tests | |
parent | e90bc43b2052b70d86875f289115a0876be230cc (diff) | |
download | fuzzycat-d104f8d0ba8eef5563555de82be66bbf17f961db.tar.gz fuzzycat-d104f8d0ba8eef5563555de82be66bbf17f961db.zip |
complete migration from away from match_release_fuzzy
Instead, use `FuzzyReleaseMatcher.match`, which has approximately the
same behavior.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_matching.py | 82 |
1 files changed, 1 insertions, 81 deletions
diff --git a/tests/test_matching.py b/tests/test_matching.py index ca94c2a..a7754ee 100644 --- a/tests/test_matching.py +++ b/tests/test_matching.py @@ -8,12 +8,11 @@ import requests from fatcat_openapi_client import ReleaseEntity, ReleaseContrib from fuzzycat.entities import entity_from_dict, entity_from_json -from fuzzycat.matching import anything_to_entity, match_release_fuzzy, FuzzyReleaseMatcher +from fuzzycat.matching import anything_to_entity, FuzzyReleaseMatcher warnings.filterwarnings( "ignore") # InsecureRequestWarning: Unverified HTTPS request is being made to host ... -from fuzzycat.matching import anything_to_entity, match_release_fuzzy from fuzzycat.config import settings from fatcat_openapi_client import ReleaseEntity import pytest @@ -30,20 +29,6 @@ logger.setLevel(logging.DEBUG) 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 - - def yaml_to_cases(klass, files="tests/files/fuzzy_release_match_release_exact_title_exact_contrib/*.yaml"): """ @@ -63,71 +48,6 @@ 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): - """ - This test is tied to the current index contents, so if that changes, this - test may fail as well. - - Note: Deprecated. We want to get rid of this. - """ - cases = ( - ("wtv64ahbdzgwnan7rllwr3nurm", 1), - ("eqcgtpav3na5jh56o5vjsvb4ei", 1), - ) - for i, (ident, count) in enumerate(cases): - entity = anything_to_entity(ident, ReleaseEntity) - - result = match_release_fuzzy(entity, es=es_client) - logger.info("[{}] given {}, found {}".format(i, entity.title, len(result))) - assert len(result) == count - - # Partial data. - cases = ( - ({ - "title": "digital libraries", - "ext_ids": {} - }, 5), - ({ - "title": "unlikelytitle", - "ext_ids": {} - }, 0), - ({ - "title": "Imminent dystopia", - "ext_ids": {} - }, 2), - ({ - "title": "", - "contribs": [{ - "raw_name": "Aristoteles" - }], - "ext_ids": {} - }, 5), - # ({ - # "title": "Letter", - # "contribs": [{"raw_name": "Claudel"}], - # "ext_ids": {} - # }, 1), - # ({ - # "title": "The Future of Digital Scholarship", - # "contribs": [{ - # "raw_name": "Costantino Thanos" - # }], - # "ext_ids": {} - # }, 5), - ) - for i, (doc, count) in enumerate(cases): - entity = entity_from_dict(doc, ReleaseEntity) - result = match_release_fuzzy(entity, es=es_client) - with caplog.at_level(logging.INFO): - logging.info("[{}] given title '{}', found {}, {}".format(i, entity.title, len(result), - [v.title for v in result])) - assert len(result) == count, doc - - def test_matcher_match_release(es_client, caplog): cases = ( ("wtv64ahbdzgwnan7rllwr3nurm", 1), |