mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Change version check in forked-daapd zeroconf step (#35796)
This commit is contained in:
parent
a51372f7b3
commit
8c8feb95a9
@ -158,7 +158,8 @@ class ForkedDaapdFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
"""Prepare configuration for a discovered forked-daapd device."""
|
"""Prepare configuration for a discovered forked-daapd device."""
|
||||||
if not (
|
if not (
|
||||||
discovery_info.get("properties")
|
discovery_info.get("properties")
|
||||||
and float(discovery_info["properties"].get("mtd-version", 0)) >= 27.0
|
and int(discovery_info["properties"].get("mtd-version", "0").split(".")[0])
|
||||||
|
>= 27
|
||||||
and discovery_info["properties"].get("Machine Name")
|
and discovery_info["properties"].get("Machine Name")
|
||||||
):
|
):
|
||||||
return self.async_abort(reason="not_forked_daapd")
|
return self.async_abort(reason="not_forked_daapd")
|
||||||
|
@ -103,7 +103,7 @@ async def test_zeroconf_updates_title(hass, config_entry):
|
|||||||
discovery_info = {
|
discovery_info = {
|
||||||
"host": "192.168.1.1",
|
"host": "192.168.1.1",
|
||||||
"port": 23,
|
"port": 23,
|
||||||
"properties": {"mtd-version": 27.0, "Machine Name": "zeroconf_test"},
|
"properties": {"mtd-version": "27.0", "Machine Name": "zeroconf_test"},
|
||||||
}
|
}
|
||||||
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
|
||||||
@ -129,12 +129,35 @@ async def test_config_flow_no_websocket(hass, config_entry):
|
|||||||
|
|
||||||
async def test_config_flow_zeroconf_invalid(hass):
|
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
|
||||||
discovery_info = {"host": "127.0.0.1", "port": 23}
|
discovery_info = {"host": "127.0.0.1", "port": 23}
|
||||||
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
|
||||||
) # doesn't create the entry, tries to show form but gets abort
|
) # doesn't create the entry, tries to show form but gets abort
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
assert result["reason"] == "not_forked_daapd"
|
assert result["reason"] == "not_forked_daapd"
|
||||||
|
# test with forked-daapd version < 27
|
||||||
|
discovery_info = {
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 23,
|
||||||
|
"properties": {"mtd-version": "26.3", "Machine Name": "forked-daapd"},
|
||||||
|
}
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
|
) # doesn't create the entry, tries to show form but gets abort
|
||||||
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
assert result["reason"] == "not_forked_daapd"
|
||||||
|
# test with verbose mtd-version from Firefly
|
||||||
|
discovery_info = {
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 23,
|
||||||
|
"properties": {"mtd-version": "0.2.4.1", "Machine Name": "firefly"},
|
||||||
|
}
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
|
) # doesn't create the entry, tries to show form but gets abort
|
||||||
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
assert result["reason"] == "not_forked_daapd"
|
||||||
|
|
||||||
|
|
||||||
async def test_config_flow_zeroconf_valid(hass):
|
async def test_config_flow_zeroconf_valid(hass):
|
||||||
@ -143,7 +166,7 @@ async def test_config_flow_zeroconf_valid(hass):
|
|||||||
"host": "192.168.1.1",
|
"host": "192.168.1.1",
|
||||||
"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",
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user