Use ZeroconfServiceInfo in smappee (#60096)
This commit is contained in:
parent
b465131170
commit
1c15544d7a
2 changed files with 77 additions and 70 deletions
|
@ -3,8 +3,8 @@ from http import HTTPStatus
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import data_entry_flow, setup
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.smappee.const import (
|
||||
CONF_HOSTNAME,
|
||||
CONF_SERIALNUMBER,
|
||||
DOMAIN,
|
||||
ENV_CLOUD,
|
||||
|
@ -55,14 +55,14 @@ async def test_show_zeroconf_connection_error_form(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "1.2.3.4",
|
||||
"port": 22,
|
||||
CONF_HOSTNAME: "Smappee1006000212.local.",
|
||||
"type": "_ssh._tcp.local.",
|
||||
"name": "Smappee1006000212._ssh._tcp.local.",
|
||||
"properties": {"_raw": {}},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4",
|
||||
port=22,
|
||||
hostname="Smappee1006000212.local.",
|
||||
type="_ssh._tcp.local.",
|
||||
name="Smappee1006000212._ssh._tcp.local.",
|
||||
properties={"_raw": {}},
|
||||
),
|
||||
)
|
||||
|
||||
assert result["description_placeholders"] == {CONF_SERIALNUMBER: "1006000212"}
|
||||
|
@ -84,14 +84,14 @@ async def test_show_zeroconf_connection_error_form_next_generation(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "1.2.3.4",
|
||||
"port": 22,
|
||||
CONF_HOSTNAME: "Smappee5001000212.local.",
|
||||
"type": "_ssh._tcp.local.",
|
||||
"name": "Smappee5001000212._ssh._tcp.local.",
|
||||
"properties": {"_raw": {}},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4",
|
||||
port=22,
|
||||
hostname="Smappee5001000212.local.",
|
||||
type="_ssh._tcp.local.",
|
||||
name="Smappee5001000212._ssh._tcp.local.",
|
||||
properties={"_raw": {}},
|
||||
),
|
||||
)
|
||||
|
||||
assert result["description_placeholders"] == {CONF_SERIALNUMBER: "5001000212"}
|
||||
|
@ -166,14 +166,14 @@ async def test_zeroconf_wrong_mdns(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "1.2.3.4",
|
||||
"port": 22,
|
||||
CONF_HOSTNAME: "example.local.",
|
||||
"type": "_ssh._tcp.local.",
|
||||
"name": "example._ssh._tcp.local.",
|
||||
"properties": {"_raw": {}},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4",
|
||||
port=22,
|
||||
hostname="example.local.",
|
||||
type="_ssh._tcp.local.",
|
||||
name="example._ssh._tcp.local.",
|
||||
properties={"_raw": {}},
|
||||
),
|
||||
)
|
||||
|
||||
assert result["reason"] == "invalid_mdns"
|
||||
|
@ -276,14 +276,14 @@ async def test_zeroconf_device_exists_abort(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "1.2.3.4",
|
||||
"port": 22,
|
||||
CONF_HOSTNAME: "Smappee1006000212.local.",
|
||||
"type": "_ssh._tcp.local.",
|
||||
"name": "Smappee1006000212._ssh._tcp.local.",
|
||||
"properties": {"_raw": {}},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4",
|
||||
port=22,
|
||||
hostname="Smappee1006000212.local.",
|
||||
type="_ssh._tcp.local.",
|
||||
name="Smappee1006000212._ssh._tcp.local.",
|
||||
properties={"_raw": {}},
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
@ -325,14 +325,14 @@ async def test_zeroconf_abort_if_cloud_device_exists(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "1.2.3.4",
|
||||
"port": 22,
|
||||
CONF_HOSTNAME: "Smappee1006000212.local.",
|
||||
"type": "_ssh._tcp.local.",
|
||||
"name": "Smappee1006000212._ssh._tcp.local.",
|
||||
"properties": {"_raw": {}},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4",
|
||||
port=22,
|
||||
hostname="Smappee1006000212.local.",
|
||||
type="_ssh._tcp.local.",
|
||||
name="Smappee1006000212._ssh._tcp.local.",
|
||||
properties={"_raw": {}},
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured_device"
|
||||
|
@ -344,14 +344,14 @@ async def test_zeroconf_confirm_abort_if_cloud_device_exists(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "1.2.3.4",
|
||||
"port": 22,
|
||||
CONF_HOSTNAME: "Smappee1006000212.local.",
|
||||
"type": "_ssh._tcp.local.",
|
||||
"name": "Smappee1006000212._ssh._tcp.local.",
|
||||
"properties": {"_raw": {}},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4",
|
||||
port=22,
|
||||
hostname="Smappee1006000212.local.",
|
||||
type="_ssh._tcp.local.",
|
||||
name="Smappee1006000212._ssh._tcp.local.",
|
||||
properties={"_raw": {}},
|
||||
),
|
||||
)
|
||||
|
||||
config_entry = MockConfigEntry(
|
||||
|
@ -463,14 +463,14 @@ async def test_full_zeroconf_flow(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "1.2.3.4",
|
||||
"port": 22,
|
||||
CONF_HOSTNAME: "Smappee1006000212.local.",
|
||||
"type": "_ssh._tcp.local.",
|
||||
"name": "Smappee1006000212._ssh._tcp.local.",
|
||||
"properties": {"_raw": {}},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4",
|
||||
port=22,
|
||||
hostname="Smappee1006000212.local.",
|
||||
type="_ssh._tcp.local.",
|
||||
name="Smappee1006000212._ssh._tcp.local.",
|
||||
properties={"_raw": {}},
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "zeroconf_confirm"
|
||||
|
@ -538,14 +538,14 @@ async def test_full_zeroconf_flow_next_generation(hass):
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "1.2.3.4",
|
||||
"port": 22,
|
||||
CONF_HOSTNAME: "Smappee5001000212.local.",
|
||||
"type": "_ssh._tcp.local.",
|
||||
"name": "Smappee5001000212._ssh._tcp.local.",
|
||||
"properties": {"_raw": {}},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4",
|
||||
port=22,
|
||||
hostname="Smappee5001000212.local.",
|
||||
type="_ssh._tcp.local.",
|
||||
name="Smappee5001000212._ssh._tcp.local.",
|
||||
properties={"_raw": {}},
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "zeroconf_confirm"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue