1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-26 14:08:21 +00:00

Prettier Zeroconf discovery name for Axis devices (#45216)

* Change zeroconf name to be based of prettier name rather than hostname to help user understand what device is discovered
Have a full zeroconf discovery message in tests
Clean up unusued globals

* Use non-formatted serial number for config entry title as well
This commit is contained in:
Robert Svensson
2021-01-16 18:59:57 +01:00
committed by GitHub
parent 8151721fbc
commit 3cc45697cb
4 changed files with 24 additions and 27 deletions

View File

@@ -33,7 +33,6 @@ from homeassistant.data_entry_flow import (
)
from .test_device import (
FORMATTED_MAC,
MAC,
MODEL,
NAME,
@@ -68,7 +67,7 @@ async def test_flow_manual_configuration(hass):
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
assert result["title"] == f"M1065-LW - {FORMATTED_MAC}"
assert result["title"] == f"M1065-LW - {MAC}"
assert result["data"] == {
CONF_HOST: "1.2.3.4",
CONF_USERNAME: "user",
@@ -225,7 +224,7 @@ async def test_flow_create_entry_multiple_existing_entries_of_same_model(hass):
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
assert result["title"] == f"M1065-LW - {FORMATTED_MAC}"
assert result["title"] == f"M1065-LW - {MAC}"
assert result["data"] == {
CONF_HOST: "1.2.3.4",
CONF_USERNAME: "user",
@@ -266,7 +265,7 @@ async def test_dhcp_flow(hass):
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
assert result["title"] == f"M1065-LW - {FORMATTED_MAC}"
assert result["title"] == f"M1065-LW - {MAC}"
assert result["data"] == {
CONF_HOST: "1.2.3.4",
CONF_USERNAME: "user",
@@ -376,10 +375,15 @@ async def test_zeroconf_flow(hass):
result = await hass.config_entries.flow.async_init(
AXIS_DOMAIN,
data={
CONF_HOST: "1.2.3.4",
CONF_PORT: 80,
"hostname": "name",
"properties": {"macaddress": MAC},
"host": "1.2.3.4",
"port": 80,
"hostname": f"axis-{MAC.lower()}.local.",
"type": "_axis-video._tcp.local.",
"name": f"AXIS M1065-L - {MAC}._axis-video._tcp.local.",
"properties": {
"_raw": {"macaddress": MAC.encode()},
"macaddress": MAC,
},
},
context={"source": SOURCE_ZEROCONF},
)
@@ -400,7 +404,7 @@ async def test_zeroconf_flow(hass):
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
assert result["title"] == f"M1065-LW - {FORMATTED_MAC}"
assert result["title"] == f"M1065-LW - {MAC}"
assert result["data"] == {
CONF_HOST: "1.2.3.4",
CONF_USERNAME: "user",
@@ -424,7 +428,7 @@ async def test_zeroconf_flow_already_configured(hass):
data={
CONF_HOST: "1.2.3.4",
CONF_PORT: 80,
"hostname": "name",
"name": "name",
"properties": {"macaddress": MAC},
},
context={"source": SOURCE_ZEROCONF},
@@ -459,7 +463,7 @@ async def test_zeroconf_flow_updated_configuration(hass):
data={
CONF_HOST: "2.3.4.5",
CONF_PORT: 8080,
"hostname": "name",
"name": "name",
"properties": {"macaddress": MAC},
},
context={"source": SOURCE_ZEROCONF},
@@ -486,7 +490,7 @@ async def test_zeroconf_flow_ignore_non_axis_device(hass):
data={
CONF_HOST: "169.254.3.4",
CONF_PORT: 80,
"hostname": "",
"name": "",
"properties": {"macaddress": "01234567890"},
},
context={"source": SOURCE_ZEROCONF},
@@ -503,7 +507,7 @@ async def test_zeroconf_flow_ignore_link_local_address(hass):
data={
CONF_HOST: "169.254.3.4",
CONF_PORT: 80,
"hostname": "",
"name": "",
"properties": {"macaddress": MAC},
},
context={"source": SOURCE_ZEROCONF},

View File

@@ -378,7 +378,7 @@ async def test_update_address(hass):
data={
"host": "2.3.4.5",
"port": 80,
"hostname": "name",
"name": "name",
"properties": {"macaddress": MAC},
},
context={"source": SOURCE_ZEROCONF},