Skip to content

Commit

Permalink
Migrate to FlowResultType in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
artspb committed Jan 5, 2025
1 parent 5b4fbd7 commit a013a79
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-r requirements.txt
homeassistant>=2024.12.0
homeassistant>=2025.1.0
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
-r requirements_dev.txt
pytest-homeassistant-custom-component>=0.13.107
pytest-homeassistant-custom-component>=0.13.201
26 changes: 13 additions & 13 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand All @@ -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
Expand All @@ -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"


Expand All @@ -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"}


Expand All @@ -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"}


Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"

0 comments on commit a013a79

Please sign in to comment.