From 7dd0992f5278a3de2bd6a0b9f5f0b573c1ba414a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 21 Nov 2023 17:18:58 +0100 Subject: [PATCH] Add siren tests (#655) --- tests/test_client.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index e349b48..4081600 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -33,6 +33,7 @@ from aioesphomeapi.api_pb2 import ( MediaPlayerCommandRequest, NumberCommandRequest, SelectCommandRequest, + SirenCommandRequest, SwitchCommandRequest, TextCommandRequest, ) @@ -478,6 +479,40 @@ async def test_button_command( send.assert_called_once_with(ButtonCommandRequest(**req)) +@pytest.mark.asyncio +@pytest.mark.parametrize( + "cmd, req", + [ + (dict(key=1, state=True), dict(key=1, state=True, has_state=True)), + (dict(key=1, state=False), dict(key=1, state=False, has_state=True)), + (dict(key=1, state=None), dict(key=1, state=None, has_state=False)), + ( + dict(key=1, state=True, tone="any"), + dict(key=1, state=True, has_state=True, has_tone=True, tone="any"), + ), + ( + dict(key=1, state=True, tone=None), + dict(key=1, state=True, has_state=True, has_tone=False, tone=None), + ), + ( + dict(key=1, state=True, volume=5), + dict(key=1, state=True, has_volume=True, volume=5, has_state=True), + ), + ( + dict(key=1, state=True, duration=5), + dict(key=1, state=True, has_duration=True, duration=5, has_state=True), + ), + ], +) +async def test_siren_command( + auth_client: APIClient, cmd: dict[str, Any], req: dict[str, Any] +) -> None: + send = patch_send(auth_client) + + await auth_client.siren_command(**cmd) + send.assert_called_once_with(SirenCommandRequest(**req)) + + @pytest.mark.asyncio async def test_execute_service(auth_client: APIClient) -> None: send = patch_send(auth_client)