Skip to content

Commit 6a5aeac

Browse files
committed
Add testcase for midnight rollover
1 parent 302b095 commit 6a5aeac

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_usb.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,21 @@ def test_pulse_collection_consumption(
11451145
fixed_this_hour, is_consumption=True
11461146
) == (2222 + 3333 + 321, pulse_update_5)
11471147

1148+
# Test next midnight rollover
1149+
pulse_update_6 = fixed_this_hour.replace(hour=0, minute=0, second=3) + td(days=1)
1150+
assert not tst_consumption.log_rollover
1151+
tst_consumption.update_pulse_counter(584, 0, pulse_update_6)
1152+
test_timestamp_3 = pulse_update_6 + td(hours=0, minutes=0, seconds=5)
1153+
assert tst_consumption.collected_pulses(
1154+
test_timestamp_3, is_consumption=True
1155+
) == (14000, pulse_update_6)
1156+
pulse_update_7 = fixed_this_hour.replace(hour=0, minute=1, second=3)
1157+
tst_consumption.update_pulse_counter(50, 0, pulse_update_7)
1158+
test_timestamp_4 = pulse_update_7 + td(hours=0, minutes=1, seconds=5)
1159+
assert tst_consumption.collected_pulses(
1160+
test_timestamp_3, is_consumption=True
1161+
) == (500, pulse_update_7)
1162+
11481163
@freeze_time(dt.now())
11491164
def test_pulse_collection_consumption_empty(
11501165
self, monkeypatch: pytest.MonkeyPatch

0 commit comments

Comments
 (0)