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..415658e0e 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 species field: mumba-jumba") + + def test_species_map(): # all alternative names should be lower case for common_names, *_ in species_map: