Skip to content

Commit 0e18666

Browse files
committed
Add test perc insulin remaining
1 parent 54ef1d5 commit 0e18666

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

python_tests/tests.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
piecewise_linear_percent_rate_at_percent_time,
1616
linear_percent_rate_at_percent_time,
1717
get_dynamic_carbs_on_board,
18+
insulin_percent_effect_remaining,
1819
)
1920

2021

@@ -122,3 +123,30 @@ def test_get_dynamic_carbs_on_board():
122123
assert isinstance(dynamic_carbs_on_board, float)
123124

124125

126+
def test_insulin_percent_effect_remaining():
127+
# Test with typical rapid-acting insulin parameters
128+
result = insulin_percent_effect_remaining(
129+
minutes=60, # 60 minutes after injection
130+
action_duration=360, # 6 hours total duration
131+
peak_activity_time=75, # Peak at 75 minutes
132+
delay=10 # 10 minute delay
133+
)
134+
135+
# Basic assertions
136+
assert isinstance(result, float), "Result should be a float"
137+
assert 0.0 <= result <= 1.0, f"Result should be between 0.0 and 1.0, got {result}"
138+
139+
# Test edge cases
140+
# At time 0 (before delay), should have close to 100% effect remaining
141+
result_start = insulin_percent_effect_remaining(0, 360, 75, 10)
142+
assert result_start > 0.9, f"At start, should have >90% remaining, got {result_start}"
143+
144+
# At very end of action duration, should have very little effect remaining
145+
result_end = insulin_percent_effect_remaining(360, 360, 75, 10)
146+
assert result_end < 0.1, f"At end, should have <10% remaining, got {result_end}"
147+
148+
# At peak time, should have less than 100% but more than end
149+
result_peak = insulin_percent_effect_remaining(75, 360, 75, 10)
150+
assert result_end < result_peak < result_start, "Effect should decrease over time"
151+
152+

0 commit comments

Comments
 (0)