mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Avoid unnecessary reload in apple_tv reauth flow (#142079)
This commit is contained in:
parent
109d20978f
commit
854cae7f12
@ -20,6 +20,7 @@ import voluptuous as vol
|
|||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_IGNORE,
|
SOURCE_IGNORE,
|
||||||
|
SOURCE_REAUTH,
|
||||||
SOURCE_ZEROCONF,
|
SOURCE_ZEROCONF,
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
@ -381,7 +382,9 @@ class AppleTVConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
CONF_IDENTIFIERS: list(combined_identifiers),
|
CONF_IDENTIFIERS: list(combined_identifiers),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if entry.source != SOURCE_IGNORE:
|
# Don't reload ignored entries or in the middle of reauth,
|
||||||
|
# e.g. if the user is entering a new PIN
|
||||||
|
if entry.source != SOURCE_IGNORE and self.source != SOURCE_REAUTH:
|
||||||
self.hass.config_entries.async_schedule_reload(entry.entry_id)
|
self.hass.config_entries.async_schedule_reload(entry.entry_id)
|
||||||
if not allow_exist:
|
if not allow_exist:
|
||||||
raise DeviceAlreadyConfigured
|
raise DeviceAlreadyConfigured
|
||||||
|
@ -59,12 +59,12 @@ def use_mocked_zeroconf(mock_async_zeroconf: MagicMock) -> None:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_setup_entry() -> Generator[None]:
|
def mock_setup_entry() -> Generator[Mock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.apple_tv.async_setup_entry", return_value=True
|
"homeassistant.components.apple_tv.async_setup_entry", return_value=True
|
||||||
):
|
) as setup_entry:
|
||||||
yield
|
yield setup_entry
|
||||||
|
|
||||||
|
|
||||||
# User Flows
|
# User Flows
|
||||||
@ -1183,7 +1183,9 @@ async def test_zeroconf_mismatch(hass: HomeAssistant, mock_scan: AsyncMock) -> N
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures("mrp_device", "pairing")
|
@pytest.mark.usefixtures("mrp_device", "pairing")
|
||||||
async def test_reconfigure_update_credentials(hass: HomeAssistant) -> None:
|
async def test_reconfigure_update_credentials(
|
||||||
|
hass: HomeAssistant, mock_setup_entry: Mock
|
||||||
|
) -> None:
|
||||||
"""Test that reconfigure flow updates config entry."""
|
"""Test that reconfigure flow updates config entry."""
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain="apple_tv", unique_id="mrpid", data={"identifiers": ["mrpid"]}
|
domain="apple_tv", unique_id="mrpid", data={"identifiers": ["mrpid"]}
|
||||||
@ -1215,6 +1217,9 @@ async def test_reconfigure_update_credentials(hass: HomeAssistant) -> None:
|
|||||||
"identifiers": ["mrpid"],
|
"identifiers": ["mrpid"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user