mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Update ZeroconfServiceInfo in tests (a-f) (#60212)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
e615e70e49
commit
1d3fbc93a0
@ -13,9 +13,12 @@ from homeassistant.components.apple_tv.const import CONF_START_OFF, DOMAIN
|
|||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
DMAP_SERVICE = zeroconf.ZeroconfServiceInfo(
|
DMAP_SERVICE = zeroconf.ZeroconfServiceInfo(
|
||||||
type="_touch-able._tcp.local.",
|
host="mock_host",
|
||||||
|
hostname="mock_hostname",
|
||||||
name="dmapid.something",
|
name="dmapid.something",
|
||||||
|
port=None,
|
||||||
properties={"CtlN": "Apple TV"},
|
properties={"CtlN": "Apple TV"},
|
||||||
|
type="_touch-able._tcp.local.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -401,8 +404,12 @@ async def test_zeroconf_unsupported_service_aborts(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
type="_dummy._tcp.local.",
|
host="mock_host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
properties={},
|
properties={},
|
||||||
|
type="_dummy._tcp.local.",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
@ -415,8 +422,12 @@ async def test_zeroconf_add_mrp_device(hass, mrp_device, pairing):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
type="_mediaremotetv._tcp.local.",
|
host="mock_host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
properties={"UniqueIdentifier": "mrpid", "Name": "Kitchen"},
|
properties={"UniqueIdentifier": "mrpid", "Name": "Kitchen"},
|
||||||
|
type="_mediaremotetv._tcp.local.",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
@ -364,9 +364,11 @@ async def test_discovery_flow(hass, source: str, discovery_info: dict):
|
|||||||
SOURCE_ZEROCONF,
|
SOURCE_ZEROCONF,
|
||||||
zeroconf.ZeroconfServiceInfo(
|
zeroconf.ZeroconfServiceInfo(
|
||||||
host=DEFAULT_HOST,
|
host=DEFAULT_HOST,
|
||||||
port=80,
|
hostname="mock_hostname",
|
||||||
name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.",
|
name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.",
|
||||||
|
port=80,
|
||||||
properties={"macaddress": MAC},
|
properties={"macaddress": MAC},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -412,9 +414,11 @@ async def test_discovered_device_already_configured(
|
|||||||
SOURCE_ZEROCONF,
|
SOURCE_ZEROCONF,
|
||||||
zeroconf.ZeroconfServiceInfo(
|
zeroconf.ZeroconfServiceInfo(
|
||||||
host="2.3.4.5",
|
host="2.3.4.5",
|
||||||
port=8080,
|
hostname="mock_hostname",
|
||||||
name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.",
|
name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.",
|
||||||
|
port=8080,
|
||||||
properties={"macaddress": MAC},
|
properties={"macaddress": MAC},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
8080,
|
8080,
|
||||||
),
|
),
|
||||||
@ -480,9 +484,11 @@ async def test_discovery_flow_updated_configuration(
|
|||||||
SOURCE_ZEROCONF,
|
SOURCE_ZEROCONF,
|
||||||
zeroconf.ZeroconfServiceInfo(
|
zeroconf.ZeroconfServiceInfo(
|
||||||
host="",
|
host="",
|
||||||
port=0,
|
hostname="mock_hostname",
|
||||||
name="",
|
name="",
|
||||||
|
port=0,
|
||||||
properties={"macaddress": "01234567890"},
|
properties={"macaddress": "01234567890"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -522,9 +528,11 @@ async def test_discovery_flow_ignore_non_axis_device(
|
|||||||
SOURCE_ZEROCONF,
|
SOURCE_ZEROCONF,
|
||||||
zeroconf.ZeroconfServiceInfo(
|
zeroconf.ZeroconfServiceInfo(
|
||||||
host="169.254.3.4",
|
host="169.254.3.4",
|
||||||
port=80,
|
hostname="mock_hostname",
|
||||||
name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.",
|
name=f"AXIS M1065-LW - {MAC}._axis-video._tcp.local.",
|
||||||
|
port=80,
|
||||||
properties={"macaddress": MAC},
|
properties={"macaddress": MAC},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -198,7 +198,12 @@ async def test_zeroconf_form(hass: core.HomeAssistant):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
name="test-bond-id.some-other-tail-info", host="test-host"
|
host="test-host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="test-bond-id.some-other-tail-info",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == "form"
|
assert result["type"] == "form"
|
||||||
@ -230,7 +235,12 @@ async def test_zeroconf_form_token_unavailable(hass: core.HomeAssistant):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
name="test-bond-id.some-other-tail-info", host="test-host"
|
host="test-host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="test-bond-id.some-other-tail-info",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -265,7 +275,12 @@ async def test_zeroconf_form_with_token_available(hass: core.HomeAssistant):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
name="test-bond-id.some-other-tail-info", host="test-host"
|
host="test-host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="test-bond-id.some-other-tail-info",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -303,8 +318,12 @@ async def test_zeroconf_already_configured(hass: core.HomeAssistant):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
name="already-registered-bond-id.some-other-tail-info",
|
|
||||||
host="updated-host",
|
host="updated-host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="already-registered-bond-id.some-other-tail-info",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -344,8 +363,12 @@ async def test_zeroconf_already_configured_refresh_token(hass: core.HomeAssistan
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
name="already-registered-bond-id.some-other-tail-info",
|
|
||||||
host="updated-host",
|
host="updated-host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="already-registered-bond-id.some-other-tail-info",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -377,8 +400,12 @@ async def test_zeroconf_already_configured_no_reload_same_host(
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
name="already-registered-bond-id.some-other-tail-info",
|
|
||||||
host="stored-host",
|
host="stored-host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="already-registered-bond-id.some-other-tail-info",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -394,8 +421,12 @@ async def test_zeroconf_form_unexpected_error(hass: core.HomeAssistant):
|
|||||||
hass,
|
hass,
|
||||||
source=config_entries.SOURCE_ZEROCONF,
|
source=config_entries.SOURCE_ZEROCONF,
|
||||||
initial_input=zeroconf.ZeroconfServiceInfo(
|
initial_input=zeroconf.ZeroconfServiceInfo(
|
||||||
name="test-bond-id.some-other-tail-info",
|
|
||||||
host="test-host",
|
host="test-host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="test-bond-id.some-other-tail-info",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
user_input={CONF_ACCESS_TOKEN: "test-token"},
|
user_input={CONF_ACCESS_TOKEN: "test-token"},
|
||||||
error=Exception(),
|
error=Exception(),
|
||||||
|
@ -22,10 +22,11 @@ MOCK_SETTINGS = {
|
|||||||
}
|
}
|
||||||
DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
||||||
host=["169.1.1.1", "1.1.1.1"],
|
host=["169.1.1.1", "1.1.1.1"],
|
||||||
port=0,
|
|
||||||
hostname="shc012345.local.",
|
hostname="shc012345.local.",
|
||||||
type="_http._tcp.local.",
|
|
||||||
name="Bosch SHC [test-mac]._http._tcp.local.",
|
name="Bosch SHC [test-mac]._http._tcp.local.",
|
||||||
|
port=0,
|
||||||
|
properties={},
|
||||||
|
type="_http._tcp.local.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -530,10 +531,11 @@ async def test_zeroconf_link_local(hass, mock_zeroconf):
|
|||||||
"""Test we get the form."""
|
"""Test we get the form."""
|
||||||
DISCOVERY_INFO_LINK_LOCAL = zeroconf.ZeroconfServiceInfo(
|
DISCOVERY_INFO_LINK_LOCAL = zeroconf.ZeroconfServiceInfo(
|
||||||
host=["169.1.1.1"],
|
host=["169.1.1.1"],
|
||||||
port=0,
|
|
||||||
hostname="shc012345.local.",
|
hostname="shc012345.local.",
|
||||||
type="_http._tcp.local.",
|
|
||||||
name="Bosch SHC [test-mac]._http._tcp.local.",
|
name="Bosch SHC [test-mac]._http._tcp.local.",
|
||||||
|
port=0,
|
||||||
|
properties={},
|
||||||
|
type="_http._tcp.local.",
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
@ -552,7 +554,14 @@ async def test_zeroconf_not_bosch_shc(hass, mock_zeroconf):
|
|||||||
"""Test we filter out non-bosch_shc devices."""
|
"""Test we filter out non-bosch_shc devices."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
data=zeroconf.ZeroconfServiceInfo(host="1.1.1.1", name="notboschshc"),
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
|
host="1.1.1.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="notboschshc",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
|
),
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
|
@ -145,7 +145,12 @@ async def test_zeroconf_snmp_error(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
hostname="example.local.", name="Brother Printer", properties={}
|
host="mock_host",
|
||||||
|
hostname="example.local.",
|
||||||
|
name="Brother Printer",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -160,9 +165,12 @@ async def test_zeroconf_unsupported_model(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
|
host="mock_host",
|
||||||
hostname="example.local.",
|
hostname="example.local.",
|
||||||
name="Brother Printer",
|
name="Brother Printer",
|
||||||
|
port=None,
|
||||||
properties={"product": "MFC-8660DN"},
|
properties={"product": "MFC-8660DN"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -185,7 +193,12 @@ async def test_zeroconf_device_exists_abort(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
hostname="example.local.", name="Brother Printer", properties={}
|
host="mock_host",
|
||||||
|
hostname="example.local.",
|
||||||
|
name="Brother Printer",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -202,7 +215,12 @@ async def test_zeroconf_no_probe_existing_device(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
hostname="localhost", name="Brother Printer"
|
host="mock_host",
|
||||||
|
hostname="localhost",
|
||||||
|
name="Brother Printer",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -223,7 +241,12 @@ async def test_zeroconf_confirm_create_entry(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
hostname="example.local.", name="Brother Printer", properties={}
|
host="mock_host",
|
||||||
|
hostname="example.local.",
|
||||||
|
name="Brother Printer",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -120,7 +120,18 @@ async def test_api_password_abort(hass):
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"source, data, unique_id",
|
"source, data, unique_id",
|
||||||
[
|
[
|
||||||
(SOURCE_ZEROCONF, zeroconf.ZeroconfServiceInfo(host=HOST), MAC),
|
(
|
||||||
|
SOURCE_ZEROCONF,
|
||||||
|
zeroconf.ZeroconfServiceInfo(
|
||||||
|
host=HOST,
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
|
),
|
||||||
|
MAC,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_discovery_zeroconf(
|
async def test_discovery_zeroconf(
|
||||||
|
@ -20,7 +20,19 @@ DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
|||||||
)
|
)
|
||||||
|
|
||||||
DISCOVERY_INFO_WRONG_DEVOLO_DEVICE = zeroconf.ZeroconfServiceInfo(
|
DISCOVERY_INFO_WRONG_DEVOLO_DEVICE = zeroconf.ZeroconfServiceInfo(
|
||||||
properties={"MT": "2700"}
|
host="mock_host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
|
properties={"MT": "2700"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
|
|
||||||
DISCOVERY_INFO_WRONG_DEVICE = zeroconf.ZeroconfServiceInfo(properties={"Features": ""})
|
DISCOVERY_INFO_WRONG_DEVICE = zeroconf.ZeroconfServiceInfo(
|
||||||
|
host="mock_host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
|
properties={"Features": ""},
|
||||||
|
type="mock_type",
|
||||||
|
)
|
||||||
|
@ -36,7 +36,14 @@ DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
DISCOVERY_INFO_WRONG_DEVICE = zeroconf.ZeroconfServiceInfo(properties={"MT": "2600"})
|
DISCOVERY_INFO_WRONG_DEVICE = zeroconf.ZeroconfServiceInfo(
|
||||||
|
host="mock_host",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
|
properties={"MT": "2600"},
|
||||||
|
type="mock_type",
|
||||||
|
)
|
||||||
|
|
||||||
NEIGHBOR_ACCESS_POINTS = {
|
NEIGHBOR_ACCESS_POINTS = {
|
||||||
"neighbor_aps": [
|
"neighbor_aps": [
|
||||||
|
@ -83,9 +83,12 @@ async def test_form_zeroconf_wrong_oui(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
properties={"macaddress": "notdoorbirdoui"},
|
|
||||||
host="192.168.1.8",
|
host="192.168.1.8",
|
||||||
|
hostname="mock_hostname",
|
||||||
name="Doorstation - abc123._axis-video._tcp.local.",
|
name="Doorstation - abc123._axis-video._tcp.local.",
|
||||||
|
port=None,
|
||||||
|
properties={"macaddress": "notdoorbirdoui"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
@ -99,9 +102,12 @@ async def test_form_zeroconf_link_local_ignored(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
properties={"macaddress": "1CCAE3DOORBIRD"},
|
|
||||||
host="169.254.103.61",
|
host="169.254.103.61",
|
||||||
|
hostname="mock_hostname",
|
||||||
name="Doorstation - abc123._axis-video._tcp.local.",
|
name="Doorstation - abc123._axis-video._tcp.local.",
|
||||||
|
port=None,
|
||||||
|
properties={"macaddress": "1CCAE3DOORBIRD"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert result["type"] == "abort"
|
assert result["type"] == "abort"
|
||||||
@ -122,9 +128,12 @@ async def test_form_zeroconf_correct_oui(hass):
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
properties={"macaddress": "1CCAE3DOORBIRD"},
|
|
||||||
name="Doorstation - abc123._axis-video._tcp.local.",
|
|
||||||
host="192.168.1.5",
|
host="192.168.1.5",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="Doorstation - abc123._axis-video._tcp.local.",
|
||||||
|
port=None,
|
||||||
|
properties={"macaddress": "1CCAE3DOORBIRD"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -181,9 +190,12 @@ async def test_form_zeroconf_correct_oui_wrong_device(hass, doorbell_state_side_
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
properties={"macaddress": "1CCAE3DOORBIRD"},
|
|
||||||
name="Doorstation - abc123._axis-video._tcp.local.",
|
|
||||||
host="192.168.1.5",
|
host="192.168.1.5",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="Doorstation - abc123._axis-video._tcp.local.",
|
||||||
|
port=None,
|
||||||
|
properties={"macaddress": "1CCAE3DOORBIRD"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -31,8 +31,10 @@ async def test_full_user_flow_implementation(
|
|||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
hostname="example.local.",
|
hostname="example.local.",
|
||||||
|
name="mock_name",
|
||||||
port=9123,
|
port=9123,
|
||||||
properties={},
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -74,8 +76,10 @@ async def test_full_zeroconf_flow_implementation(
|
|||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
hostname="example.local.",
|
hostname="example.local.",
|
||||||
|
name="mock_name",
|
||||||
port=9123,
|
port=9123,
|
||||||
properties={},
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -128,7 +132,14 @@ async def test_zeroconf_connection_error(
|
|||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": SOURCE_ZEROCONF},
|
context={"source": SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(host="127.0.0.1", port=9123),
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
|
host="127.0.0.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=9123,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["reason"] == "cannot_connect"
|
assert result["reason"] == "cannot_connect"
|
||||||
@ -159,7 +170,14 @@ async def test_zeroconf_device_exists_abort(
|
|||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(host="127.0.0.1", port=9123),
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
|
host="127.0.0.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=9123,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
@ -168,7 +186,14 @@ async def test_zeroconf_device_exists_abort(
|
|||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(host="127.0.0.2", port=9123),
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
|
host="127.0.0.2",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=9123,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
@ -159,8 +159,12 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
properties={"serialnum": "1234"},
|
|
||||||
host="1.1.1.1",
|
host="1.1.1.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
|
properties={"serialnum": "1234"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -255,8 +259,12 @@ async def test_zeroconf_serial_already_exists(hass: HomeAssistant) -> None:
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
properties={"serialnum": "1234"},
|
|
||||||
host="1.1.1.1",
|
host="1.1.1.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
|
properties={"serialnum": "1234"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -290,8 +298,12 @@ async def test_zeroconf_host_already_exists(hass: HomeAssistant) -> None:
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||||
data=zeroconf.ZeroconfServiceInfo(
|
data=zeroconf.ZeroconfServiceInfo(
|
||||||
properties={"serialnum": "1234"},
|
|
||||||
host="1.1.1.1",
|
host="1.1.1.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=None,
|
||||||
|
properties={"serialnum": "1234"},
|
||||||
|
type="mock_type",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -218,9 +218,11 @@ async def test_discovery_initiation(hass, mock_client, mock_zeroconf):
|
|||||||
|
|
||||||
service_info = zeroconf.ZeroconfServiceInfo(
|
service_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="192.168.43.183",
|
host="192.168.43.183",
|
||||||
port=6053,
|
|
||||||
hostname="test8266.local.",
|
hostname="test8266.local.",
|
||||||
|
name="mock_name",
|
||||||
|
port=6053,
|
||||||
properties={},
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
flow = await hass.config_entries.flow.async_init(
|
flow = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
@ -250,9 +252,11 @@ async def test_discovery_already_configured_hostname(hass, mock_client):
|
|||||||
|
|
||||||
service_info = zeroconf.ZeroconfServiceInfo(
|
service_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="192.168.43.183",
|
host="192.168.43.183",
|
||||||
port=6053,
|
|
||||||
hostname="test8266.local.",
|
hostname="test8266.local.",
|
||||||
|
name="mock_name",
|
||||||
|
port=6053,
|
||||||
properties={},
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
@ -275,9 +279,11 @@ async def test_discovery_already_configured_ip(hass, mock_client):
|
|||||||
|
|
||||||
service_info = zeroconf.ZeroconfServiceInfo(
|
service_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="192.168.43.183",
|
host="192.168.43.183",
|
||||||
port=6053,
|
|
||||||
hostname="test8266.local.",
|
hostname="test8266.local.",
|
||||||
|
name="mock_name",
|
||||||
|
port=6053,
|
||||||
properties={"address": "192.168.43.183"},
|
properties={"address": "192.168.43.183"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
@ -304,9 +310,11 @@ async def test_discovery_already_configured_name(hass, mock_client):
|
|||||||
|
|
||||||
service_info = zeroconf.ZeroconfServiceInfo(
|
service_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="192.168.43.184",
|
host="192.168.43.184",
|
||||||
port=6053,
|
|
||||||
hostname="test8266.local.",
|
hostname="test8266.local.",
|
||||||
|
name="mock_name",
|
||||||
|
port=6053,
|
||||||
properties={"address": "test8266.local"},
|
properties={"address": "test8266.local"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
@ -323,9 +331,11 @@ async def test_discovery_duplicate_data(hass, mock_client):
|
|||||||
"""Test discovery aborts if same mDNS packet arrives."""
|
"""Test discovery aborts if same mDNS packet arrives."""
|
||||||
service_info = zeroconf.ZeroconfServiceInfo(
|
service_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="192.168.43.183",
|
host="192.168.43.183",
|
||||||
port=6053,
|
|
||||||
hostname="test8266.local.",
|
hostname="test8266.local.",
|
||||||
|
name="mock_name",
|
||||||
|
port=6053,
|
||||||
properties={"address": "test8266.local"},
|
properties={"address": "test8266.local"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
|
|
||||||
mock_client.device_info = AsyncMock(return_value=MockDeviceInfo(False, "test8266"))
|
mock_client.device_info = AsyncMock(return_value=MockDeviceInfo(False, "test8266"))
|
||||||
@ -354,9 +364,11 @@ async def test_discovery_updates_unique_id(hass, mock_client):
|
|||||||
|
|
||||||
service_info = zeroconf.ZeroconfServiceInfo(
|
service_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="192.168.43.183",
|
host="192.168.43.183",
|
||||||
port=6053,
|
|
||||||
hostname="test8266.local.",
|
hostname="test8266.local.",
|
||||||
|
name="mock_name",
|
||||||
|
port=6053,
|
||||||
properties={"address": "test8266.local"},
|
properties={"address": "test8266.local"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
"esphome", context={"source": config_entries.SOURCE_ZEROCONF}, data=service_info
|
||||||
|
@ -101,8 +101,11 @@ async def test_zeroconf_updates_title(hass, config_entry):
|
|||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 2
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 2
|
||||||
discovery_info = zeroconf.ZeroconfServiceInfo(
|
discovery_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="192.168.1.1",
|
host="192.168.1.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
port=23,
|
port=23,
|
||||||
properties={"mtd-version": "27.0", "Machine Name": "zeroconf_test"},
|
properties={"mtd-version": "27.0", "Machine Name": "zeroconf_test"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
@ -131,7 +134,12 @@ async def test_config_flow_zeroconf_invalid(hass):
|
|||||||
"""Test that an invalid zeroconf entry doesn't work."""
|
"""Test that an invalid zeroconf entry doesn't work."""
|
||||||
# test with no discovery properties
|
# test with no discovery properties
|
||||||
discovery_info = zeroconf.ZeroconfServiceInfo(
|
discovery_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="127.0.0.1", port=23, properties={}
|
host="127.0.0.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
|
port=23,
|
||||||
|
properties={},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
@ -141,8 +149,11 @@ async def test_config_flow_zeroconf_invalid(hass):
|
|||||||
# test with forked-daapd version < 27
|
# test with forked-daapd version < 27
|
||||||
discovery_info = zeroconf.ZeroconfServiceInfo(
|
discovery_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
port=23,
|
port=23,
|
||||||
properties={"mtd-version": "26.3", "Machine Name": "forked-daapd"},
|
properties={"mtd-version": "26.3", "Machine Name": "forked-daapd"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
@ -152,8 +163,11 @@ async def test_config_flow_zeroconf_invalid(hass):
|
|||||||
# test with verbose mtd-version from Firefly
|
# test with verbose mtd-version from Firefly
|
||||||
discovery_info = zeroconf.ZeroconfServiceInfo(
|
discovery_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
port=23,
|
port=23,
|
||||||
properties={"mtd-version": "0.2.4.1", "Machine Name": "firefly"},
|
properties={"mtd-version": "0.2.4.1", "Machine Name": "firefly"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
@ -163,8 +177,11 @@ async def test_config_flow_zeroconf_invalid(hass):
|
|||||||
# test with svn mtd-version from Firefly
|
# test with svn mtd-version from Firefly
|
||||||
discovery_info = zeroconf.ZeroconfServiceInfo(
|
discovery_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="127.0.0.1",
|
host="127.0.0.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
port=23,
|
port=23,
|
||||||
properties={"mtd-version": "svn-1676", "Machine Name": "firefly"},
|
properties={"mtd-version": "svn-1676", "Machine Name": "firefly"},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
@ -177,12 +194,15 @@ async def test_config_flow_zeroconf_valid(hass):
|
|||||||
"""Test that a valid zeroconf entry works."""
|
"""Test that a valid zeroconf entry works."""
|
||||||
discovery_info = zeroconf.ZeroconfServiceInfo(
|
discovery_info = zeroconf.ZeroconfServiceInfo(
|
||||||
host="192.168.1.1",
|
host="192.168.1.1",
|
||||||
|
hostname="mock_hostname",
|
||||||
|
name="mock_name",
|
||||||
port=23,
|
port=23,
|
||||||
properties={
|
properties={
|
||||||
"mtd-version": "27.0",
|
"mtd-version": "27.0",
|
||||||
"Machine Name": "zeroconf_test",
|
"Machine Name": "zeroconf_test",
|
||||||
"Machine ID": "5E55EEFF",
|
"Machine ID": "5E55EEFF",
|
||||||
},
|
},
|
||||||
|
type="mock_type",
|
||||||
)
|
)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user