Skip to content

Commit

Permalink
Add test for manually ticking StepTickTimeFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdedude committed May 6, 2024
1 parent d2872d0 commit be779f4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_operations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import pytest
from freezegun import freeze_time
from dateutil.relativedelta import relativedelta
from datetime import timedelta, tzinfo
Expand Down Expand Up @@ -102,3 +103,27 @@ def test_auto_tick() -> None:
auto_incremented_time = datetime.datetime.now()
assert first_time + datetime.timedelta(seconds=15) == auto_incremented_time


@pytest.mark.parametrize(
"tick,expected_diff",
(
(datetime.timedelta(milliseconds=1500), 1.5),
(1, 1),
(1.5, 1.5)
)
)
def test_auto_and_manual_tick(tick, expected_diff) -> None:
first_time = datetime.datetime(2020, 1, 14, 0, 0, 0, 1)

with freeze_time(first_time, auto_tick_seconds=2) as frozen_time:
frozen_time.tick(tick)
incremented_time = datetime.datetime.now()
expected_time = first_time + datetime.timedelta(seconds=expected_diff)
assert incremented_time == expected_time

expected_time += datetime.timedelta(seconds=2) # auto_tick_seconds

frozen_time.tick(tick)
incremented_time = datetime.datetime.now()
expected_time += datetime.timedelta(seconds=expected_diff)
assert incremented_time == expected_time

0 comments on commit be779f4

Please sign in to comment.