mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Use config_entries.SOURCE_* constants (#49631)
This commit is contained in:
@@ -54,7 +54,7 @@ async def test_flow_works(hass):
|
||||
return_value=[mock_bridge],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
@@ -101,7 +101,7 @@ async def test_manual_flow_works(hass, aioclient_mock):
|
||||
return_value=[mock_bridge],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
@@ -157,7 +157,7 @@ async def test_manual_flow_bridge_exist(hass, aioclient_mock):
|
||||
return_value=[],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
@@ -184,7 +184,7 @@ async def test_manual_flow_no_discovered_bridges(hass, aioclient_mock):
|
||||
aioclient_mock.get(URL_NUPNP, json=[])
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "manual"
|
||||
@@ -198,7 +198,7 @@ async def test_flow_all_discovered_bridges_exist(hass, aioclient_mock):
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
@@ -221,7 +221,7 @@ async def test_flow_bridges_discovered(hass, aioclient_mock):
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "init"
|
||||
@@ -248,7 +248,7 @@ async def test_flow_two_bridges_discovered_one_new(hass, aioclient_mock):
|
||||
).add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
@@ -266,7 +266,7 @@ async def test_flow_timeout_discovery(hass):
|
||||
side_effect=asyncio.TimeoutError,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
@@ -283,7 +283,7 @@ async def test_flow_link_timeout(hass):
|
||||
return_value=[mock_bridge],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -308,7 +308,7 @@ async def test_flow_link_unknown_error(hass):
|
||||
return_value=[mock_bridge],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -334,7 +334,7 @@ async def test_flow_link_button_not_pressed(hass):
|
||||
return_value=[mock_bridge],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -360,7 +360,7 @@ async def test_flow_link_unknown_host(hass):
|
||||
return_value=[mock_bridge],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": "user"}
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -380,7 +380,7 @@ async def test_bridge_ssdp(hass, mf_url):
|
||||
"""Test a bridge being discovered."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data={
|
||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: mf_url,
|
||||
@@ -396,7 +396,7 @@ async def test_bridge_ssdp_discover_other_bridge(hass):
|
||||
"""Test that discovery ignores other bridges."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data={ssdp.ATTR_UPNP_MANUFACTURER_URL: "http://www.notphilips.com"},
|
||||
)
|
||||
|
||||
@@ -408,7 +408,7 @@ async def test_bridge_ssdp_emulated_hue(hass):
|
||||
"""Test if discovery info is from an emulated hue instance."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data={
|
||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: "Home Assistant Bridge",
|
||||
@@ -425,7 +425,7 @@ async def test_bridge_ssdp_missing_location(hass):
|
||||
"""Test if discovery info is missing a location attribute."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data={
|
||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
||||
ssdp.ATTR_UPNP_SERIAL: "1234",
|
||||
@@ -440,7 +440,7 @@ async def test_bridge_ssdp_missing_serial(hass):
|
||||
"""Test if discovery info is a serial attribute."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data={
|
||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
||||
@@ -455,7 +455,7 @@ async def test_bridge_ssdp_espalexa(hass):
|
||||
"""Test if discovery info is from an Espalexa based device."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data={
|
||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||
ssdp.ATTR_UPNP_FRIENDLY_NAME: "Espalexa (0.0.0.0)",
|
||||
@@ -476,7 +476,7 @@ async def test_bridge_ssdp_already_configured(hass):
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data={
|
||||
ssdp.ATTR_SSDP_LOCATION: "http://0.0.0.0/",
|
||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
||||
@@ -492,7 +492,7 @@ async def test_import_with_no_config(hass):
|
||||
"""Test importing a host without an existing config file."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "import"},
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={"host": "0.0.0.0"},
|
||||
)
|
||||
|
||||
@@ -531,7 +531,9 @@ async def test_creating_entry_removes_entries_for_same_host_or_bridge(hass):
|
||||
return_value=bridge,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"hue", data={"host": "2.2.2.2"}, context={"source": "import"}
|
||||
"hue",
|
||||
data={"host": "2.2.2.2"},
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
@@ -561,7 +563,7 @@ async def test_bridge_homekit(hass, aioclient_mock):
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "homekit"},
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={
|
||||
"host": "0.0.0.0",
|
||||
"serial": "1234",
|
||||
@@ -589,7 +591,7 @@ async def test_bridge_import_already_configured(hass):
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "import"},
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
||||
)
|
||||
|
||||
@@ -605,7 +607,7 @@ async def test_bridge_homekit_already_configured(hass):
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "homekit"},
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
|
||||
)
|
||||
|
||||
@@ -622,7 +624,7 @@ async def test_ssdp_discovery_update_configuration(hass):
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN,
|
||||
context={"source": "ssdp"},
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data={
|
||||
ssdp.ATTR_SSDP_LOCATION: "http://1.1.1.1/",
|
||||
ssdp.ATTR_UPNP_MANUFACTURER_URL: config_flow.HUE_MANUFACTURERURL[0],
|
||||
|
||||
Reference in New Issue
Block a user