From a013a79eadad1567469238dce8a080b325621e4a Mon Sep 17 00:00:00 2001 From: Artem Khvastunov Date: Sun, 5 Jan 2025 10:46:39 +0100 Subject: [PATCH] Migrate to FlowResultType in tests --- requirements_dev.txt | 2 +- requirements_test.txt | 2 +- tests/test_config_flow.py | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 497e59a..e299d6f 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,2 +1,2 @@ -r requirements.txt -homeassistant>=2024.12.0 +homeassistant>=2025.1.0 diff --git a/requirements_test.txt b/requirements_test.txt index 27a87bd..025697d 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,2 +1,2 @@ -r requirements_dev.txt -pytest-homeassistant-custom-component>=0.13.107 +pytest-homeassistant-custom-component>=0.13.201 diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 7b96f2a..1b76548 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -4,7 +4,7 @@ import pytest from homeassistant import config_entries -from homeassistant import data_entry_flow +from homeassistant.data_entry_flow import FlowResultType from pytest_homeassistant_custom_component.common import MockConfigEntry from custom_components.tk_husteblume import CONF_PASSWORD @@ -46,7 +46,7 @@ async def test_successful_config_flow( ) # Check that the config flow shows the user form as the first step - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" # If a user were to enter `test_username` for username and `test_password` @@ -57,7 +57,7 @@ async def test_successful_config_flow( # Check that the config flow is complete and a new entry is created with # the input data - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == "TEST_STATION test_app_id" data = result["data"] # a random password is generated @@ -79,7 +79,7 @@ async def test_failed_config_flow_stations( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "unable_to_fetch_stations" @@ -96,14 +96,14 @@ async def test_failed_config_flow_registration( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=MOCK_FORM ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["errors"] == {"base": "unable_to_register"} @@ -120,14 +120,14 @@ async def test_failed_config_flow_verification( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=MOCK_FORM ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["errors"] == {"base": "auth"} @@ -144,7 +144,7 @@ async def test_options_flow(hass, enable_custom_integrations, bypass_get_data): result = await hass.config_entries.options.async_init(entry.entry_id) # Verify that the first options step is a user form - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" # Enter some fake data into the form @@ -155,7 +155,7 @@ async def test_options_flow(hass, enable_custom_integrations, bypass_get_data): ) # Verify that the flow finishes - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == "test_app_id" # Verify that the options were updated @@ -180,7 +180,7 @@ async def test_options_flow_with_options( result = await hass.config_entries.options.async_init(entry.entry_id) # Verify that the first options step is a user form - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" # Enter some fake data into the form @@ -190,7 +190,7 @@ async def test_options_flow_with_options( ) # Verify that the flow finishes - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == "test_app_id" # If all options are true, we store an empty dict @@ -209,5 +209,5 @@ async def test_failed_options_flow(hass, enable_custom_integrations, error_on_ge result = await hass.config_entries.options.async_init(entry.entry_id) # Verify that the first options step is a user form - assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "unable_to_fetch_data"