Use mock_config_flow helper in config_entries tests (#117241)

This commit is contained in:
Erik Montnemery 2024-05-11 20:11:18 +02:00 committed by GitHub
parent 5c1f6aeb60
commit 021b057a87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
) )