Spaces:
Sleeping
Sleeping
KevinIsInCoding
test(wave-2): add pure-function tests for models and prompts (#17)
9c9268b unverified | """Tests for prompts.py — lookup_disease_profile function.""" | |
| from __future__ import annotations | |
| import pytest | |
| from prompts import lookup_disease_profile | |
| class TestLookupDiseaseProfile: | |
| # --- exact full_name matches --- | |
| def test_exact_full_name(self): | |
| result = lookup_disease_profile("Amyotrophic Lateral Sclerosis") | |
| assert result is not None | |
| assert result["id"] == "als" | |
| def test_case_insensitive_full_name(self): | |
| result = lookup_disease_profile("amyotrophic lateral sclerosis") | |
| assert result is not None | |
| assert result["id"] == "als" | |
| def test_mixed_case_full_name(self): | |
| result = lookup_disease_profile("AMYOTROPHIC LATERAL SCLEROSIS") | |
| assert result is not None | |
| assert result["id"] == "als" | |
| # --- synonym matches --- | |
| def test_synonym_als(self): | |
| result = lookup_disease_profile("ALS") | |
| assert result is not None | |
| assert result["id"] == "als" | |
| def test_synonym_lou_gehrig(self): | |
| result = lookup_disease_profile("Lou Gehrig's disease") | |
| assert result is not None | |
| assert result["id"] == "als" | |
| def test_synonym_mnd(self): | |
| result = lookup_disease_profile("motor neuron disease") | |
| assert result is not None | |
| assert result["id"] == "als" | |
| # --- other diseases in registry --- | |
| def test_huntingtons_exact(self): | |
| result = lookup_disease_profile("Huntington's Disease") | |
| assert result is not None | |
| assert result["id"] == "huntingtons" | |
| def test_parkinsons_exact(self): | |
| result = lookup_disease_profile("Parkinson's Disease") | |
| assert result is not None | |
| assert result["id"] == "parkinsons" | |
| def test_sma_synonym(self): | |
| result = lookup_disease_profile("SMA") | |
| assert result is not None | |
| assert result["id"] == "sma" | |
| # --- partial containment fallback --- | |
| def test_partial_containment_als_in_longer_string(self): | |
| result = lookup_disease_profile("ALS (Amyotrophic Lateral Sclerosis)") | |
| assert result is not None | |
| assert result["id"] == "als" | |
| # --- unknown disease --- | |
| def test_unknown_disease_returns_none(self): | |
| assert lookup_disease_profile("Totally Unknown Rare Disease XYZ") is None | |
| def test_truly_unknown_disease_returns_none(self): | |
| # A name that shares no substring with any registered disease | |
| assert lookup_disease_profile("xyzzy-9999-zqj-unknown") is None | |
| # --- profile structure --- | |
| def test_profile_has_required_keys(self): | |
| result = lookup_disease_profile("Amyotrophic Lateral Sclerosis") | |
| assert result is not None | |
| assert "id" in result | |
| assert "full_name" in result | |
| assert "synonyms" in result | |
| assert "benchmarks" in result | |
| def test_benchmarks_is_list(self): | |
| result = lookup_disease_profile("Amyotrophic Lateral Sclerosis") | |
| assert isinstance(result["benchmarks"], list) | |
| def test_synonyms_is_list(self): | |
| result = lookup_disease_profile("Amyotrophic Lateral Sclerosis") | |
| assert isinstance(result["synonyms"], list) | |
| def test_whitespace_stripped(self): | |
| result = lookup_disease_profile(" Amyotrophic Lateral Sclerosis ") | |
| assert result is not None | |
| assert result["id"] == "als" | |