mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add additional coverage to the ESPHome manager (#114265)
This commit is contained in:
@@ -188,6 +188,7 @@ class MockESPHomeDevice:
|
||||
self.service_call_callback: Callable[[HomeassistantServiceCall], None]
|
||||
self.on_disconnect: Callable[[bool], None]
|
||||
self.on_connect: Callable[[bool], None]
|
||||
self.on_connect_error: Callable[[Exception], None]
|
||||
self.home_assistant_state_subscription_callback: Callable[
|
||||
[str, str | None], None
|
||||
]
|
||||
@@ -222,10 +223,20 @@ class MockESPHomeDevice:
|
||||
"""Set the connect callback."""
|
||||
self.on_connect = on_connect
|
||||
|
||||
def set_on_connect_error(
|
||||
self, on_connect_error: Callable[[Exception], None]
|
||||
) -> None:
|
||||
"""Set the connect error callback."""
|
||||
self.on_connect_error = on_connect_error
|
||||
|
||||
async def mock_connect(self) -> None:
|
||||
"""Mock connecting."""
|
||||
await self.on_connect()
|
||||
|
||||
async def mock_connect_error(self, exc: Exception) -> None:
|
||||
"""Mock connect error."""
|
||||
await self.on_connect_error(exc)
|
||||
|
||||
def set_home_assistant_state_subscription_callback(
|
||||
self,
|
||||
on_state_sub: Callable[[str, str | None], None],
|
||||
@@ -309,6 +320,7 @@ async def _mock_generic_device_entry(
|
||||
super().__init__(*args, **kwargs)
|
||||
mock_device.set_on_disconnect(kwargs["on_disconnect"])
|
||||
mock_device.set_on_connect(kwargs["on_connect"])
|
||||
mock_device.set_on_connect_error(kwargs["on_connect_error"])
|
||||
self._try_connect = self.mock_try_connect
|
||||
|
||||
async def mock_try_connect(self):
|
||||
|
||||
Reference in New Issue
Block a user