Skip to content

Commit 7e1d14f

Browse files
${localEnv}${localEnv}
authored andcommitted
test(siren): 100% coverage on PR lines – enum and invalid-duration paths
1 parent 845bf47 commit 7e1d14f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎tests/test_api_public.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,26 @@ async def test_play_siren_public_no_body(
226226
assert kwargs["json"] == {"duration": 5}
227227

228228

229+
@pytest.mark.asyncio()
230+
async def test_play_siren_public_enum_duration(
231+
protect_client: ProtectApiClient,
232+
) -> None:
233+
"""Passing a SirenDuration enum value directly should be forwarded as-is."""
234+
protect_client.api_request_raw = AsyncMock(return_value=None)
235+
await protect_client.play_siren_public(SIREN_ID, duration=SirenDuration.TWENTY)
236+
_, kwargs = protect_client.api_request_raw.call_args
237+
assert kwargs["json"] == {"duration": SirenDuration.TWENTY}
238+
239+
240+
@pytest.mark.asyncio()
241+
async def test_play_siren_public_invalid_duration(
242+
protect_client: ProtectApiClient,
243+
) -> None:
244+
"""An integer that is not a valid SirenDuration value must raise BadRequest."""
245+
with pytest.raises(BadRequest):
246+
await protect_client.play_siren_public(SIREN_ID, duration=99)
247+
248+
229249
@pytest.mark.asyncio()
230250
async def test_stop_siren_public(protect_client: ProtectApiClient) -> None:
231251
protect_client.api_request_raw = AsyncMock(return_value=None)

0 commit comments

Comments
 (0)