mirror of
https://github.com/home-assistant/core.git
synced 2025-11-14 05:20:17 +00:00
Refactor deCONZ tests (#41362)
* Use hass.config_entries.async_unload * Return config_entry from setup_deconz_integration
This commit is contained in:
@@ -199,7 +199,7 @@ async def test_manual_configuration_after_discovery_ResponseError(hass, aioclien
|
||||
|
||||
async def test_manual_configuration_update_configuration(hass, aioclient_mock):
|
||||
"""Test that manual configuration can update existing config entry."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
config_entry = await setup_deconz_integration(hass)
|
||||
|
||||
aioclient_mock.get(
|
||||
pydeconz.utils.URL_DISCOVER,
|
||||
@@ -240,7 +240,7 @@ async def test_manual_configuration_update_configuration(hass, aioclient_mock):
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert gateway.config_entry.data[CONF_HOST] == "2.3.4.5"
|
||||
assert config_entry.data[CONF_HOST] == "2.3.4.5"
|
||||
|
||||
|
||||
async def test_manual_configuration_dont_update_configuration(hass, aioclient_mock):
|
||||
@@ -436,7 +436,7 @@ async def test_ssdp_discovery_not_deconz_bridge(hass):
|
||||
|
||||
async def test_ssdp_discovery_update_configuration(hass):
|
||||
"""Test if a discovered bridge is configured but updates with new attributes."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
config_entry = await setup_deconz_integration(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.deconz.async_setup_entry",
|
||||
@@ -455,13 +455,13 @@ async def test_ssdp_discovery_update_configuration(hass):
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert gateway.config_entry.data[CONF_HOST] == "2.3.4.5"
|
||||
assert config_entry.data[CONF_HOST] == "2.3.4.5"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_ssdp_discovery_dont_update_configuration(hass):
|
||||
"""Test if a discovered bridge has already been configured."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
config_entry = await setup_deconz_integration(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -475,12 +475,12 @@ async def test_ssdp_discovery_dont_update_configuration(hass):
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert gateway.config_entry.data[CONF_HOST] == "1.2.3.4"
|
||||
assert config_entry.data[CONF_HOST] == "1.2.3.4"
|
||||
|
||||
|
||||
async def test_ssdp_discovery_dont_update_existing_hassio_configuration(hass):
|
||||
"""Test to ensure the SSDP discovery does not update an Hass.io entry."""
|
||||
gateway = await setup_deconz_integration(hass, source="hassio")
|
||||
config_entry = await setup_deconz_integration(hass, source="hassio")
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
@@ -494,7 +494,7 @@ async def test_ssdp_discovery_dont_update_existing_hassio_configuration(hass):
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert gateway.config_entry.data[CONF_HOST] == "1.2.3.4"
|
||||
assert config_entry.data[CONF_HOST] == "1.2.3.4"
|
||||
|
||||
|
||||
async def test_flow_hassio_discovery(hass):
|
||||
@@ -537,7 +537,7 @@ async def test_flow_hassio_discovery(hass):
|
||||
|
||||
async def test_hassio_discovery_update_configuration(hass):
|
||||
"""Test we can update an existing config entry."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
config_entry = await setup_deconz_integration(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.deconz.async_setup_entry",
|
||||
@@ -557,9 +557,9 @@ async def test_hassio_discovery_update_configuration(hass):
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert gateway.config_entry.data[CONF_HOST] == "2.3.4.5"
|
||||
assert gateway.config_entry.data[CONF_PORT] == 8080
|
||||
assert gateway.config_entry.data[CONF_API_KEY] == "updated"
|
||||
assert config_entry.data[CONF_HOST] == "2.3.4.5"
|
||||
assert config_entry.data[CONF_PORT] == 8080
|
||||
assert config_entry.data[CONF_API_KEY] == "updated"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
@@ -584,9 +584,9 @@ async def test_hassio_discovery_dont_update_configuration(hass):
|
||||
|
||||
async def test_option_flow(hass):
|
||||
"""Test config flow options."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
config_entry = await setup_deconz_integration(hass)
|
||||
|
||||
result = await hass.config_entries.options.async_init(gateway.config_entry.entry_id)
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "deconz_devices"
|
||||
|
||||
Reference in New Issue
Block a user