From 4d00eaca6626ae390fe7c94a87109fa31e3abd88 Mon Sep 17 00:00:00 2001 From: Sander Date: Wed, 29 Jan 2025 20:48:18 +0000 Subject: [PATCH] Improve imports --- tests/test_config_flow.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 2ef3926..1da6958 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -2,9 +2,10 @@ from unittest.mock import patch -from homeassistant import config_entries, data_entry_flow +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_PORT from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType import pytest from pytest_homeassistant_custom_component.common import MockConfigEntry @@ -33,11 +34,11 @@ async def test_successful_config_flow(hass: HomeAssistant, bypass_get_data): """Test a successful config flow.""" # Initialize a config flow result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER} + DOMAIN, context={"source": SOURCE_USER} ) # Check that the config flow shows the user form as the first step - assert result["type"] == data_entry_flow.FlowResultType.FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" # If a user were to fill in all fields, it would result in this function call @@ -47,7 +48,7 @@ async def test_successful_config_flow(hass: HomeAssistant, bypass_get_data): # Check that the config flow is complete and a new entry is created with # the input data - assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == MOCK_CONFIG[CONF_PORT] assert result["data"] == MOCK_CONFIG assert result["result"] @@ -61,17 +62,17 @@ async def test_successful_config_flow(hass: HomeAssistant, bypass_get_data): async def test_failed_config_flow(hass: HomeAssistant, error_on_get_data): """Test a failed config flow due to credential validation failure.""" result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": config_entries.SOURCE_USER} + DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == data_entry_flow.FlowResultType.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_CONFIG ) - assert result["type"] == data_entry_flow.FlowResultType.FORM + assert result["type"] == FlowResultType.FORM assert "base" in result["errors"] @@ -87,7 +88,7 @@ async def test_options_flow(hass: HomeAssistant): 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.FlowResultType.FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" # Enter some fake data into the form @@ -97,7 +98,7 @@ async def test_options_flow(hass: HomeAssistant): ) # Verify that the flow finishes - assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == MOCK_CONFIG[CONF_PORT] # Verify that the options were updated