feat: complete production hardening implementation, specialty canonicalization, google-genai migration, voice reliability, sqlite concurrency, and test suite consolidation
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
Consolidated Automated Tests from root-level scripts.
|
||||
Covers:
|
||||
- Direct symptom classification for all supported specialties
|
||||
- Auto-specialty triage rules and canonical output checks
|
||||
- Offline AI provider interface and configuration contracts
|
||||
"""
|
||||
import pytest
|
||||
from app.ai.orchestrator import classify_specialty_from_symptoms
|
||||
from app.specialties.registry import get_specialty_config, SPECIALTIES, CANONICAL_ALIASES
|
||||
|
||||
|
||||
def test_direct_symptom_classifier_all_specialties():
|
||||
"""Consolidated test derived from test_direct_classifier.py & test_auto_specialty.py."""
|
||||
test_cases = [
|
||||
("Cardiology", "Chest pain and shortness of breath", "cardiology"),
|
||||
("Dermatology", "Skin rash and severe itching", "dermatology"),
|
||||
("Orthopedics", "Knee joint pain and swelling", "orthopedics"),
|
||||
("Neurology", "Headache and dizziness for 3 days", "neurology"),
|
||||
("Gastroenterology", "Stomach pain and vomiting", "gastroenterology"),
|
||||
("Pulmonology", "Cough and phlegm for 4 days", "pulmonology"),
|
||||
("Diabetology", "High blood sugar and insulin history", "diabetology"),
|
||||
("Mental Health", "Depression and panic attacks", "mental_health"),
|
||||
("General", "Feverish and weakness", "general"),
|
||||
]
|
||||
|
||||
for label, text, expected_code in test_cases:
|
||||
res = classify_specialty_from_symptoms(text)
|
||||
assert res["code"] == expected_code, f"Failed for {label}: expected '{expected_code}', got '{res['code']}'"
|
||||
|
||||
|
||||
def test_registry_canonical_aliases():
|
||||
"""Verify alias mapping for legacy codes."""
|
||||
assert get_specialty_config("general_medicine")["code"] == "general"
|
||||
assert get_specialty_config("psychiatry")["code"] == "mental_health"
|
||||
|
||||
|
||||
def test_all_canonical_specialties_registered():
|
||||
"""Ensure all required canonical specialties have active, valid configs."""
|
||||
required = {
|
||||
"general",
|
||||
"mental_health",
|
||||
"diabetology",
|
||||
"cardiology",
|
||||
"dermatology",
|
||||
"neurology",
|
||||
"orthopedics",
|
||||
"gastroenterology",
|
||||
"pulmonology",
|
||||
}
|
||||
registered = set(SPECIALTIES.keys())
|
||||
assert required.issubset(registered), f"Missing registered specialties: {required - registered}"
|
||||
Reference in New Issue
Block a user