mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-06-26 10:35:00 +02:00
fix mocking
This commit is contained in:
parent
f0df2fff21
commit
224ef60faf
|
@ -373,12 +373,12 @@ class APIConnection:
|
||||||
aiohappyeyeballs.pop_addr_infos_interleave(addr_infos, interleave)
|
aiohappyeyeballs.pop_addr_infos_interleave(addr_infos, interleave)
|
||||||
|
|
||||||
if sock is None:
|
if sock is None:
|
||||||
if isinstance(last_exception, OSError):
|
if isinstance(last_exception, asyncio_TimeoutError):
|
||||||
raise SocketAPIError(
|
raise TimeoutAPIError(
|
||||||
f"Error connecting to {addr_infos}: {last_exception}"
|
f"Timeout while connecting to {addrs}"
|
||||||
) from last_exception
|
) from last_exception
|
||||||
raise SocketAPIError(
|
raise SocketAPIError(
|
||||||
f"Timeout while connecting to {addr_infos}"
|
f"Error connecting to {addrs}: {last_exception}"
|
||||||
) from last_exception
|
) from last_exception
|
||||||
|
|
||||||
self._socket = sock
|
self._socket = sock
|
||||||
|
|
|
@ -39,12 +39,14 @@ def async_zeroconf():
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def resolve_host():
|
def resolve_host():
|
||||||
with patch("aioesphomeapi.host_resolver.async_resolve_host") as func:
|
with patch("aioesphomeapi.host_resolver.async_resolve_host") as func:
|
||||||
func.return_value = AddrInfo(
|
func.return_value = [
|
||||||
family=socket.AF_INET,
|
AddrInfo(
|
||||||
type=socket.SOCK_STREAM,
|
family=socket.AF_INET,
|
||||||
proto=socket.IPPROTO_TCP,
|
type=socket.SOCK_STREAM,
|
||||||
sockaddr=IPv4Sockaddr("10.0.0.512", 6052),
|
proto=socket.IPPROTO_TCP,
|
||||||
)
|
sockaddr=IPv4Sockaddr("10.0.0.512", 6052),
|
||||||
|
)
|
||||||
|
]
|
||||||
yield func
|
yield func
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user