mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
ConfigSubEntryFlow _get_reconfigure_entry() -> _get_entry() (#141017)
* ConfigSubEntryFlow _get_reconfigure_entry() -> _get_entry() * Update MQTT test * Fix test_config_entries * Minimize changes to keep existing tests working * Re-revert and update negative test instead
This commit is contained in:
@@ -6566,7 +6566,7 @@ async def test_update_subentry_and_abort(
|
||||
class SubentryFlowHandler(config_entries.ConfigSubentryFlow):
|
||||
async def async_step_reconfigure(self, user_input=None):
|
||||
return self.async_update_and_abort(
|
||||
self._get_reconfigure_entry(),
|
||||
self._get_entry(),
|
||||
self._get_reconfigure_subentry(),
|
||||
**kwargs,
|
||||
)
|
||||
@@ -8158,10 +8158,10 @@ async def test_get_reconfigure_entry(
|
||||
assert result["reason"] == "Source is user, expected reconfigure: -"
|
||||
|
||||
|
||||
async def test_subentry_get_reconfigure_entry(
|
||||
async def test_subentry_get_entry(
|
||||
hass: HomeAssistant, manager: config_entries.ConfigEntries
|
||||
) -> None:
|
||||
"""Test subentry _get_reconfigure_entry and _get_reconfigure_subentry behavior."""
|
||||
"""Test subentry _get_entry and _get_reconfigure_subentry behavior."""
|
||||
subentry_id = "mock_subentry_id"
|
||||
entry = MockConfigEntry(
|
||||
data={},
|
||||
@@ -8198,13 +8198,13 @@ async def test_subentry_get_reconfigure_entry(
|
||||
async def _async_step_confirm(self):
|
||||
"""Confirm input."""
|
||||
try:
|
||||
entry = self._get_reconfigure_entry()
|
||||
entry = self._get_entry()
|
||||
except ValueError as err:
|
||||
reason = str(err)
|
||||
else:
|
||||
reason = f"Found entry {entry.title}"
|
||||
try:
|
||||
entry_id = self._reconfigure_entry_id
|
||||
entry_id = self._entry_id
|
||||
except ValueError:
|
||||
reason = f"{reason}: -"
|
||||
else:
|
||||
@@ -8233,7 +8233,7 @@ async def test_subentry_get_reconfigure_entry(
|
||||
) -> dict[str, type[config_entries.ConfigSubentryFlow]]:
|
||||
return {"test": TestFlow.SubentryFlowHandler}
|
||||
|
||||
# A reconfigure flow finds the config entry
|
||||
# A reconfigure flow finds the config entry and subentry
|
||||
with mock_config_flow("test", TestFlow):
|
||||
result = await entry.start_subentry_reconfigure_flow(hass, "test", subentry_id)
|
||||
assert (
|
||||
@@ -8255,14 +8255,14 @@ async def test_subentry_get_reconfigure_entry(
|
||||
== "Found entry entry_title: mock_entry_id/Subentry not found: 01JRemoved"
|
||||
)
|
||||
|
||||
# A user flow does not have access to the config entry or subentry
|
||||
# A user flow finds the config entry but not the subentry
|
||||
with mock_config_flow("test", TestFlow):
|
||||
result = await manager.subentries.async_init(
|
||||
(entry.entry_id, "test"), context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert (
|
||||
result["reason"]
|
||||
== "Source is user, expected reconfigure: -/Source is user, expected reconfigure: -"
|
||||
== "Found entry entry_title: mock_entry_id/Source is user, expected reconfigure: -"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user