chore: moved tests scripts
This commit is contained in:
80
scripts/test_dose_parsing_simple.py
Normal file
80
scripts/test_dose_parsing_simple.py
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Simple test of the dose parsing workflow."""
|
||||
|
||||
import sys
|
||||
|
||||
sys.path.append("src")
|
||||
|
||||
|
||||
# Test the fixed parsing workflow
|
||||
def test_dose_parsing():
|
||||
print("Testing dose parsing workflow...\n")
|
||||
|
||||
# Import UIManager after path setup
|
||||
import logging
|
||||
import tkinter as tk
|
||||
from unittest.mock import Mock
|
||||
|
||||
from ui_manager import UIManager
|
||||
|
||||
# Create minimal mocks
|
||||
root = tk.Tk()
|
||||
root.withdraw()
|
||||
logger = logging.getLogger("test")
|
||||
mock_medicine_manager = Mock()
|
||||
mock_pathology_manager = Mock()
|
||||
|
||||
# Create UIManager
|
||||
ui_manager = UIManager(root, logger, mock_medicine_manager, mock_pathology_manager)
|
||||
|
||||
# Test case 1: Simulate what happens in the UI
|
||||
print("1. Testing _populate_dose_history...")
|
||||
|
||||
# Mock text widget
|
||||
class MockText:
|
||||
def __init__(self):
|
||||
self.content = ""
|
||||
|
||||
def configure(self, state):
|
||||
pass
|
||||
|
||||
def delete(self, start, end):
|
||||
self.content = ""
|
||||
|
||||
def insert(self, pos, text):
|
||||
self.content = text
|
||||
|
||||
def get(self, start, end):
|
||||
return self.content
|
||||
|
||||
mock_text = MockText()
|
||||
saved_doses = "2025-01-30 08:00:00:150mg|2025-01-30 14:00:00:25mg"
|
||||
|
||||
ui_manager._populate_dose_history(mock_text, saved_doses)
|
||||
print(f"Populated display: '{mock_text.content}'")
|
||||
|
||||
# Test case 2: User adds a new dose
|
||||
print("\n2. Testing user editing...")
|
||||
user_edited = mock_text.content + "\n• 06:00 PM - 50mg"
|
||||
print(f"User edited content: '{user_edited}'")
|
||||
|
||||
# Test case 3: Parse back for saving
|
||||
print("\n3. Testing _parse_dose_history_for_saving...")
|
||||
parsed_result = ui_manager._parse_dose_history_for_saving(user_edited, "2025-01-30")
|
||||
print(f"Parsed for saving: '{parsed_result}'")
|
||||
|
||||
# Count doses
|
||||
dose_count = len([d for d in parsed_result.split("|") if d.strip()])
|
||||
print(f"Final dose count: {dose_count}")
|
||||
|
||||
if dose_count == 3:
|
||||
print("\n✅ SUCCESS: All 3 doses preserved!")
|
||||
return True
|
||||
else:
|
||||
print(f"\n❌ FAILURE: Expected 3 doses, got {dose_count}")
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_dose_parsing()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user