summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/fatcat_tools/importers/common.py6
-rw-r--r--python/tests/import_common.py4
2 files changed, 5 insertions, 5 deletions
diff --git a/python/fatcat_tools/importers/common.py b/python/fatcat_tools/importers/common.py
index 1cce5fd0..6dc2ab9e 100644
--- a/python/fatcat_tools/importers/common.py
+++ b/python/fatcat_tools/importers/common.py
@@ -446,13 +446,13 @@ class EntityImporter:
existing.urls = [u for u in existing.urls if u.url not in redundant_urls]
return existing
- def match_existing_release_fuzzy(self, release: ReleaseEntity) -> Optional[Tuple[str, ReleaseEntity]]:
+ def match_existing_release_fuzzy(self, release: ReleaseEntity) -> Optional[Tuple[str, str, ReleaseEntity]]:
"""
This helper function uses fuzzycat (and elasticsearch) to look for
existing release entities with similar metadata.
Returns None if there was no match of any kind, or a single tuple
- (status: str, existing: ReleaseEntity) if there was a match.
+ (status: str, reason: str, existing: ReleaseEntity) if there was a match.
Status string is one of the fuzzycat.common.Status, with "strongest
match" in this sorted order:
@@ -491,7 +491,7 @@ class EntityImporter:
elif closest[0].status == fuzzycat.common.Status.TODO:
raise NotImplementedError("fuzzycat verify hit a Status.TODO")
else:
- return (closest[0].status.name, closest[1])
+ return (closest[0].status.name, closest[0].reason.value, closest[1])
class RecordPusher:
diff --git a/python/tests/import_common.py b/python/tests/import_common.py
index 9f04ebe0..d0db014e 100644
--- a/python/tests/import_common.py
+++ b/python/tests/import_common.py
@@ -63,11 +63,11 @@ def test_fuzzy_match_different(entity_importer, mocker) -> None:
match_raw = mocker.patch('fatcat_tools.importers.common.match_release_fuzzy')
match_raw.side_effect = [[r3, r2, r3, r2]]
resp = entity_importer.match_existing_release_fuzzy(r1)
- assert resp == ("STRONG", r2)
+ assert (resp[0], resp[2]) == ("STRONG", r2)
match_raw.side_effect = [[r2, r2, r3, r1]]
resp = entity_importer.match_existing_release_fuzzy(r1)
- assert resp == ("EXACT", r1)
+ assert (resp[0], resp[2]) == ("EXACT", r1)
match_raw.side_effect = [[r3]]
resp = entity_importer.match_existing_release_fuzzy(r1)