From c3845e419a3b4228842977fa57d76173ecfe443e Mon Sep 17 00:00:00 2001 From: Bram Date: Wed, 1 Jan 2025 12:18:53 +0100 Subject: [PATCH] fix: forward to post library step --- custom_components/powercalc/config_flow.py | 2 +- tests/config_flow/test_virtual_power_library.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/custom_components/powercalc/config_flow.py b/custom_components/powercalc/config_flow.py index 6d4dd5d8d..65d6922a5 100644 --- a/custom_components/powercalc/config_flow.py +++ b/custom_components/powercalc/config_flow.py @@ -1014,7 +1014,7 @@ async def _process_user_input(user_input: dict[str, Any]) -> dict[str, Any]: PowercalcFormStep( step=Step.LIBRARY_CUSTOM_FIELDS, schema=build_dynamic_field_schema(self.selected_profile), # type: ignore - # next_step=Step.POST_LIBRARY, + next_step=Step.POST_LIBRARY, validate_user_input=_process_user_input, ), user_input, diff --git a/tests/config_flow/test_virtual_power_library.py b/tests/config_flow/test_virtual_power_library.py index 102fb8b2a..1fad126be 100644 --- a/tests/config_flow/test_virtual_power_library.py +++ b/tests/config_flow/test_virtual_power_library.py @@ -7,7 +7,12 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.selector import SelectSelector -from custom_components.powercalc import CONF_CREATE_ENERGY_SENSOR, CONF_CREATE_UTILITY_METERS +from custom_components.powercalc import ( + CONF_CREATE_ENERGY_SENSOR, + CONF_CREATE_UTILITY_METERS, + CONF_ENERGY_INTEGRATION_METHOD, + DEFAULT_ENERGY_INTEGRATION_METHOD, +) from custom_components.powercalc.config_flow import ( CONF_CONFIRM_AUTODISCOVERED_MODEL, Step, @@ -229,10 +234,18 @@ async def test_profile_with_custom_fields( {"some_entity": "sensor.foobar"}, ) + assert result["type"] == data_entry_flow.FlowResultType.FORM + assert result["step_id"] == Step.POWER_ADVANCED + result = await hass.config_entries.flow.async_configure( + result["flow_id"], + {}, + ) + assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY assert result["data"] == { CONF_CREATE_ENERGY_SENSOR: True, CONF_CREATE_UTILITY_METERS: False, + CONF_ENERGY_INTEGRATION_METHOD: DEFAULT_ENERGY_INTEGRATION_METHOD, CONF_ENTITY_ID: "sensor.test", CONF_NAME: "test", CONF_MANUFACTURER: "test",