@@ -74,6 +74,15 @@ async def test_create_duration_none(client: FakeClient, sample: Dispatch) -> Non
7474 assert dispatch == sample
7575
7676
77+ async def test_create_duration_0 (client : FakeClient , sample : Dispatch ) -> None :
78+ """Test creating a dispatch with a 0 duration."""
79+ microgrid_id = random .randint (1 , 100 )
80+ sample = replace (sample , duration = timedelta (minutes = 0 ))
81+ dispatch = await client .create (** to_create_params (microgrid_id , sample ))
82+ sample = _update_metadata (sample , dispatch )
83+ assert dispatch == sample
84+
85+
7786async def test_list_dispatches (
7887 client : FakeClient , generator : DispatchGenerator
7988) -> None :
@@ -172,6 +181,24 @@ async def test_update_dispatch_to_no_duration(
172181 assert client .dispatches (microgrid_id )[0 ].duration is None
173182
174183
184+ async def test_update_dispatch_to_0_duration (
185+ client : FakeClient , sample : Dispatch
186+ ) -> None :
187+ """Test updating the duration field of a dispatch to 0."""
188+ microgrid_id = random .randint (1 , 100 )
189+ client .set_dispatches (
190+ microgrid_id = microgrid_id ,
191+ value = [replace (sample , duration = timedelta (minutes = 10 ))],
192+ )
193+
194+ await client .update (
195+ microgrid_id = microgrid_id ,
196+ dispatch_id = sample .id ,
197+ new_fields = {"duration" : timedelta (minutes = 0 )},
198+ )
199+ assert client .dispatches (microgrid_id )[0 ].duration == timedelta (minutes = 0 )
200+
201+
175202async def test_update_dispatch_from_no_duration (
176203 client : FakeClient , sample : Dispatch
177204) -> None :
0 commit comments