Skip to content

Commit 9960656

Browse files
committed
Use easier to debug fake times in tests
We use the epoch so it is very easy to debug time issues when using datetime.timestamp(). We also stop the time from ticking, because we want to have full control over time passing in these tests. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent e2136d1 commit 9960656

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/timeseries/test_resampling.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def resampling_function_sum(
4141
return sum(sample.value for sample in samples if sample.value is not None)
4242

4343

44-
@time_machine.travel(datetime.now())
44+
@time_machine.travel(0, tick=False)
4545
def test_component_metric_resampler_remove_outdated_samples() -> None:
4646
"""Test if outdated samples are being properly removed."""
4747
resampler = ComponentMetricResampler(
@@ -63,7 +63,7 @@ def test_component_metric_resampler_remove_outdated_samples() -> None:
6363
assert len(resampler._buffer) == 0 # pylint: disable=protected-access
6464

6565

66-
@time_machine.travel(datetime.now())
66+
@time_machine.travel(0, tick=False)
6767
def test_component_metric_resampler_resample() -> None:
6868
"""Test if resampling function works as expected."""
6969
resampler = ComponentMetricResampler(
@@ -88,7 +88,7 @@ def test_component_metric_resampler_resample() -> None:
8888
assert value == sum([value1, value2])
8989

9090

91-
@time_machine.travel(datetime.now())
91+
@time_machine.travel(0, tick=False)
9292
def test_component_metric_resampler_resample_with_outdated_samples() -> None:
9393
"""Test that resampling function doesn't take outdated samples into account."""
9494
resampler = ComponentMetricResampler(
@@ -116,7 +116,7 @@ def test_component_metric_resampler_resample_with_outdated_samples() -> None:
116116
assert value == sum([value2, value3])
117117

118118

119-
@time_machine.travel(datetime.now())
119+
@time_machine.travel(0, tick=False)
120120
def test_component_metric_group_resampler() -> None:
121121
"""Test if resampling is properly delegated to component metric resamplers."""
122122
resampler = ComponentMetricGroupResampler(

0 commit comments

Comments
 (0)