Skip to content

Commit 38ac7fb

Browse files
Add test to remove single gap if outdated
Signed-off-by: Matthias Wende <[email protected]>
1 parent 79c373f commit 38ac7fb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/timeseries/test_ringbuffer.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,25 @@ def test_cleanup_oldest_gap_timestamp() -> None:
390390
)
391391

392392
assert gap == buffer.gaps[0]
393+
394+
395+
def test_delete_oudated_gap() -> None:
396+
"""
397+
Update the buffer such that the gap is no longer valid.
398+
We introduce two gaps and check that the oldest is removed.
399+
"""
400+
buffer = OrderedRingBuffer(
401+
np.empty(shape=3, dtype=float),
402+
sampling_period=timedelta(seconds=1),
403+
align_to=datetime(1, 1, 1, tzinfo=timezone.utc),
404+
)
405+
406+
for i in range(2):
407+
buffer.update(
408+
Sample(datetime.fromtimestamp(200 + i, tz=timezone.utc), Quantity(i))
409+
)
410+
assert len(buffer.gaps) == 1
411+
412+
buffer.update(Sample(datetime.fromtimestamp(202, tz=timezone.utc), Quantity(2)))
413+
414+
assert len(buffer.gaps) == 0

0 commit comments

Comments
 (0)