Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/components/nam/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@

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"}

Expand Down
8 changes: 6 additions & 2 deletions tests/components/nanoleaf/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions tests/components/netatmo/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion tests/components/nut/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 6 additions & 2 deletions tests/components/octoprint/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions tests/components/plugwise/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,27 @@

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",
)


Expand Down
14 changes: 12 additions & 2 deletions tests/components/rachio/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
45 changes: 40 additions & 5 deletions tests/components/rainmachine/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion tests/components/roku/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@
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",
)


Expand Down
3 changes: 3 additions & 0 deletions tests/components/samsungtv/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@
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",
"manufacturer": "fake_manufacturer",
"model": "fake_model",
"serialNumber": "fake_serial",
},
type="mock_type",
)
MOCK_OLD_ENTRY = {
CONF_HOST: "fake_host",
Expand Down
5 changes: 4 additions & 1 deletion tests/components/shelly/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
}
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"}},
Expand Down
7 changes: 6 additions & 1 deletion tests/components/sonos/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
14 changes: 12 additions & 2 deletions tests/components/tado/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"