mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 02:38:10 +02:00
Refactor the MQTT option and reconfigure flow (#133342)
* Move entry options to entry.options en remove broker setup from mqtt option flow * UPdate diagnostics to export both entry data and options * Parameterize entry options directly not depending on migration * Update tests to use v2 entry and add separate migration test * use start_reconfigure_flow helper * Update quality scale comment * Do minor entry upgrade, and do not force to upgrade entry * Ensure options are read from older entries * Add comment * Follow up on code review * Assert config entry version checking the broker connection * Update comment
This commit is contained in:
@ -695,7 +695,12 @@ async def test_reload_entry_with_restored_subscriptions(
|
||||
) -> None:
|
||||
"""Test reloading the config entry with with subscriptions restored."""
|
||||
# Setup the MQTT entry
|
||||
entry = MockConfigEntry(domain=mqtt.DOMAIN, data={mqtt.CONF_BROKER: "test-broker"})
|
||||
entry = MockConfigEntry(
|
||||
domain=mqtt.DOMAIN,
|
||||
data={mqtt.CONF_BROKER: "test-broker"},
|
||||
version=mqtt.CONFIG_ENTRY_VERSION,
|
||||
minor_version=mqtt.CONFIG_ENTRY_MINOR_VERSION,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
hass.config.components.add(mqtt.DOMAIN)
|
||||
with patch("homeassistant.config.load_yaml_config_file", return_value={}):
|
||||
@ -800,7 +805,10 @@ async def test_default_entry_setting_are_applied(
|
||||
|
||||
# Config entry data is incomplete but valid according the schema
|
||||
entry = MockConfigEntry(
|
||||
domain=mqtt.DOMAIN, data={"broker": "test-broker", "port": 1234}
|
||||
domain=mqtt.DOMAIN,
|
||||
data={"broker": "test-broker", "port": 1234},
|
||||
version=mqtt.CONFIG_ENTRY_VERSION,
|
||||
minor_version=mqtt.CONFIG_ENTRY_MINOR_VERSION,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
hass.config.components.add(mqtt.DOMAIN)
|
||||
@ -1614,6 +1622,8 @@ async def test_unload_config_entry(
|
||||
entry = MockConfigEntry(
|
||||
domain=mqtt.DOMAIN,
|
||||
data={mqtt.CONF_BROKER: "test-broker"},
|
||||
version=mqtt.CONFIG_ENTRY_VERSION,
|
||||
minor_version=mqtt.CONFIG_ENTRY_MINOR_VERSION,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
|
Reference in New Issue
Block a user