Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ dev-pytest = [
"pytest-mock == 3.15.1",
"pytest-asyncio == 1.2.0",
"async-solipsism == 0.8",
"time-machine == 2.19.0",
"time-machine == 3.1.0",
]
dev = [
"frequenz-dispatch[dev-mkdocs,dev-flake8,dev-formatting,dev-mkdocs,dev-mypy,dev-noxfile,dev-pylint,dev-pytest]",
Expand Down
30 changes: 15 additions & 15 deletions tests/test_frequenz_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def event_loop_policy() -> async_solipsism.EventLoopPolicy:


@fixture
def fake_time() -> Iterator[time_machine.Coordinates]:
def fake_time() -> Iterator[time_machine.Traveller]:
"""Replace real time with a time machine that doesn't automatically tick."""
# destination can be a datetime or a timestamp (int), so are moving to the
# epoch (in UTC!)
Expand Down Expand Up @@ -165,7 +165,7 @@ async def _test_new_dispatch_created(
async def test_existing_dispatch_updated(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that an existing dispatch is updated."""
sample = generator.generate_dispatch()
Expand Down Expand Up @@ -203,7 +203,7 @@ async def test_existing_dispatch_updated(
async def test_existing_dispatch_deleted(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that an existing dispatch is deleted."""
sample = await _test_new_dispatch_created(test_env, generator.generate_dispatch())
Expand All @@ -226,7 +226,7 @@ async def test_existing_dispatch_deleted(
async def test_dispatch_inf_duration_deleted(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that a dispatch with infinite duration can be deleted while running."""
# Generate a dispatch with infinite duration (duration=None)
Expand Down Expand Up @@ -261,7 +261,7 @@ async def test_dispatch_inf_duration_deleted(
async def test_dispatch_inf_duration_updated_stopped_started(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that a dispatch with infinite duration can be stopped and started by updating it."""
# Generate a dispatch with infinite duration (duration=None)
Expand Down Expand Up @@ -310,7 +310,7 @@ async def test_dispatch_inf_duration_updated_stopped_started(
async def test_dispatch_inf_duration_updated_to_finite_and_stops(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test updating an inf. duration changing to finite.

Expand Down Expand Up @@ -353,7 +353,7 @@ async def test_dispatch_inf_duration_updated_to_finite_and_stops(
async def test_dispatch_schedule(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that a random dispatch is scheduled correctly."""
sample = replace(
Expand Down Expand Up @@ -400,7 +400,7 @@ async def test_dispatch_schedule(
async def test_dispatch_inf_duration_updated_to_finite_and_continues(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that updating an infinite duration dispatch to a finite duration.

Expand Down Expand Up @@ -447,7 +447,7 @@ async def test_dispatch_inf_duration_updated_to_finite_and_continues(
async def test_dispatch_new_but_finished(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that a finished dispatch is not started at startup."""
# Generate a dispatch that is already finished
Expand Down Expand Up @@ -503,7 +503,7 @@ async def test_dispatch_new_but_finished(
async def test_notification_on_actor_start(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that the actor sends notifications for all running dispatches on start."""
# Generate a dispatch that is already running
Expand Down Expand Up @@ -545,7 +545,7 @@ async def test_notification_on_actor_start(
async def test_notification_on_actor_start_inf_duration(
test_env: _TestEnv,
generator: DispatchGenerator,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that the actor sends notifications for indefinite dispatches on start."""
# Generate a dispatch that is already running
Expand Down Expand Up @@ -586,7 +586,7 @@ async def test_notification_on_actor_start_inf_duration(

@pytest.mark.parametrize("merge_strategy", [MergeByType(), MergeByTypeTarget()])
async def test_multiple_dispatches_merge_running_intervals(
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
generator: DispatchGenerator,
merge_strategy: MergeStrategy,
) -> None:
Expand Down Expand Up @@ -664,7 +664,7 @@ async def test_multiple_dispatches_merge_running_intervals(

@pytest.mark.parametrize("merge_strategy", [MergeByType(), MergeByTypeTarget()])
async def test_multiple_dispatches_sequential_intervals_merge(
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
generator: DispatchGenerator,
merge_strategy: MergeStrategy,
) -> None:
Expand Down Expand Up @@ -734,7 +734,7 @@ async def test_multiple_dispatches_sequential_intervals_merge(

@pytest.mark.parametrize("merge_strategy", [MergeByType(), MergeByTypeTarget()])
async def test_at_least_one_running_filter(
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
generator: DispatchGenerator,
merge_strategy: MergeStrategy,
) -> None:
Expand Down Expand Up @@ -831,7 +831,7 @@ async def test_at_least_one_running_filter(
],
)
async def test_dry_run_dispatches_not_merged(
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
generator: DispatchGenerator,
merge_strategy: MergeStrategy,
) -> None:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_managing_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def event_loop_policy() -> async_solipsism.EventLoopPolicy:


@fixture
def fake_time() -> Iterator[time_machine.Coordinates]:
def fake_time() -> Iterator[time_machine.Traveller]:
"""Replace real time with a time machine that doesn't automatically tick."""
# destination can be a datetime or a timestamp (int), so are moving to the
# epoch (in UTC!)
Expand Down Expand Up @@ -147,7 +147,7 @@ async def test_env() -> AsyncIterator[_TestEnv]:

async def test_simple_start_stop(
test_env: _TestEnv,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test behavior when receiving start/stop messages."""
now = _now()
Expand Down Expand Up @@ -194,7 +194,7 @@ async def test_simple_start_stop(


async def test_start_failed(
test_env: _TestEnv, fake_time: time_machine.Coordinates
test_env: _TestEnv, fake_time: time_machine.Traveller
) -> None:
"""Test auto-retry after 60 seconds."""
# pylint: disable=protected-access
Expand Down Expand Up @@ -283,7 +283,7 @@ def test_heapq_dispatch_start_stop_compare(test_env: _TestEnv) -> None:
assert scheduled_events[1].dispatch_id == dispatch2.id


async def test_dry_run(test_env: _TestEnv, fake_time: time_machine.Coordinates) -> None:
async def test_dry_run(test_env: _TestEnv, fake_time: time_machine.Traveller) -> None:
"""Test the dry run mode."""
dispatch = test_env.generator.generate_dispatch()
dispatch = replace(
Expand Down Expand Up @@ -321,7 +321,7 @@ async def test_dry_run(test_env: _TestEnv, fake_time: time_machine.Coordinates)

@pytest.mark.parametrize("strategy", [MergeByTypeTarget(), MergeByType(), None])
async def test_manage_abstraction(
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
generator: DispatchGenerator,
strategy: MergeStrategy | None,
) -> None:
Expand Down Expand Up @@ -417,7 +417,7 @@ async def new_mock_receiver(

async def test_actor_dispatcher_update_isolation(
test_env: _TestEnv,
fake_time: time_machine.Coordinates,
fake_time: time_machine.Traveller,
) -> None:
"""Test that updates for one dispatch don't affect other actors of the same type."""
dispatch_type = "ISOLATION_TEST"
Expand Down