aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-04-14 16:28:22 -0700
committerBryan Newbold <bnewbold@archive.org>2021-04-14 16:40:03 -0700
commitafe27a3480f45bfa4d13fce0ca7624cd37069434 (patch)
treeea04e3dcc47328349e53ab8a8ad5ccfb3b65ff2f /tests
parent567727e8606d2565098ddbcd63a1526aa44ff97f (diff)
downloadfuzzycat-afe27a3480f45bfa4d13fce0ca7624cd37069434.tar.gz
fuzzycat-afe27a3480f45bfa4d13fce0ca7624cd37069434.zip
add 'simple' high-level routines for fuzzy-match-and-verify calls
Some of these are a little redundant, in that calling code could trivially re-implement. However, I think these are good starters for stable external API interfaces, leaving us room to iterate and refactor lower-level implementations behind the scenes.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_simple.py42
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"