Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Simple test script to verify dose calculation functionality.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src"))
|
|
|
|
import tkinter as tk
|
|
from tkinter import ttk
|
|
|
|
from src.graph_manager import GraphManager
|
|
|
|
|
|
def test_dose_calculation():
|
|
print("Testing dose calculation...")
|
|
|
|
# Create a minimal test setup
|
|
root = tk.Tk()
|
|
frame = ttk.LabelFrame(root, text="Test")
|
|
frame.pack()
|
|
|
|
# Create GraphManager instance
|
|
gm = GraphManager(frame)
|
|
|
|
# Test dose calculations
|
|
test_cases = [
|
|
("2025-07-28 18:59:45:150mg", 150.0),
|
|
("2025-07-28 18:59:45:150mg|2025-07-28 19:34:19:75mg", 225.0),
|
|
("• • • • 2025-07-30 07:50:00:300", 300.0),
|
|
("• 2025-07-30 22:50:00:10", 10.0),
|
|
("", 0.0),
|
|
("nan", 0.0),
|
|
("12.5mg", 12.5),
|
|
("100|50", 150.0),
|
|
]
|
|
|
|
all_passed = True
|
|
for dose_str, expected in test_cases:
|
|
result = gm._calculate_daily_dose(dose_str)
|
|
passed = result == expected
|
|
status = "PASS" if passed else "FAIL"
|
|
print(f'{status}: "{dose_str[:30]}..." -> Expected: {expected}, Got: {result}')
|
|
if not passed:
|
|
all_passed = False
|
|
|
|
root.destroy()
|
|
|
|
if all_passed:
|
|
print("\n✅ All dose calculation tests passed!")
|
|
else:
|
|
print("\n❌ Some tests failed!")
|
|
|
|
return all_passed
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_dose_calculation()
|