Skip to content

Commit cd9a76c

Browse files
committed
Update test-case to mimic a real device rollover
1 parent 70c9496 commit cd9a76c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/test_usb.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,20 +1121,24 @@ def test_pulse_collection_consumption(
11211121
# Test rollover by updating pulses before log record
11221122
assert not tst_consumption.log_rollover
11231123
pulse_update_3 = fixed_this_hour + td(hours=1, seconds=3)
1124-
tst_consumption.update_pulse_counter(45, 0, pulse_update_3)
1124+
tst_consumption.update_pulse_counter(2700, 0, pulse_update_3)
11251125
assert tst_consumption.log_rollover
1126-
test_timestamp = fixed_this_hour + td(hours=1, seconds=5)
11271126
assert tst_consumption.collected_pulses(
11281127
test_timestamp, is_consumption=True
1129-
) == (45, pulse_update_3)
1128+
) == (2700, pulse_update_3)
1129+
test_timestamp = fixed_this_hour + td(hours=1, seconds=18)
1130+
tst_consumption.update_pulse_counter(45, 0, test_timestamp)
1131+
assert tst_consumption.collected_pulses(
1132+
test_timestamp, is_consumption=True
1133+
) == (90, test_timestamp)
11301134
tst_consumption.add_log(100, 2, (fixed_this_hour + td(hours=1)), 2222)
11311135
assert not tst_consumption.log_rollover
11321136
assert tst_consumption.collected_pulses(
11331137
test_timestamp, is_consumption=True
1134-
) == (45, pulse_update_3)
1138+
) == (90, test_timestamp)
11351139
assert tst_consumption.collected_pulses(
11361140
fixed_this_hour, is_consumption=True
1137-
) == (45 + 2222, pulse_update_3)
1141+
) == (45 + 90 + 2222, test_timestamp)
11381142

11391143
# Test log rollover by updating log first before updating pulses
11401144
tst_consumption.add_log(100, 3, (fixed_this_hour + td(hours=2)), 3333)

0 commit comments

Comments
 (0)