File size: 3,332 Bytes
9c9268b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""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"