Add medicine management functionality with UI and data handling
- Implemented MedicineManagementWindow for adding, editing, and removing medicines. - Created MedicineManager to handle medicine configurations, including loading and saving to JSON. - Updated UIManager to dynamically generate medicine-related UI components based on the MedicineManager. - Enhanced test suite with mock objects for MedicineManager to ensure proper functionality in DataManager tests. - Added validation for medicine input fields in the UI. - Introduced default medicine configurations for initial setup.
This commit is contained in:
42
scripts/test_medicine_manager.py
Normal file
42
scripts/test_medicine_manager.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple test to check if the medicine manager works correctly.
|
||||
"""
|
||||
|
||||
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 medicine_manager import MedicineManager
|
||||
|
||||
|
||||
def test_medicine_manager():
|
||||
"""Test the medicine manager functionality."""
|
||||
print("Testing MedicineManager...")
|
||||
|
||||
# Create medicine manager
|
||||
medicine_manager = MedicineManager(logger=logger)
|
||||
|
||||
# Test getting all medicines
|
||||
medicines = medicine_manager.get_all_medicines()
|
||||
print(f"Found {len(medicines)} medicines:")
|
||||
for key, medicine in medicines.items():
|
||||
print(f" - {key}: {medicine.display_name} ({medicine.dosage_info})")
|
||||
|
||||
# Test getting medicine keys
|
||||
keys = medicine_manager.get_medicine_keys()
|
||||
print(f"Medicine keys: {keys}")
|
||||
|
||||
# Test getting quick doses
|
||||
for key in keys:
|
||||
doses = medicine_manager.get_quick_doses(key)
|
||||
print(f"Quick doses for {key}: {doses}")
|
||||
|
||||
print("Medicine manager test completed successfully!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_medicine_manager()
|
||||
Reference in New Issue
Block a user