diff options
author | Martin Czygan <martin@archive.org> | 2021-04-15 14:11:09 +0000 |
---|---|---|
committer | Martin Czygan <martin@archive.org> | 2021-04-15 14:11:09 +0000 |
commit | b27c43071ab021e9595457999359009cfd7a1abb (patch) | |
tree | e00199889528c00f777f5bbc908d0962760fb96f /tests/test_simple.py | |
parent | 8a17311c9516e63aeb31111647fdf21083bcf928 (diff) | |
parent | d44a9e421edfec2cac16048b67e6809cae8cdd18 (diff) | |
download | fuzzycat-b27c43071ab021e9595457999359009cfd7a1abb.tar.gz fuzzycat-b27c43071ab021e9595457999359009cfd7a1abb.zip |
Merge branch 'bnewbold-upstreaming' into 'master'
refactoring/upstreaming fuzzycat "live" matching helpers
See merge request webgroup/fuzzycat!2
Diffstat (limited to 'tests/test_simple.py')
-rw-r--r-- | tests/test_simple.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_simple.py b/tests/test_simple.py new file mode 100644 index 0000000..0c5d216 --- /dev/null +++ b/tests/test_simple.py @@ -0,0 +1,42 @@ +""" +These basically all hit external network services. +""" + +import pytest +import elasticsearch + +from fuzzycat.simple import * +from fuzzycat.config import settings + + +@pytest.fixture +def es_client(): + return elasticsearch.Elasticsearch( + [settings.get("FATCAT_SEARCH_URL", "https://search.fatcat.wiki:443")]) + + +def test_close_fuzzy_unstructured_matches(es_client): + + matches = close_fuzzy_unstructured_matches( + """Cunningham HB, Weis JJ, Taveras LR, Huerta S. Mesh migration following abdominal hernia repair: a comprehensive review. Hernia. 2019 Apr;23(2):235-243. doi: 10.1007/s10029-019-01898-9. Epub 2019 Jan 30. PMID: 30701369.""", + es_client=es_client) + + assert matches + assert matches[0].status.name == "EXACT" + assert matches[0].release.ext_ids.doi == "10.1007/s10029-019-01898-9" + + +def test_close_fuzzy_biblio_matches(es_client): + + matches = close_fuzzy_biblio_matches(dict( + title="Mesh migration following abdominal hernia repair: a comprehensive review", + first_author="Cunningham", + year=2019, + journal="Hernia", + ), + es_client=es_client) + + assert matches + # TODO: should be "STRONG" or "WEAK" without all authors? + assert matches[0].status.name in ("STRONG", "WEAK", "AMBIGUOUS") + assert matches[0].release.ext_ids.doi == "10.1007/s10029-019-01898-9" |