diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d4546f43..027b9a83 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -14,4 +14,4 @@ ## Bug Fixes - +* Fixes reconnecting after connection loss for streams diff --git a/pyproject.toml b/pyproject.toml index 36f38623..85874fc6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dependencies = [ # plugins.mkdocstrings.handlers.python.import) "frequenz-sdk >= 1.0.0-rc1302, < 1.0.0-rc1900", "frequenz-channels >= 1.6.1, < 2.0.0", - "frequenz-client-dispatch >= 0.8.4, < 0.9.0", + "frequenz-client-dispatch >= 0.9.0, < 0.10.0", ] dynamic = ["version"] diff --git a/tests/test_frequenz_dispatch.py b/tests/test_frequenz_dispatch.py index 9c5bed73..e066f97a 100644 --- a/tests/test_frequenz_dispatch.py +++ b/tests/test_frequenz_dispatch.py @@ -127,6 +127,7 @@ def update_dispatch(sample: BaseDispatch, dispatch: BaseDispatch) -> BaseDispatc update_time=dispatch.update_time, create_time=dispatch.create_time, id=dispatch.id, + end_time=dispatch.end_time, # Ensure end_time is updated ) @@ -359,9 +360,12 @@ async def test_dispatch_schedule( type="TEST_TYPE", ) await test_env.client.create(**to_create_params(test_env.microgrid_id, sample)) - dispatch = Dispatch(test_env.client.dispatches(test_env.microgrid_id)[0]) + # Get the initial dispatch state from the client to use as a base for comparison + initial_dispatch_from_client = Dispatch( + test_env.client.dispatches(test_env.microgrid_id)[0] + ) - next_run = dispatch.next_run_after(_now()) + next_run = initial_dispatch_from_client.next_run_after(_now()) assert next_run is not None fake_time.shift(next_run - _now() - timedelta(seconds=1)) @@ -370,16 +374,21 @@ async def test_dispatch_schedule( # Expect notification of the dispatch being ready to run ready_dispatch = await test_env.running_state_change.receive() - assert ready_dispatch == dispatch + # Use update_dispatch to create the expected object based on the initial state + expected_ready_dispatch = Dispatch(update_dispatch(sample, ready_dispatch)) + assert ready_dispatch == expected_ready_dispatch - assert dispatch.duration is not None + assert initial_dispatch_from_client.duration is not None # Shift time to the end of the dispatch - fake_time.shift(dispatch.duration + timedelta(seconds=1)) + fake_time.shift(initial_dispatch_from_client.duration + timedelta(seconds=1)) await asyncio.sleep(1) # Expect notification to stop the dispatch done_dispatch = await test_env.running_state_change.receive() - assert done_dispatch == dispatch + + # Use update_dispatch again for the stop event comparison + expected_done_dispatch = Dispatch(update_dispatch(sample, done_dispatch)) + assert done_dispatch == expected_done_dispatch await asyncio.sleep(1)