Spaces:
Running
Running
File size: 1,632 Bytes
1e732dd | 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 | """
Tests for src/services/biomarker/service.py — production biomarker validation.
"""
import pytest
from src.services.biomarker.service import BiomarkerService, ValidationReport
@pytest.fixture
def service():
return BiomarkerService()
def test_validate_known_biomarkers(service: BiomarkerService):
"""Should validate known biomarkers correctly."""
report = service.validate({"Glucose": 185.0, "HbA1c": 8.2})
assert isinstance(report, ValidationReport)
assert report.recognized_count >= 1
# At least one result should exist
assert len(report.results) >= 1
def test_validate_critical_generates_alert(service: BiomarkerService):
"""Critically abnormal values should generate safety alerts."""
# Glucose < 40 or > 500 should be critical
report = service.validate({"Glucose": 550.0})
if report.recognized_count > 0:
critical = [r for r in report.results if r.status.startswith("CRITICAL")]
# If the validator flags it as critical, there should be alerts
if critical:
assert len(report.safety_alerts) > 0
def test_validate_unrecognized(service: BiomarkerService):
"""Unknown biomarker names should be listed as unrecognized."""
report = service.validate({"FakeMarkerXYZ": 42.0})
assert "FakeMarkerXYZ" in report.unrecognized
assert report.recognized_count == 0
def test_list_supported(service: BiomarkerService):
"""Should return a list of supported biomarkers."""
supported = service.list_supported()
assert isinstance(supported, list)
# We know the validator has 24 biomarkers
assert len(supported) >= 20
|