From 4625d82d600d3c8e065f40c726e214530258288b Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 12 Aug 2024 17:03:30 -0400 Subject: [PATCH 1/2] BF: use correct variable bug likely introduced during refactoring in a62fe7df0a33399b46fe65919c7456eccf5c3aec Closes https://github.com/dandi/dandi-cli/issues/1481 --- dandi/metadata/util.py | 2 +- dandi/tests/test_metadata.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dandi/metadata/util.py b/dandi/metadata/util.py index d3f8f95b4..23f82b247 100644 --- a/dandi/metadata/util.py +++ b/dandi/metadata/util.py @@ -474,7 +474,7 @@ def extract_species(metadata: dict) -> models.SpeciesType | None: break if value_id is None: raise ValueError( - f"Cannot interpret species field: {value}. Please " + f"Cannot interpret species field: {value_orig}. Please " "contact help@dandiarchive.org to add your species. " "You can also put the entire url from NCBITaxon " "(http://www.ontobee.org/ontology/NCBITaxon) into " diff --git a/dandi/tests/test_metadata.py b/dandi/tests/test_metadata.py index 8c5229bd9..4c2d1e925 100644 --- a/dandi/tests/test_metadata.py +++ b/dandi/tests/test_metadata.py @@ -513,6 +513,12 @@ def test_species(): } +def test_extract_unknown_species(): + with pytest.raises(ValueError) as excinfo: + extract_species({"species": "mumba-jumba"}) + assert str(excinfo.value).startswith("Cannot interpret") + + def test_species_map(): # all alternative names should be lower case for common_names, *_ in species_map: From a3031221caa29e8f0adecfd27c69c73d8dec6f44 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 12 Aug 2024 17:25:43 -0400 Subject: [PATCH 2/2] Test also for including the value Co-authored-by: John T. Wodder II --- dandi/tests/test_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dandi/tests/test_metadata.py b/dandi/tests/test_metadata.py index 4c2d1e925..415658e0e 100644 --- a/dandi/tests/test_metadata.py +++ b/dandi/tests/test_metadata.py @@ -516,7 +516,7 @@ def test_species(): def test_extract_unknown_species(): with pytest.raises(ValueError) as excinfo: extract_species({"species": "mumba-jumba"}) - assert str(excinfo.value).startswith("Cannot interpret") + assert str(excinfo.value).startswith("Cannot interpret species field: mumba-jumba") def test_species_map():