mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-12-22 16:48:04 +01:00
Fix trying to convert hostnames to IP Addresses (#579)
This commit is contained in:
parent
cf226b5837
commit
2a78e9588e
@ -209,7 +209,7 @@ async def async_resolve_host(
|
|||||||
except APIConnectionError as err:
|
except APIConnectionError as err:
|
||||||
zc_error = err
|
zc_error = err
|
||||||
|
|
||||||
if not addrs:
|
else:
|
||||||
addrs.extend(_async_ip_address_to_addrs(host, port))
|
addrs.extend(_async_ip_address_to_addrs(host, port))
|
||||||
|
|
||||||
if not addrs:
|
if not addrs:
|
||||||
|
@ -146,3 +146,21 @@ async def test_resolve_host_addrinfo_empty(resolve_addr, resolve_zc, addr_infos)
|
|||||||
|
|
||||||
resolve_zc.assert_not_called()
|
resolve_zc.assert_not_called()
|
||||||
resolve_addr.assert_called_once_with("example.com", 6052)
|
resolve_addr.assert_called_once_with("example.com", 6052)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
@patch("aioesphomeapi.host_resolver._async_resolve_host_zeroconf")
|
||||||
|
@patch("aioesphomeapi.host_resolver._async_resolve_host_getaddrinfo")
|
||||||
|
async def test_resolve_host_with_address(resolve_addr, resolve_zc):
|
||||||
|
resolve_zc.return_value = []
|
||||||
|
resolve_addr.return_value = addr_infos
|
||||||
|
ret = await hr.async_resolve_host("127.0.0.1", 6052)
|
||||||
|
|
||||||
|
resolve_zc.assert_not_called()
|
||||||
|
resolve_addr.assert_not_called()
|
||||||
|
assert ret == hr.AddrInfo(
|
||||||
|
family=socket.AddressFamily.AF_INET,
|
||||||
|
type=socket.SocketKind.SOCK_STREAM,
|
||||||
|
proto=6,
|
||||||
|
sockaddr=hr.IPv4Sockaddr(address="127.0.0.1", port=6052),
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user