Convert functions that no longer await to be normal functions (#827)

This commit is contained in:
J. Nick Koston 2024-02-18 14:02:24 -06:00 committed by GitHub
parent f9df266a4a
commit 23a2f402fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 67 additions and 73 deletions

View File

@ -410,7 +410,7 @@ class APIClient:
entities.append(cls.from_pb(msg)) entities.append(cls.from_pb(msg))
return entities, services return entities, services
async def subscribe_states(self, on_state: Callable[[EntityState], None]) -> None: def subscribe_states(self, on_state: Callable[[EntityState], None]) -> None:
"""Subscribe to state updates.""" """Subscribe to state updates."""
self._get_connection().send_message_callback_response( self._get_connection().send_message_callback_response(
SubscribeStatesRequest(), SubscribeStatesRequest(),
@ -418,7 +418,7 @@ class APIClient:
SUBSCRIBE_STATES_MSG_TYPES, SUBSCRIBE_STATES_MSG_TYPES,
) )
async def subscribe_logs( def subscribe_logs(
self, self,
on_log: Callable[[SubscribeLogsResponse], None], on_log: Callable[[SubscribeLogsResponse], None],
log_level: LogLevel | None = None, log_level: LogLevel | None = None,
@ -433,7 +433,7 @@ class APIClient:
req, on_log, (SubscribeLogsResponse,) req, on_log, (SubscribeLogsResponse,)
) )
async def subscribe_service_calls( def subscribe_service_calls(
self, on_service_call: Callable[[HomeassistantServiceCall], None] self, on_service_call: Callable[[HomeassistantServiceCall], None]
) -> None: ) -> None:
self._get_connection().send_message_callback_response( self._get_connection().send_message_callback_response(
@ -479,7 +479,7 @@ class APIClient:
unsub_callback() unsub_callback()
self._connection.send_message(UnsubscribeBluetoothLEAdvertisementsRequest()) self._connection.send_message(UnsubscribeBluetoothLEAdvertisementsRequest())
async def subscribe_bluetooth_le_advertisements( def subscribe_bluetooth_le_advertisements(
self, on_bluetooth_le_advertisement: Callable[[BluetoothLEAdvertisement], None] self, on_bluetooth_le_advertisement: Callable[[BluetoothLEAdvertisement], None]
) -> Callable[[], None]: ) -> Callable[[], None]:
unsub_callback = self._get_connection().send_message_callback_response( unsub_callback = self._get_connection().send_message_callback_response(
@ -492,7 +492,7 @@ class APIClient:
) )
return partial(self._unsub_bluetooth_advertisements, unsub_callback) return partial(self._unsub_bluetooth_advertisements, unsub_callback)
async def subscribe_bluetooth_le_raw_advertisements( def subscribe_bluetooth_le_raw_advertisements(
self, on_advertisements: Callable[[BluetoothLERawAdvertisementsResponse], None] self, on_advertisements: Callable[[BluetoothLERawAdvertisementsResponse], None]
) -> Callable[[], None]: ) -> Callable[[], None]:
unsub_callback = self._get_connection().send_message_callback_response( unsub_callback = self._get_connection().send_message_callback_response(
@ -504,7 +504,7 @@ class APIClient:
) )
return partial(self._unsub_bluetooth_advertisements, unsub_callback) return partial(self._unsub_bluetooth_advertisements, unsub_callback)
async def subscribe_bluetooth_connections_free( def subscribe_bluetooth_connections_free(
self, on_bluetooth_connections_free_update: Callable[[int, int], None] self, on_bluetooth_connections_free_update: Callable[[int, int], None]
) -> Callable[[], None]: ) -> Callable[[], None]:
return self._get_connection().send_message_callback_response( return self._get_connection().send_message_callback_response(
@ -900,7 +900,7 @@ class APIClient:
return stop_notify, remove_callback return stop_notify, remove_callback
async def subscribe_home_assistant_states( def subscribe_home_assistant_states(
self, on_state_sub: Callable[[str, str | None], None] self, on_state_sub: Callable[[str, str | None], None]
) -> None: ) -> None:
self._get_connection().send_message_callback_response( self._get_connection().send_message_callback_response(
@ -909,7 +909,7 @@ class APIClient:
(SubscribeHomeAssistantStateResponse,), (SubscribeHomeAssistantStateResponse,),
) )
async def send_home_assistant_state( def send_home_assistant_state(
self, entity_id: str, attribute: str | None, state: str self, entity_id: str, attribute: str | None, state: str
) -> None: ) -> None:
self._get_connection().send_message( self._get_connection().send_message(
@ -920,7 +920,7 @@ class APIClient:
) )
) )
async def cover_command( def cover_command(
self, self,
key: int, key: int,
position: float | None = None, position: float | None = None,
@ -952,7 +952,7 @@ class APIClient:
req.has_legacy_command = True req.has_legacy_command = True
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def fan_command( def fan_command(
self, self,
key: int, key: int,
state: bool | None = None, state: bool | None = None,
@ -983,7 +983,7 @@ class APIClient:
req.preset_mode = preset_mode req.preset_mode = preset_mode
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def light_command( # pylint: disable=too-many-branches def light_command( # pylint: disable=too-many-branches
self, self,
key: int, key: int,
state: bool | None = None, state: bool | None = None,
@ -1040,10 +1040,10 @@ class APIClient:
req.effect = effect req.effect = effect
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def switch_command(self, key: int, state: bool) -> None: def switch_command(self, key: int, state: bool) -> None:
self._get_connection().send_message(SwitchCommandRequest(key=key, state=state)) self._get_connection().send_message(SwitchCommandRequest(key=key, state=state))
async def climate_command( # pylint: disable=too-many-branches def climate_command( # pylint: disable=too-many-branches
self, self,
key: int, key: int,
mode: ClimateMode | None = None, mode: ClimateMode | None = None,
@ -1097,13 +1097,13 @@ class APIClient:
req.target_humidity = target_humidity req.target_humidity = target_humidity
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def number_command(self, key: int, state: float) -> None: def number_command(self, key: int, state: float) -> None:
self._get_connection().send_message(NumberCommandRequest(key=key, state=state)) self._get_connection().send_message(NumberCommandRequest(key=key, state=state))
async def select_command(self, key: int, state: str) -> None: def select_command(self, key: int, state: str) -> None:
self._get_connection().send_message(SelectCommandRequest(key=key, state=state)) self._get_connection().send_message(SelectCommandRequest(key=key, state=state))
async def siren_command( def siren_command(
self, self,
key: int, key: int,
state: bool | None = None, state: bool | None = None,
@ -1126,10 +1126,10 @@ class APIClient:
req.has_duration = True req.has_duration = True
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def button_command(self, key: int) -> None: def button_command(self, key: int) -> None:
self._get_connection().send_message(ButtonCommandRequest(key=key)) self._get_connection().send_message(ButtonCommandRequest(key=key))
async def lock_command( def lock_command(
self, self,
key: int, key: int,
command: LockCommand, command: LockCommand,
@ -1140,7 +1140,7 @@ class APIClient:
req.code = code req.code = code
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def media_player_command( def media_player_command(
self, self,
key: int, key: int,
*, *,
@ -1160,10 +1160,10 @@ class APIClient:
req.has_media_url = True req.has_media_url = True
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def text_command(self, key: int, state: str) -> None: def text_command(self, key: int, state: str) -> None:
self._get_connection().send_message(TextCommandRequest(key=key, state=state)) self._get_connection().send_message(TextCommandRequest(key=key, state=state))
async def execute_service( def execute_service(
self, service: UserService, data: ExecuteServiceDataType self, service: UserService, data: ExecuteServiceDataType
) -> None: ) -> None:
req = ExecuteServiceRequest(key=service.key) req = ExecuteServiceRequest(key=service.key)
@ -1192,18 +1192,16 @@ class APIClient:
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def _request_image( def _request_image(self, *, single: bool = False, stream: bool = False) -> None:
self, *, single: bool = False, stream: bool = False
) -> None:
self._get_connection().send_message( self._get_connection().send_message(
CameraImageRequest(single=single, stream=stream) CameraImageRequest(single=single, stream=stream)
) )
async def request_single_image(self) -> None: def request_single_image(self) -> None:
await self._request_image(single=True) self._request_image(single=True)
async def request_image_stream(self) -> None: def request_image_stream(self) -> None:
await self._request_image(stream=True) self._request_image(stream=True)
@property @property
def api_version(self) -> APIVersion | None: def api_version(self) -> APIVersion | None:
@ -1211,7 +1209,7 @@ class APIClient:
return None return None
return self._connection.api_version return self._connection.api_version
async def subscribe_voice_assistant( def subscribe_voice_assistant(
self, self,
handle_start: Callable[ handle_start: Callable[
[str, int, VoiceAssistantAudioSettingsModel], [str, int, VoiceAssistantAudioSettingsModel],
@ -1297,7 +1295,7 @@ class APIClient:
) )
self._get_connection().send_message(req) self._get_connection().send_message(req)
async def alarm_control_panel_command( def alarm_control_panel_command(
self, self,
key: int, key: int,
command: AlarmControlPanelCommand, command: AlarmControlPanelCommand,

View File

@ -33,7 +33,7 @@ async def async_run(
"""Handle a connection.""" """Handle a connection."""
nonlocal dumped_config nonlocal dumped_config
try: try:
await cli.subscribe_logs( cli.subscribe_logs(
on_log, on_log,
log_level=log_level, log_level=log_level,
dump_config=not dumped_config, dump_config=not dumped_config,

View File

@ -324,7 +324,7 @@ async def test_list_entities(
async def test_subscribe_states(auth_client: APIClient) -> None: async def test_subscribe_states(auth_client: APIClient) -> None:
send = patch_response_callback(auth_client) send = patch_response_callback(auth_client)
on_state = MagicMock() on_state = MagicMock()
await auth_client.subscribe_states(on_state) auth_client.subscribe_states(on_state)
on_state.assert_not_called() on_state.assert_not_called()
await send(BinarySensorStateResponse()) await send(BinarySensorStateResponse())
@ -335,7 +335,7 @@ async def test_subscribe_states(auth_client: APIClient) -> None:
async def test_subscribe_states_camera(auth_client: APIClient) -> None: async def test_subscribe_states_camera(auth_client: APIClient) -> None:
send = patch_response_callback(auth_client) send = patch_response_callback(auth_client)
on_state = MagicMock() on_state = MagicMock()
await auth_client.subscribe_states(on_state) auth_client.subscribe_states(on_state)
await send(CameraImageResponse(key=1, data=b"asdf")) await send(CameraImageResponse(key=1, data=b"asdf"))
on_state.assert_not_called() on_state.assert_not_called()
@ -374,7 +374,7 @@ async def test_cover_command_legacy(
send = patch_send(auth_client) send = patch_send(auth_client)
patch_api_version(auth_client, APIVersion(1, 0)) patch_api_version(auth_client, APIVersion(1, 0))
await auth_client.cover_command(**cmd) auth_client.cover_command(**cmd)
send.assert_called_once_with(CoverCommandRequest(**req)) send.assert_called_once_with(CoverCommandRequest(**req))
@ -398,7 +398,7 @@ async def test_cover_command(
send = patch_send(auth_client) send = patch_send(auth_client)
patch_api_version(auth_client, APIVersion(1, 1)) patch_api_version(auth_client, APIVersion(1, 1))
await auth_client.cover_command(**cmd) auth_client.cover_command(**cmd)
send.assert_called_once_with(CoverCommandRequest(**req)) send.assert_called_once_with(CoverCommandRequest(**req))
@ -435,7 +435,7 @@ async def test_fan_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.fan_command(**cmd) auth_client.fan_command(**cmd)
send.assert_called_once_with(FanCommandRequest(**req)) send.assert_called_once_with(FanCommandRequest(**req))
@ -499,7 +499,7 @@ async def test_light_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.light_command(**cmd) auth_client.light_command(**cmd)
send.assert_called_once_with(LightCommandRequest(**req)) send.assert_called_once_with(LightCommandRequest(**req))
@ -516,7 +516,7 @@ async def test_switch_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.switch_command(**cmd) auth_client.switch_command(**cmd)
send.assert_called_once_with(SwitchCommandRequest(**req)) send.assert_called_once_with(SwitchCommandRequest(**req))
@ -540,7 +540,7 @@ async def test_climate_command_legacy(
send = patch_send(auth_client) send = patch_send(auth_client)
patch_api_version(auth_client, APIVersion(1, 4)) patch_api_version(auth_client, APIVersion(1, 4))
await auth_client.climate_command(**cmd) auth_client.climate_command(**cmd)
send.assert_called_once_with(ClimateCommandRequest(**req)) send.assert_called_once_with(ClimateCommandRequest(**req))
@ -596,7 +596,7 @@ async def test_climate_command(
send = patch_send(auth_client) send = patch_send(auth_client)
patch_api_version(auth_client, APIVersion(1, 5)) patch_api_version(auth_client, APIVersion(1, 5))
await auth_client.climate_command(**cmd) auth_client.climate_command(**cmd)
send.assert_called_once_with(ClimateCommandRequest(**req)) send.assert_called_once_with(ClimateCommandRequest(**req))
@ -613,7 +613,7 @@ async def test_number_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.number_command(**cmd) auth_client.number_command(**cmd)
send.assert_called_once_with(NumberCommandRequest(**req)) send.assert_called_once_with(NumberCommandRequest(**req))
@ -638,7 +638,7 @@ async def test_lock_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.lock_command(**cmd) auth_client.lock_command(**cmd)
send.assert_called_once_with(LockCommandRequest(**req)) send.assert_called_once_with(LockCommandRequest(**req))
@ -655,7 +655,7 @@ async def test_select_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.select_command(**cmd) auth_client.select_command(**cmd)
send.assert_called_once_with(SelectCommandRequest(**req)) send.assert_called_once_with(SelectCommandRequest(**req))
@ -682,7 +682,7 @@ async def test_media_player_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.media_player_command(**cmd) auth_client.media_player_command(**cmd)
send.assert_called_once_with(MediaPlayerCommandRequest(**req)) send.assert_called_once_with(MediaPlayerCommandRequest(**req))
@ -698,7 +698,7 @@ async def test_button_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.button_command(**cmd) auth_client.button_command(**cmd)
send.assert_called_once_with(ButtonCommandRequest(**req)) send.assert_called_once_with(ButtonCommandRequest(**req))
@ -732,7 +732,7 @@ async def test_siren_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.siren_command(**cmd) auth_client.siren_command(**cmd)
send.assert_called_once_with(SirenCommandRequest(**req)) send.assert_called_once_with(SirenCommandRequest(**req))
@ -757,9 +757,9 @@ async def test_execute_service(auth_client: APIClient) -> None:
) )
with pytest.raises(KeyError): with pytest.raises(KeyError):
await auth_client.execute_service(service, data={}) auth_client.execute_service(service, data={})
await auth_client.execute_service( auth_client.execute_service(
service, service,
data={ data={
"arg1": False, "arg1": False,
@ -800,7 +800,7 @@ async def test_execute_service(auth_client: APIClient) -> None:
) )
# Test legacy_int # Test legacy_int
await auth_client.execute_service( auth_client.execute_service(
service, service,
data={ data={
"arg1": False, "arg1": False,
@ -819,7 +819,7 @@ async def test_execute_service(auth_client: APIClient) -> None:
send.reset_mock() send.reset_mock()
# Test arg order # Test arg order
await auth_client.execute_service( auth_client.execute_service(
service, service,
data={ data={
"arg2": 42, "arg2": 42,
@ -842,7 +842,7 @@ async def test_execute_service(auth_client: APIClient) -> None:
async def test_request_single_image(auth_client: APIClient) -> None: async def test_request_single_image(auth_client: APIClient) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.request_single_image() auth_client.request_single_image()
send.assert_called_once_with(CameraImageRequest(single=True, stream=False)) send.assert_called_once_with(CameraImageRequest(single=True, stream=False))
@ -850,7 +850,7 @@ async def test_request_single_image(auth_client: APIClient) -> None:
async def test_request_image_stream(auth_client: APIClient) -> None: async def test_request_image_stream(auth_client: APIClient) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.request_image_stream() auth_client.request_image_stream()
send.assert_called_once_with(CameraImageRequest(single=False, stream=True)) send.assert_called_once_with(CameraImageRequest(single=False, stream=True))
@ -877,7 +877,7 @@ async def test_alarm_panel_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.alarm_control_panel_command(**cmd) auth_client.alarm_control_panel_command(**cmd)
send.assert_called_once_with(AlarmControlPanelCommandRequest(**req)) send.assert_called_once_with(AlarmControlPanelCommandRequest(**req))
@ -894,7 +894,7 @@ async def test_text_command(
) -> None: ) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.text_command(**cmd) auth_client.text_command(**cmd)
send.assert_called_once_with(TextCommandRequest(**req)) send.assert_called_once_with(TextCommandRequest(**req))
@ -1536,9 +1536,7 @@ async def test_subscribe_bluetooth_le_advertisements(
def on_bluetooth_le_advertisements(adv: BluetoothLEAdvertisement) -> None: def on_bluetooth_le_advertisements(adv: BluetoothLEAdvertisement) -> None:
advs.append(adv) advs.append(adv)
unsub = await client.subscribe_bluetooth_le_advertisements( unsub = client.subscribe_bluetooth_le_advertisements(on_bluetooth_le_advertisements)
on_bluetooth_le_advertisements
)
await asyncio.sleep(0) await asyncio.sleep(0)
response: message.Message = BluetoothLEAdvertisementResponse( response: message.Message = BluetoothLEAdvertisementResponse(
address=1234, address=1234,
@ -1654,7 +1652,7 @@ async def test_subscribe_bluetooth_le_raw_advertisements(
) -> None: ) -> None:
adv_groups.append(advs.advertisements) adv_groups.append(advs.advertisements)
unsub = await client.subscribe_bluetooth_le_raw_advertisements( unsub = client.subscribe_bluetooth_le_raw_advertisements(
on_raw_bluetooth_le_advertisements on_raw_bluetooth_le_advertisements
) )
await asyncio.sleep(0) await asyncio.sleep(0)
@ -1692,9 +1690,7 @@ async def test_subscribe_bluetooth_connections_free(
def on_bluetooth_connections_free(free: int, limit: int) -> None: def on_bluetooth_connections_free(free: int, limit: int) -> None:
connections.append((free, limit)) connections.append((free, limit))
unsub = await client.subscribe_bluetooth_connections_free( unsub = client.subscribe_bluetooth_connections_free(on_bluetooth_connections_free)
on_bluetooth_connections_free
)
await asyncio.sleep(0) await asyncio.sleep(0)
response: message.Message = BluetoothConnectionsFreeResponse(free=2, limit=3) response: message.Message = BluetoothConnectionsFreeResponse(free=2, limit=3)
mock_data_received(protocol, generate_plaintext_packet(response)) mock_data_received(protocol, generate_plaintext_packet(response))
@ -1718,7 +1714,7 @@ async def test_subscribe_home_assistant_states(
) -> None: ) -> None:
states.append((entity_id, attribute)) states.append((entity_id, attribute))
await client.subscribe_home_assistant_states(on_subscribe_home_assistant_states) client.subscribe_home_assistant_states(on_subscribe_home_assistant_states)
await asyncio.sleep(0) await asyncio.sleep(0)
response: message.Message = SubscribeHomeAssistantStateResponse( response: message.Message = SubscribeHomeAssistantStateResponse(
@ -1733,7 +1729,7 @@ async def test_subscribe_home_assistant_states(
async def test_subscribe_logs(auth_client: APIClient) -> None: async def test_subscribe_logs(auth_client: APIClient) -> None:
send = patch_response_callback(auth_client) send = patch_response_callback(auth_client)
on_logs = MagicMock() on_logs = MagicMock()
await auth_client.subscribe_logs(on_logs) auth_client.subscribe_logs(on_logs)
log_msg = SubscribeLogsResponse(level=1, message=b"asdf") log_msg = SubscribeLogsResponse(level=1, message=b"asdf")
await send(log_msg) await send(log_msg)
on_logs.assert_called_with(log_msg) on_logs.assert_called_with(log_msg)
@ -1742,7 +1738,7 @@ async def test_subscribe_logs(auth_client: APIClient) -> None:
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_send_home_assistant_state(auth_client: APIClient) -> None: async def test_send_home_assistant_state(auth_client: APIClient) -> None:
send = patch_send(auth_client) send = patch_send(auth_client)
await auth_client.send_home_assistant_state("binary_sensor.bla", None, "on") auth_client.send_home_assistant_state("binary_sensor.bla", None, "on")
send.assert_called_once_with( send.assert_called_once_with(
HomeAssistantStateResponse( HomeAssistantStateResponse(
entity_id="binary_sensor.bla", state="on", attribute=None entity_id="binary_sensor.bla", state="on", attribute=None
@ -1754,7 +1750,7 @@ async def test_send_home_assistant_state(auth_client: APIClient) -> None:
async def test_subscribe_service_calls(auth_client: APIClient) -> None: async def test_subscribe_service_calls(auth_client: APIClient) -> None:
send = patch_response_callback(auth_client) send = patch_response_callback(auth_client)
on_service_call = MagicMock() on_service_call = MagicMock()
await auth_client.subscribe_service_calls(on_service_call) auth_client.subscribe_service_calls(on_service_call)
service_msg = HomeassistantServiceResponse(service="bob") service_msg = HomeassistantServiceResponse(service="bob")
await send(service_msg) await send(service_msg)
on_service_call.assert_called_with(HomeassistantServiceCall.from_pb(service_msg)) on_service_call.assert_called_with(HomeassistantServiceCall.from_pb(service_msg))
@ -2059,7 +2055,7 @@ async def test_subscribe_voice_assistant(
async def handle_stop() -> None: async def handle_stop() -> None:
stops.append(True) stops.append(True)
unsub = await client.subscribe_voice_assistant(handle_start, handle_stop) unsub = client.subscribe_voice_assistant(handle_start, handle_stop)
send.assert_called_once_with(SubscribeVoiceAssistantRequest(subscribe=True)) send.assert_called_once_with(SubscribeVoiceAssistantRequest(subscribe=True))
send.reset_mock() send.reset_mock()
audio_settings = VoiceAssistantAudioSettings( audio_settings = VoiceAssistantAudioSettings(
@ -2130,7 +2126,7 @@ async def test_subscribe_voice_assistant_failure(
async def handle_stop() -> None: async def handle_stop() -> None:
stops.append(True) stops.append(True)
unsub = await client.subscribe_voice_assistant(handle_start, handle_stop) unsub = client.subscribe_voice_assistant(handle_start, handle_stop)
send.assert_called_once_with(SubscribeVoiceAssistantRequest(subscribe=True)) send.assert_called_once_with(SubscribeVoiceAssistantRequest(subscribe=True))
send.reset_mock() send.reset_mock()
audio_settings = VoiceAssistantAudioSettings( audio_settings = VoiceAssistantAudioSettings(
@ -2203,7 +2199,7 @@ async def test_subscribe_voice_assistant_cancels_long_running_handle_start(
async def handle_stop() -> None: async def handle_stop() -> None:
stops.append(True) stops.append(True)
unsub = await client.subscribe_voice_assistant(handle_start, handle_stop) unsub = client.subscribe_voice_assistant(handle_start, handle_stop)
send.assert_called_once_with(SubscribeVoiceAssistantRequest(subscribe=True)) send.assert_called_once_with(SubscribeVoiceAssistantRequest(subscribe=True))
send.reset_mock() send.reset_mock()
audio_settings = VoiceAssistantAudioSettings( audio_settings = VoiceAssistantAudioSettings(

View File

@ -68,8 +68,8 @@ async def test_log_runner(
subscribed = asyncio.Event() subscribed = asyncio.Event()
original_subscribe_logs = cli.subscribe_logs original_subscribe_logs = cli.subscribe_logs
async def _wait_subscribe_cli(*args, **kwargs): def _wait_subscribe_cli(*args, **kwargs):
await original_subscribe_logs(*args, **kwargs) original_subscribe_logs(*args, **kwargs)
subscribed.set() subscribed.set()
with ( with (
@ -137,8 +137,8 @@ async def test_log_runner_reconnects_on_disconnect(
subscribed = asyncio.Event() subscribed = asyncio.Event()
original_subscribe_logs = cli.subscribe_logs original_subscribe_logs = cli.subscribe_logs
async def _wait_subscribe_cli(*args, **kwargs): def _wait_subscribe_cli(*args, **kwargs):
await original_subscribe_logs(*args, **kwargs) original_subscribe_logs(*args, **kwargs)
subscribed.set() subscribed.set()
with ( with (
@ -216,7 +216,7 @@ async def test_log_runner_reconnects_on_subscribe_failure(
subscribed = asyncio.Event() subscribed = asyncio.Event()
async def _wait_and_fail_subscribe_cli(*args, **kwargs): def _wait_and_fail_subscribe_cli(*args, **kwargs):
subscribed.set() subscribed.set()
raise APIConnectionError("subscribed force to fail") raise APIConnectionError("subscribed force to fail")