Tweaks to options flow (#25969)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-08-15 14:11:55 -07:00
1 parent 9b3aa9bbd1
commit 8a1ab8c0b5
4 files changed
+28 -21

No files matched your search

+6 -14
View File
@@ -488,12 +488,8 @@ async def test_options_flow(hass, client):
class TestFlow(core_ce.ConfigFlow):
@staticmethod
@callback
def async_get_options_flow(config, options):
def async_get_options_flow(config_entry):
class OptionsFlowHandler(data_entry_flow.FlowHandler):
def __init__(self, config, options):
self.config = config
self.options = options
async def async_step_init(self, user_input=None):
schema = OrderedDict()
schema[vol.Required("enabled")] = bool
@@ -503,7 +499,7 @@ async def test_options_flow(hass, client):
description_placeholders={"enabled": "Set to true to be true"},
)
return OptionsFlowHandler(config, options)
return OptionsFlowHandler()
MockConfigEntry(
domain="test",
@@ -514,7 +510,7 @@ async def test_options_flow(hass, client):
entry = hass.config_entries._entries[0]
with patch.dict(HANDLERS, {"test": TestFlow}):
url = "/api/config/config_entries/entry/option/flow"
url = "/api/config/config_entries/options/flow"
resp = await client.post(url, json={"handler": entry.entry_id})
assert resp.status == 200
@@ -538,12 +534,8 @@ async def test_two_step_options_flow(hass, client):
class TestFlow(core_ce.ConfigFlow):
@staticmethod
@callback
def async_get_options_flow(config, options):
def async_get_options_flow(config_entry):
class OptionsFlowHandler(data_entry_flow.FlowHandler):
def __init__(self, config, options):
self.config = config
self.options = options
async def async_step_init(self, user_input=None):
return self.async_show_form(
step_id="finish", data_schema=vol.Schema({"enabled": bool})
@@ -554,7 +546,7 @@ async def test_two_step_options_flow(hass, client):
title="Enable disable", data=user_input
)
return OptionsFlowHandler(config, options)
return OptionsFlowHandler()
MockConfigEntry(
domain="test",
@@ -565,7 +557,7 @@ async def test_two_step_options_flow(hass, client):
entry = hass.config_entries._entries[0]
with patch.dict(HANDLERS, {"test": TestFlow}):
url = "/api/config/config_entries/entry/option/flow"
url = "/api/config/config_entries/options/flow"
resp = await client.post(url, json={"handler": entry.entry_id})
assert resp.status == 200
+3 -4
View File
@@ -666,12 +666,11 @@ async def test_entry_options(hass, manager):
class TestFlow:
@staticmethod
@callback
def async_get_options_flow(config, options):
def async_get_options_flow(config_entry):
class OptionsFlowHandler(data_entry_flow.FlowHandler):
def __init__(self, config, options):
pass
pass
return OptionsFlowHandler(config, options)
return OptionsFlowHandler()
config_entries.HANDLERS["test"] = TestFlow()
flow = await manager.options._async_create_flow(