From 77dfeb062f902f4e25450e791160fdf7ce515695 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 23 Nov 2021 17:35:44 +0100 Subject: [PATCH] Update ZeroconfServiceInfo in tests (n-t) (#60219) Co-authored-by: epenet --- tests/components/nam/test_config_flow.py | 9 +++- tests/components/nanoleaf/test_config_flow.py | 8 +++- tests/components/netatmo/test_config_flow.py | 4 ++ tests/components/nut/test_config_flow.py | 9 +++- .../components/octoprint/test_config_flow.py | 8 +++- tests/components/plugwise/test_config_flow.py | 10 +++-- tests/components/rachio/test_config_flow.py | 14 +++++- .../rainmachine/test_config_flow.py | 45 ++++++++++++++++--- tests/components/roku/__init__.py | 5 ++- .../components/samsungtv/test_config_flow.py | 3 ++ tests/components/shelly/test_config_flow.py | 5 ++- tests/components/sonos/test_config_flow.py | 7 ++- tests/components/tado/test_config_flow.py | 14 +++++- 13 files changed, 119 insertions(+), 22 deletions(-) diff --git a/tests/components/nam/test_config_flow.py b/tests/components/nam/test_config_flow.py index 5a3e46cedb9..015c645a3e7 100644 --- a/tests/components/nam/test_config_flow.py +++ b/tests/components/nam/test_config_flow.py @@ -12,7 +12,14 @@ from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZERO from tests.common import MockConfigEntry -DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(host="10.10.2.3") +DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo( + host="10.10.2.3", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={}, + type="mock_type", +) VALID_CONFIG = {"host": "10.10.2.3"} VALID_AUTH = {"username": "fake_username", "password": "fake_password"} diff --git a/tests/components/nanoleaf/test_config_flow.py b/tests/components/nanoleaf/test_config_flow.py index 5e781499325..9faf48b625c 100644 --- a/tests/components/nanoleaf/test_config_flow.py +++ b/tests/components/nanoleaf/test_config_flow.py @@ -238,9 +238,11 @@ async def test_discovery_link_unavailable( context={"source": source}, data=zeroconf.ZeroconfServiceInfo( host=TEST_HOST, + hostname="mock_hostname", name=f"{TEST_NAME}.{type_in_discovery_info}", - type=type_in_discovery_info, + port=None, properties={zeroconf.ATTR_PROPERTIES_ID: TEST_DEVICE_ID}, + type=type_in_discovery_info, ), ) assert result["type"] == "form" @@ -420,9 +422,11 @@ async def test_import_discovery_integration( context={"source": source}, data=zeroconf.ZeroconfServiceInfo( host=TEST_HOST, + hostname="mock_hostname", name=f"{TEST_NAME}.{type_in_discovery}", - type=type_in_discovery, + port=None, properties={zeroconf.ATTR_PROPERTIES_ID: TEST_DEVICE_ID}, + type=type_in_discovery, ), ) assert result["type"] == "create_entry" diff --git a/tests/components/netatmo/test_config_flow.py b/tests/components/netatmo/test_config_flow.py index b38c59055b6..b97f4c8b4ec 100644 --- a/tests/components/netatmo/test_config_flow.py +++ b/tests/components/netatmo/test_config_flow.py @@ -42,7 +42,11 @@ async def test_abort_if_existing_entry(hass): context={"source": config_entries.SOURCE_HOMEKIT}, data=zeroconf.ZeroconfServiceInfo( host="0.0.0.0", + hostname="mock_hostname", + name="mock_name", + port=None, properties={zeroconf.ATTR_PROPERTIES_ID: "aa:bb:cc:dd:ee:ff"}, + type="mock_type", ), ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT diff --git a/tests/components/nut/test_config_flow.py b/tests/components/nut/test_config_flow.py index 892d74b4713..733d5807c5f 100644 --- a/tests/components/nut/test_config_flow.py +++ b/tests/components/nut/test_config_flow.py @@ -35,7 +35,14 @@ async def test_form_zeroconf(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.ZeroconfServiceInfo(host="192.168.1.5", port=1234), + data=zeroconf.ZeroconfServiceInfo( + host="192.168.1.5", + hostname="mock_hostname", + name="mock_name", + port=1234, + properties={}, + type="mock_type", + ), ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user" diff --git a/tests/components/octoprint/test_config_flow.py b/tests/components/octoprint/test_config_flow.py index 2c8143fb78c..b55d43fda9e 100644 --- a/tests/components/octoprint/test_config_flow.py +++ b/tests/components/octoprint/test_config_flow.py @@ -172,9 +172,11 @@ async def test_show_zerconf_form(hass: HomeAssistant) -> None: context={"source": config_entries.SOURCE_ZEROCONF}, data=zeroconf.ZeroconfServiceInfo( host="192.168.1.123", - port=80, hostname="example.local.", + name="mock_name", + port=80, properties={"uuid": "83747482", "path": "/foo/"}, + type="mock_type", ), ) assert result["type"] == "form" @@ -487,9 +489,11 @@ async def test_duplicate_zerconf_ignored(hass: HomeAssistant) -> None: context={"source": config_entries.SOURCE_ZEROCONF}, data=zeroconf.ZeroconfServiceInfo( host="192.168.1.123", - port=80, hostname="example.local.", + name="mock_name", + port=80, properties={"uuid": "83747482", "path": "/foo/"}, + type="mock_type", ), ) assert result["type"] == "abort" diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index 72e695a4e9c..9f9be299f84 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -42,25 +42,27 @@ TEST_USERNAME2 = "stretch" TEST_DISCOVERY = zeroconf.ZeroconfServiceInfo( host=TEST_HOST, - port=DEFAULT_PORT, hostname=f"{TEST_HOSTNAME}.local.", - server=f"{TEST_HOSTNAME}.local.", + name="mock_name", + port=DEFAULT_PORT, properties={ "product": "smile", "version": "1.2.3", "hostname": f"{TEST_HOSTNAME}.local.", }, + type="mock_type", ) TEST_DISCOVERY2 = zeroconf.ZeroconfServiceInfo( host=TEST_HOST, - port=DEFAULT_PORT, hostname=f"{TEST_HOSTNAME2}.local.", - server=f"{TEST_HOSTNAME2}.local.", + name="mock_name", + port=DEFAULT_PORT, properties={ "product": "stretch", "version": "1.2.3", "hostname": f"{TEST_HOSTNAME2}.local.", }, + type="mock_type", ) diff --git a/tests/components/rachio/test_config_flow.py b/tests/components/rachio/test_config_flow.py index 8afcaca1886..cf9e811ed5a 100644 --- a/tests/components/rachio/test_config_flow.py +++ b/tests/components/rachio/test_config_flow.py @@ -113,7 +113,12 @@ async def test_form_homekit(hass): DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, data=zeroconf.ZeroconfServiceInfo( - properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"} + host="mock_host", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}, + type="mock_type", ), ) assert result["type"] == "form" @@ -132,7 +137,12 @@ async def test_form_homekit(hass): DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, data=zeroconf.ZeroconfServiceInfo( - properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"} + host="mock_host", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}, + type="mock_type", ), ) assert result["type"] == "abort" diff --git a/tests/components/rainmachine/test_config_flow.py b/tests/components/rainmachine/test_config_flow.py index 1ce95f76ac5..35824296cc6 100644 --- a/tests/components/rainmachine/test_config_flow.py +++ b/tests/components/rainmachine/test_config_flow.py @@ -235,7 +235,14 @@ async def test_step_homekit_zeroconf_ip_already_exists(hass, source): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": source}, - data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"), + data=zeroconf.ZeroconfServiceInfo( + host="192.168.1.100", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={}, + type="mock_type", + ), ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT @@ -264,7 +271,14 @@ async def test_step_homekit_zeroconf_ip_change(hass, source): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": source}, - data=zeroconf.ZeroconfServiceInfo(host="192.168.1.2"), + data=zeroconf.ZeroconfServiceInfo( + host="192.168.1.2", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={}, + type="mock_type", + ), ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT @@ -295,7 +309,14 @@ async def test_step_homekit_zeroconf_new_controller_when_some_exist(hass, source result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": source}, - data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"), + data=zeroconf.ZeroconfServiceInfo( + host="192.168.1.100", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={}, + type="mock_type", + ), ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -339,7 +360,14 @@ async def test_discovery_by_homekit_and_zeroconf_same_time(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, - data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"), + data=zeroconf.ZeroconfServiceInfo( + host="192.168.1.100", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={}, + type="mock_type", + ), ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM @@ -352,7 +380,14 @@ async def test_discovery_by_homekit_and_zeroconf_same_time(hass): result2 = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, - data=zeroconf.ZeroconfServiceInfo(host="192.168.1.100"), + data=zeroconf.ZeroconfServiceInfo( + host="192.168.1.100", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={}, + type="mock_type", + ), ) assert result2["type"] == data_entry_flow.RESULT_TYPE_ABORT diff --git a/tests/components/roku/__init__.py b/tests/components/roku/__init__.py index d97d30e66ce..ece58de763a 100644 --- a/tests/components/roku/__init__.py +++ b/tests/components/roku/__init__.py @@ -33,11 +33,14 @@ MOCK_SSDP_DISCOVERY_INFO = { HOMEKIT_HOST = "192.168.1.161" MOCK_HOMEKIT_DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo( - name="onn._hap._tcp.local.", host=HOMEKIT_HOST, + hostname="mock_hostname", + name="onn._hap._tcp.local.", + port=None, properties={ zeroconf.ATTR_PROPERTIES_ID: "2d:97:da:ee:dc:99", }, + type="mock_type", ) diff --git a/tests/components/samsungtv/test_config_flow.py b/tests/components/samsungtv/test_config_flow.py index 79420d6f303..4c5d77fcc1f 100644 --- a/tests/components/samsungtv/test_config_flow.py +++ b/tests/components/samsungtv/test_config_flow.py @@ -90,6 +90,8 @@ MOCK_DHCP_DATA = dhcp.DhcpServiceInfo( EXISTING_IP = "192.168.40.221" MOCK_ZEROCONF_DATA = zeroconf.ZeroconfServiceInfo( host="fake_host", + hostname="mock_hostname", + name="mock_name", port=1234, properties={ "deviceid": "aa:bb:cc:dd:ee:ff", @@ -97,6 +99,7 @@ MOCK_ZEROCONF_DATA = zeroconf.ZeroconfServiceInfo( "model": "fake_model", "serialNumber": "fake_serial", }, + type="mock_type", ) MOCK_OLD_ENTRY = { CONF_HOST: "fake_host", diff --git a/tests/components/shelly/test_config_flow.py b/tests/components/shelly/test_config_flow.py index ec88856603a..2d9cb20342f 100644 --- a/tests/components/shelly/test_config_flow.py +++ b/tests/components/shelly/test_config_flow.py @@ -19,8 +19,11 @@ MOCK_SETTINGS = { } DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo( host="1.1.1.1", + hostname="mock_hostname", name="shelly1pm-12345", - properties={"id": "shelly1pm-12345"}, + port=None, + properties={zeroconf.ATTR_PROPERTIES_ID: "shelly1pm-12345"}, + type="mock_type", ) MOCK_CONFIG = { "wifi": {"ap": {"ssid": "Test name"}}, diff --git a/tests/components/sonos/test_config_flow.py b/tests/components/sonos/test_config_flow.py index 4d4e0cc4cad..9677ee73759 100644 --- a/tests/components/sonos/test_config_flow.py +++ b/tests/components/sonos/test_config_flow.py @@ -46,9 +46,11 @@ async def test_zeroconf_form(hass: core.HomeAssistant): context={"source": config_entries.SOURCE_ZEROCONF}, data=zeroconf.ZeroconfServiceInfo( host="192.168.4.2", - name="Sonos-aaa@Living Room._sonos._tcp.local.", hostname="Sonos-aaa", + name="Sonos-aaa@Living Room._sonos._tcp.local.", + port=None, properties={"bootseq": "1234"}, + type="mock_type", ), ) assert result["type"] == "form" @@ -136,7 +138,10 @@ async def test_zeroconf_form_not_sonos(hass: core.HomeAssistant): data=zeroconf.ZeroconfServiceInfo( host="192.168.4.2", hostname="not-aaa", + name="mock_name", + port=None, properties={"bootseq": "1234"}, + type="mock_type", ), ) assert result["type"] == "abort" diff --git a/tests/components/tado/test_config_flow.py b/tests/components/tado/test_config_flow.py index 327747cb841..4c234fee248 100644 --- a/tests/components/tado/test_config_flow.py +++ b/tests/components/tado/test_config_flow.py @@ -128,7 +128,12 @@ async def test_form_homekit(hass): DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, data=zeroconf.ZeroconfServiceInfo( - properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"} + host="mock_host", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}, + type="mock_type", ), ) assert result["type"] == "form" @@ -149,7 +154,12 @@ async def test_form_homekit(hass): DOMAIN, context={"source": config_entries.SOURCE_HOMEKIT}, data=zeroconf.ZeroconfServiceInfo( - properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"} + host="mock_host", + hostname="mock_hostname", + name="mock_name", + port=None, + properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}, + type="mock_type", ), ) assert result["type"] == "abort"