mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Pop the mocked config flow, restore the original with mock_config_flow (#107567)
Pop the mocked config flow, restore the original if it existed
This commit is contained in:
parent
0d946c62dc
commit
20610645fb
@ -1321,8 +1321,13 @@ async def get_system_health_info(hass: HomeAssistant, domain: str) -> dict[str,
|
||||
@contextmanager
|
||||
def mock_config_flow(domain: str, config_flow: type[ConfigFlow]) -> None:
|
||||
"""Mock a config flow handler."""
|
||||
with patch.dict(config_entries.HANDLERS, {domain: config_flow}):
|
||||
original_handler = config_entries.HANDLERS.get(domain)
|
||||
config_entries.HANDLERS[domain] = config_flow
|
||||
_LOGGER.info("Adding mock config flow: %s", domain)
|
||||
yield
|
||||
config_entries.HANDLERS.pop(domain)
|
||||
if original_handler:
|
||||
config_entries.HANDLERS[domain] = original_handler
|
||||
|
||||
|
||||
def mock_integration(
|
||||
|
Loading…
x
Reference in New Issue
Block a user