Skip to content

Commit 969f2f7

Browse files
committed
Add/improve testing
1 parent 0734649 commit 969f2f7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/test_usb.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,25 +1122,28 @@ def test_pulse_collection_consumption(
11221122
) == (45, pulse_update_3)
11231123
tst_consumption.add_log(100, 2, (fixed_this_hour + td(hours=1)), 2222)
11241124
assert not tst_consumption.log_rollover
1125+
pulse_update_4 = fixed_this_hour + td(hours=1, minutes=1, seconds=18)
1126+
test_timestamp_2 = fixed_this_hour + td(hours=1, minutes=1, seconds=20)
1127+
tst_consumption.update_pulse_counter(145, 0, pulse_update_4)
11251128
assert tst_consumption.collected_pulses(
1126-
test_timestamp, is_consumption=True
1127-
) == (45, pulse_update_3)
1129+
test_timestamp_2, is_consumption=True
1130+
) == (145, pulse_update_4)
11281131
assert tst_consumption.collected_pulses(
11291132
fixed_this_hour, is_consumption=True
1130-
) == (45 + 2222, pulse_update_3)
1133+
) == (145 + 2222, pulse_update_4)
11311134

11321135
# Test log rollover by updating log first before updating pulses
11331136
tst_consumption.add_log(100, 3, (fixed_this_hour + td(hours=2)), 3333)
11341137
assert tst_consumption.log_rollover
11351138
assert tst_consumption.collected_pulses(
11361139
fixed_this_hour, is_consumption=True
1137-
) == (45+ 2222 + 3333, pulse_update_3)
1138-
pulse_update_4 = fixed_this_hour + td(hours=2, seconds=10)
1139-
tst_consumption.update_pulse_counter(321, 0, pulse_update_4)
1140+
) == (145+ 2222 + 3333, pulse_update_4)
1141+
pulse_update_5 = fixed_this_hour + td(hours=2, seconds=10)
1142+
tst_consumption.update_pulse_counter(321, 0, pulse_update_5)
11401143
assert not tst_consumption.log_rollover
11411144
assert tst_consumption.collected_pulses(
11421145
fixed_this_hour, is_consumption=True
1143-
) == (2222 + 3333 + 321, pulse_update_4)
1146+
) == (2222 + 3333 + 321, pulse_update_5)
11441147

11451148
@freeze_time(dt.now())
11461149
def test_pulse_collection_consumption_empty(

0 commit comments

Comments
 (0)