Scribbled-docs-notes / tests /test_examples.py
Bonosa2's picture
Create test_examples.py
e4ff146 verified
raw
history blame
4.72 kB
import pytest
class TestExamples:
"""Test example medical notes and functionality"""
def test_example_notes_exist(self):
"""Test that example notes are properly defined"""
examples = {
'chest_pain': """Patient: John Smith, 45-year-old male
Chief Complaint: Chest pain for 2 hours
History: Patient reports sudden onset of sharp chest pain while at work.
Pain is 7/10 intensity, located substernal, radiating to left arm.""",
'diabetes': """Patient: Maria Garcia, 52-year-old female
Chief Complaint: Increased thirst and frequent urination for 3 weeks
History: Patient reports polyuria, polydipsia, and unintentional weight loss.""",
'pediatric': """Patient: Emma Thompson, 8-year-old female
Chief Complaint: Fever and sore throat for 2 days
History: Mother reports fever up to 102°F, sore throat, difficulty swallowing."""
}
assert 'chest_pain' in examples
assert 'diabetes' in examples
assert 'pediatric' in examples
for key, example in examples.items():
assert len(example.strip()) > 50 # Ensure examples have substance
assert "Patient:" in example
assert "Chief Complaint:" in example
def test_example_loading(self):
"""Test example loading functionality"""
def mock_load_example(example_key):
examples = {
'chest_pain': "Chest pain example loaded",
'diabetes': "Diabetes example loaded",
'pediatric': "Pediatric example loaded"
}
return examples.get(example_key, "Example not found")
assert mock_load_example('chest_pain') == "Chest pain example loaded"
assert mock_load_example('diabetes') == "Diabetes example loaded"
assert mock_load_example('pediatric') == "Pediatric example loaded"
assert mock_load_example('invalid_key') == "Example not found"
def test_example_content_quality(self):
"""Test that examples contain required medical information"""
examples = {
'chest_pain': """Patient: John Smith, 45-year-old male
Chief Complaint: Chest pain for 2 hours
History: Sharp chest pain, 7/10 intensity
Physical Exam: VS: BP 150/90, HR 110
Assessment: Acute chest pain
Plan: EKG, cardiac enzymes""",
'diabetes': """Patient: Maria Garcia, 52-year-old female
Chief Complaint: Increased thirst and urination
History: Polyuria, polydipsia, weight loss
Physical Exam: VS: BP 140/85, BMI 28
Assessment: New onset diabetes
Plan: HbA1c, glucose, metformin""",
'pediatric': """Patient: Emma Thompson, 8-year-old female
Chief Complaint: Fever and sore throat
History: Fever 102°F, sore throat, decreased appetite
Physical Exam: Throat erythematous, lymphadenopathy
Assessment: Streptococcal pharyngitis
Plan: Rapid strep test, amoxicillin"""
}
for key, example in examples.items():
# Check for essential medical note components
assert "Patient:" in example
assert "Chief Complaint:" in example
assert "History:" in example or "Physical Exam:" in example
assert "Assessment:" in example
assert "Plan:" in example
# Check for age and gender
assert any(age in example for age in ['year-old', 'yo', 'years old'])
assert any(gender in example for gender in ['male', 'female'])
def test_example_button_handlers(self):
"""Test example button click handlers"""
def mock_example_click_handler(example_text):
def handler():
return f"Loaded: {example_text[:20]}..."
return handler
# Test each example handler
examples = {
'chest_pain': "Chest pain example text",
'diabetes': "Diabetes example text",
'pediatric': "Pediatric example text"
}
for key, text in examples.items():
handler = mock_example_click_handler(text)
result = handler()
assert "Loaded:" in result
assert text[:20] in result
def test_clear_functionality(self):
"""Test clear button functionality"""
def mock_clear_handler():
return {
'notes_input': '',
'file_upload': None,
'output_area': 'Ready to generate SOAP notes!'
}
result = mock_clear_handler()
assert result['notes_input'] == ''
assert result['file_upload'] is None
assert 'Ready to generate' in result['output_area']