- Implemented `test_dose_parsing_simple.py` to validate the dose parsing workflow. - Created `test_dose_save.py` to verify the saving functionality of dose tracking. - Added `test_dose_save_simple.py` for programmatic testing of dose saving without UI interaction. - Developed `test_final_workflow.py` to test the complete dose tracking workflow, ensuring doses are preserved during edits. - Enhanced `conftest.py` with a mock pathology manager for testing. - Updated `test_data_manager.py` to include pathology manager in DataManager tests and ensure compatibility with new features.
95 lines
3.1 KiB
Python
95 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to validate the pathology management system.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Add src to path
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
|
|
|
from init import logger
|
|
from pathology_manager import Pathology, PathologyManager
|
|
|
|
|
|
def test_pathology_system():
|
|
"""Test the complete pathology system."""
|
|
print("🧪 Testing Pathology Management System...")
|
|
|
|
# Test 1: Initialize PathologyManager
|
|
print("\n1. Testing PathologyManager initialization...")
|
|
pathology_manager = PathologyManager("test_pathologies.json", logger)
|
|
pathologies = pathology_manager.get_all_pathologies()
|
|
print(f" ✅ Successfully loaded {len(pathologies)} pathologies")
|
|
|
|
for key, pathology in pathologies.items():
|
|
print(f" - {key}: {pathology.display_name} ({pathology.scale_info})")
|
|
|
|
# Test 2: Add a new pathology
|
|
print("\n2. Testing pathology addition...")
|
|
new_pathology = Pathology(
|
|
key="stress",
|
|
display_name="Stress Level",
|
|
scale_info="0:calm, 10:overwhelmed",
|
|
color="#9B59B6",
|
|
default_enabled=True,
|
|
scale_min=0,
|
|
scale_max=10,
|
|
scale_orientation="normal",
|
|
)
|
|
|
|
if pathology_manager.add_pathology(new_pathology):
|
|
print(" ✅ Successfully added Stress Level pathology")
|
|
updated_pathologies = pathology_manager.get_all_pathologies()
|
|
print(f" Now have {len(updated_pathologies)} pathologies")
|
|
else:
|
|
print(" ❌ Failed to add Stress Level pathology")
|
|
|
|
# Test 3: Test CSV headers with DataManager
|
|
print("\n3. Testing CSV headers generation...")
|
|
from data_manager import DataManager
|
|
from medicine_manager import MedicineManager
|
|
|
|
medicine_manager = MedicineManager("medicines.json", logger)
|
|
DataManager(
|
|
"test_pathologies_data.csv", logger, medicine_manager, pathology_manager
|
|
)
|
|
|
|
if os.path.exists("test_pathologies_data.csv"):
|
|
with open("test_pathologies_data.csv") as f:
|
|
headers = f.readline().strip()
|
|
print(f" CSV headers: {headers}")
|
|
os.remove("test_pathologies_data.csv") # Clean up
|
|
print(" ✅ CSV headers generated successfully")
|
|
|
|
# Test 4: Test pathology configuration methods
|
|
print("\n4. Testing pathology configuration methods...")
|
|
keys = pathology_manager.get_pathology_keys()
|
|
display_names = pathology_manager.get_display_names()
|
|
colors = pathology_manager.get_graph_colors()
|
|
enabled = pathology_manager.get_default_enabled_pathologies()
|
|
|
|
print(f" Keys: {keys}")
|
|
print(f" Display names: {display_names}")
|
|
print(f" Colors: {colors}")
|
|
print(f" Default enabled: {enabled}")
|
|
print(" ✅ All configuration methods working")
|
|
|
|
# Clean up test file
|
|
if os.path.exists("test_pathologies.json"):
|
|
os.remove("test_pathologies.json")
|
|
print("\n🧹 Cleaned up test files")
|
|
|
|
print("\n✅ All pathology system tests passed!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
test_pathology_system()
|
|
except Exception as e:
|
|
print(f"❌ Test failed with error: {e}")
|
|
import traceback
|
|
|
|
traceback.print_exc()
|