mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Use mock_config_flow helper in config_entries tests (#117241)
This commit is contained in:
parent
5c1f6aeb60
commit
021b057a87
@ -1407,7 +1407,7 @@ async def test_entry_options(
|
|||||||
entry = MockConfigEntry(domain="test", data={"first": True}, options=None)
|
entry = MockConfigEntry(domain="test", data={"first": True}, options=None)
|
||||||
entry.add_to_manager(manager)
|
entry.add_to_manager(manager)
|
||||||
|
|
||||||
class TestFlow:
|
class TestFlow(config_entries.ConfigFlow):
|
||||||
"""Test flow."""
|
"""Test flow."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -1420,11 +1420,7 @@ async def test_entry_options(
|
|||||||
|
|
||||||
return OptionsFlowHandler()
|
return OptionsFlowHandler()
|
||||||
|
|
||||||
def async_supports_options_flow(self, entry: MockConfigEntry) -> bool:
|
with mock_config_flow("test", TestFlow):
|
||||||
"""Test options flow."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
config_entries.HANDLERS["test"] = TestFlow()
|
|
||||||
flow = await manager.options.async_create_flow(
|
flow = await manager.options.async_create_flow(
|
||||||
entry.entry_id, context={"source": "test"}, data=None
|
entry.entry_id, context={"source": "test"}, data=None
|
||||||
)
|
)
|
||||||
@ -1433,7 +1429,10 @@ async def test_entry_options(
|
|||||||
|
|
||||||
await manager.options.async_finish_flow(
|
await manager.options.async_finish_flow(
|
||||||
flow,
|
flow,
|
||||||
{"data": {"second": True}, "type": data_entry_flow.FlowResultType.CREATE_ENTRY},
|
{
|
||||||
|
"data": {"second": True},
|
||||||
|
"type": data_entry_flow.FlowResultType.CREATE_ENTRY,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert entry.data == {"first": True}
|
assert entry.data == {"first": True}
|
||||||
@ -1450,7 +1449,7 @@ async def test_entry_options_abort(
|
|||||||
entry = MockConfigEntry(domain="test", data={"first": True}, options=None)
|
entry = MockConfigEntry(domain="test", data={"first": True}, options=None)
|
||||||
entry.add_to_manager(manager)
|
entry.add_to_manager(manager)
|
||||||
|
|
||||||
class TestFlow:
|
class TestFlow(config_entries.ConfigFlow):
|
||||||
"""Test flow."""
|
"""Test flow."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -1463,7 +1462,7 @@ async def test_entry_options_abort(
|
|||||||
|
|
||||||
return OptionsFlowHandler()
|
return OptionsFlowHandler()
|
||||||
|
|
||||||
config_entries.HANDLERS["test"] = TestFlow()
|
with mock_config_flow("test", TestFlow):
|
||||||
flow = await manager.options.async_create_flow(
|
flow = await manager.options.async_create_flow(
|
||||||
entry.entry_id, context={"source": "test"}, data=None
|
entry.entry_id, context={"source": "test"}, data=None
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user