core/tests/components/tessie/test_config_flow.py

169 lines
4.9 KiB
Python
Raw Normal View History

"""Test the Tessie config flow."""
from unittest.mock import patch
Add reauth to Tessie (#105419) * First pass at Tessie * Working POC * async_step_reauth * Config Flow tests * WIP * Add test requirement * correctly gen test requirements * 100% coverage * Remove remnants of copy paste * Add TPMS * Fix docstring * Remove redundant line * Fix some more copied docstrings * Grammar * Create reusable StrEnum * Streamline get * Add a couple more sensors * Removed need for a model * Move MODELS * Remove DOMAIN from config flow * Add translation strings * Remove unused parameter * Simplify error handling * Refactor coordinator to class * Add missing types * Add icon to shift state * Simplify setdefault Co-authored-by: J. Nick Koston <nick@koston.org> * Use walrus for async_unload_platforms Co-authored-by: J. Nick Koston <nick@koston.org> * Reformat entity init Co-authored-by: J. Nick Koston <nick@koston.org> * Remove Unique ID * Better Config Flow Tests * Fix all remaining tests * Standardise docstring * Remove redudnant test * Set TessieDataUpdateCoordinator on entity * Correct some sensors * add error types * Make shift state a ENUM sensor * Add more sensors * Fix translation string * Add precision suggestions * Move session from init to coordinator * Add api_key type * Remove api_key parameter * Meta changes * Update TessieEntity and TessieSensor translations * Goodbye translation keys * bump tessie-api to 0.0.9 * Fix only_active to be True * Per vehicle coordinator * Rework coordinator * Fix coverage * WIP * The grand rework * Add comments * Use ENUM more * Add ENUM translations * Update homeassistant/components/tessie/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add entity_category * Remove reauth * Remove session * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add property tag * Add error text * Complete config flow tests * Fix property and rename * Fix init test * Reworked coordinator tests * Add extra checks * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Update homeassistant/components/tessie/coordinator.py Co-authored-by: J. Nick Koston <nick@koston.org> * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove future ENUMs Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove reauth and already configured strings * Lowercase sensor values for translation * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Fixed, before using lambda * Add value lambda * fix lambda * Fix config flow test * @bdraco fix for 500 errors * format * Add reauth * Reuse string in reauth * Ruff * remove redundant check * Improve error tests --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-10 07:37:57 +00:00
import pytest
from homeassistant import config_entries
from homeassistant.components.tessie.const import DOMAIN
from homeassistant.const import CONF_ACCESS_TOKEN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .common import (
ERROR_AUTH,
ERROR_CONNECTION,
ERROR_UNKNOWN,
TEST_CONFIG,
Add reauth to Tessie (#105419) * First pass at Tessie * Working POC * async_step_reauth * Config Flow tests * WIP * Add test requirement * correctly gen test requirements * 100% coverage * Remove remnants of copy paste * Add TPMS * Fix docstring * Remove redundant line * Fix some more copied docstrings * Grammar * Create reusable StrEnum * Streamline get * Add a couple more sensors * Removed need for a model * Move MODELS * Remove DOMAIN from config flow * Add translation strings * Remove unused parameter * Simplify error handling * Refactor coordinator to class * Add missing types * Add icon to shift state * Simplify setdefault Co-authored-by: J. Nick Koston <nick@koston.org> * Use walrus for async_unload_platforms Co-authored-by: J. Nick Koston <nick@koston.org> * Reformat entity init Co-authored-by: J. Nick Koston <nick@koston.org> * Remove Unique ID * Better Config Flow Tests * Fix all remaining tests * Standardise docstring * Remove redudnant test * Set TessieDataUpdateCoordinator on entity * Correct some sensors * add error types * Make shift state a ENUM sensor * Add more sensors * Fix translation string * Add precision suggestions * Move session from init to coordinator * Add api_key type * Remove api_key parameter * Meta changes * Update TessieEntity and TessieSensor translations * Goodbye translation keys * bump tessie-api to 0.0.9 * Fix only_active to be True * Per vehicle coordinator * Rework coordinator * Fix coverage * WIP * The grand rework * Add comments * Use ENUM more * Add ENUM translations * Update homeassistant/components/tessie/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add entity_category * Remove reauth * Remove session * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add property tag * Add error text * Complete config flow tests * Fix property and rename * Fix init test * Reworked coordinator tests * Add extra checks * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Update homeassistant/components/tessie/coordinator.py Co-authored-by: J. Nick Koston <nick@koston.org> * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove future ENUMs Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove reauth and already configured strings * Lowercase sensor values for translation * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Fixed, before using lambda * Add value lambda * fix lambda * Fix config flow test * @bdraco fix for 500 errors * format * Add reauth * Reuse string in reauth * Ruff * remove redundant check * Improve error tests --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-10 07:37:57 +00:00
setup_platform,
)
Add reauth to Tessie (#105419) * First pass at Tessie * Working POC * async_step_reauth * Config Flow tests * WIP * Add test requirement * correctly gen test requirements * 100% coverage * Remove remnants of copy paste * Add TPMS * Fix docstring * Remove redundant line * Fix some more copied docstrings * Grammar * Create reusable StrEnum * Streamline get * Add a couple more sensors * Removed need for a model * Move MODELS * Remove DOMAIN from config flow * Add translation strings * Remove unused parameter * Simplify error handling * Refactor coordinator to class * Add missing types * Add icon to shift state * Simplify setdefault Co-authored-by: J. Nick Koston <nick@koston.org> * Use walrus for async_unload_platforms Co-authored-by: J. Nick Koston <nick@koston.org> * Reformat entity init Co-authored-by: J. Nick Koston <nick@koston.org> * Remove Unique ID * Better Config Flow Tests * Fix all remaining tests * Standardise docstring * Remove redudnant test * Set TessieDataUpdateCoordinator on entity * Correct some sensors * add error types * Make shift state a ENUM sensor * Add more sensors * Fix translation string * Add precision suggestions * Move session from init to coordinator * Add api_key type * Remove api_key parameter * Meta changes * Update TessieEntity and TessieSensor translations * Goodbye translation keys * bump tessie-api to 0.0.9 * Fix only_active to be True * Per vehicle coordinator * Rework coordinator * Fix coverage * WIP * The grand rework * Add comments * Use ENUM more * Add ENUM translations * Update homeassistant/components/tessie/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add entity_category * Remove reauth * Remove session * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add property tag * Add error text * Complete config flow tests * Fix property and rename * Fix init test * Reworked coordinator tests * Add extra checks * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Update homeassistant/components/tessie/coordinator.py Co-authored-by: J. Nick Koston <nick@koston.org> * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove future ENUMs Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove reauth and already configured strings * Lowercase sensor values for translation * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Fixed, before using lambda * Add value lambda * fix lambda * Fix config flow test * @bdraco fix for 500 errors * format * Add reauth * Reuse string in reauth * Ruff * remove redundant check * Improve error tests --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-10 07:37:57 +00:00
from tests.common import MockConfigEntry
2023-12-12 06:30:54 +00:00
async def test_form(hass: HomeAssistant, mock_get_state_of_all_vehicles) -> None:
"""Test we get the form."""
result1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result1["type"] == FlowResultType.FORM
assert not result1["errors"]
with patch(
"homeassistant.components.tessie.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result1["flow_id"],
TEST_CONFIG,
)
await hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_get_state_of_all_vehicles.mock_calls) == 1
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["title"] == "Tessie"
assert result2["data"] == TEST_CONFIG
2023-12-12 06:30:54 +00:00
@pytest.mark.parametrize(
("side_effect", "error"),
[
(ERROR_AUTH, {CONF_ACCESS_TOKEN: "invalid_access_token"}),
(ERROR_UNKNOWN, {"base": "unknown"}),
(ERROR_CONNECTION, {"base": "cannot_connect"}),
],
)
async def test_form_errors(
hass: HomeAssistant, side_effect, error, mock_get_state_of_all_vehicles
) -> None:
"""Test errors are handled."""
result1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
2023-12-12 06:30:54 +00:00
mock_get_state_of_all_vehicles.side_effect = side_effect
result2 = await hass.config_entries.flow.async_configure(
result1["flow_id"],
TEST_CONFIG,
)
assert result2["type"] == FlowResultType.FORM
2023-12-12 06:30:54 +00:00
assert result2["errors"] == error
# Complete the flow
2023-12-12 06:30:54 +00:00
mock_get_state_of_all_vehicles.side_effect = None
result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"],
TEST_CONFIG,
)
assert result3["type"] == FlowResultType.CREATE_ENTRY
Add reauth to Tessie (#105419) * First pass at Tessie * Working POC * async_step_reauth * Config Flow tests * WIP * Add test requirement * correctly gen test requirements * 100% coverage * Remove remnants of copy paste * Add TPMS * Fix docstring * Remove redundant line * Fix some more copied docstrings * Grammar * Create reusable StrEnum * Streamline get * Add a couple more sensors * Removed need for a model * Move MODELS * Remove DOMAIN from config flow * Add translation strings * Remove unused parameter * Simplify error handling * Refactor coordinator to class * Add missing types * Add icon to shift state * Simplify setdefault Co-authored-by: J. Nick Koston <nick@koston.org> * Use walrus for async_unload_platforms Co-authored-by: J. Nick Koston <nick@koston.org> * Reformat entity init Co-authored-by: J. Nick Koston <nick@koston.org> * Remove Unique ID * Better Config Flow Tests * Fix all remaining tests * Standardise docstring * Remove redudnant test * Set TessieDataUpdateCoordinator on entity * Correct some sensors * add error types * Make shift state a ENUM sensor * Add more sensors * Fix translation string * Add precision suggestions * Move session from init to coordinator * Add api_key type * Remove api_key parameter * Meta changes * Update TessieEntity and TessieSensor translations * Goodbye translation keys * bump tessie-api to 0.0.9 * Fix only_active to be True * Per vehicle coordinator * Rework coordinator * Fix coverage * WIP * The grand rework * Add comments * Use ENUM more * Add ENUM translations * Update homeassistant/components/tessie/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add entity_category * Remove reauth * Remove session * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add property tag * Add error text * Complete config flow tests * Fix property and rename * Fix init test * Reworked coordinator tests * Add extra checks * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Update homeassistant/components/tessie/coordinator.py Co-authored-by: J. Nick Koston <nick@koston.org> * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove future ENUMs Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove reauth and already configured strings * Lowercase sensor values for translation * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Fixed, before using lambda * Add value lambda * fix lambda * Fix config flow test * @bdraco fix for 500 errors * format * Add reauth * Reuse string in reauth * Ruff * remove redundant check * Improve error tests --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-10 07:37:57 +00:00
async def test_reauth(hass: HomeAssistant, mock_get_state_of_all_vehicles) -> None:
"""Test reauth flow."""
mock_entry = MockConfigEntry(
domain=DOMAIN,
data=TEST_CONFIG,
)
mock_entry.add_to_hass(hass)
result1 = await hass.config_entries.flow.async_init(
DOMAIN,
context={
"source": config_entries.SOURCE_REAUTH,
"entry_id": mock_entry.entry_id,
},
data=TEST_CONFIG,
)
assert result1["type"] == FlowResultType.FORM
assert result1["step_id"] == "reauth_confirm"
assert not result1["errors"]
with patch(
"homeassistant.components.tessie.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result1["flow_id"],
TEST_CONFIG,
)
await hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_get_state_of_all_vehicles.mock_calls) == 1
assert result2["type"] == FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
assert mock_entry.data == TEST_CONFIG
@pytest.mark.parametrize(
("side_effect", "error"),
[
2023-12-12 06:30:54 +00:00
(ERROR_AUTH, {CONF_ACCESS_TOKEN: "invalid_access_token"}),
Add reauth to Tessie (#105419) * First pass at Tessie * Working POC * async_step_reauth * Config Flow tests * WIP * Add test requirement * correctly gen test requirements * 100% coverage * Remove remnants of copy paste * Add TPMS * Fix docstring * Remove redundant line * Fix some more copied docstrings * Grammar * Create reusable StrEnum * Streamline get * Add a couple more sensors * Removed need for a model * Move MODELS * Remove DOMAIN from config flow * Add translation strings * Remove unused parameter * Simplify error handling * Refactor coordinator to class * Add missing types * Add icon to shift state * Simplify setdefault Co-authored-by: J. Nick Koston <nick@koston.org> * Use walrus for async_unload_platforms Co-authored-by: J. Nick Koston <nick@koston.org> * Reformat entity init Co-authored-by: J. Nick Koston <nick@koston.org> * Remove Unique ID * Better Config Flow Tests * Fix all remaining tests * Standardise docstring * Remove redudnant test * Set TessieDataUpdateCoordinator on entity * Correct some sensors * add error types * Make shift state a ENUM sensor * Add more sensors * Fix translation string * Add precision suggestions * Move session from init to coordinator * Add api_key type * Remove api_key parameter * Meta changes * Update TessieEntity and TessieSensor translations * Goodbye translation keys * bump tessie-api to 0.0.9 * Fix only_active to be True * Per vehicle coordinator * Rework coordinator * Fix coverage * WIP * The grand rework * Add comments * Use ENUM more * Add ENUM translations * Update homeassistant/components/tessie/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add entity_category * Remove reauth * Remove session * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add property tag * Add error text * Complete config flow tests * Fix property and rename * Fix init test * Reworked coordinator tests * Add extra checks * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Update homeassistant/components/tessie/coordinator.py Co-authored-by: J. Nick Koston <nick@koston.org> * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove future ENUMs Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove reauth and already configured strings * Lowercase sensor values for translation * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Fixed, before using lambda * Add value lambda * fix lambda * Fix config flow test * @bdraco fix for 500 errors * format * Add reauth * Reuse string in reauth * Ruff * remove redundant check * Improve error tests --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-10 07:37:57 +00:00
(ERROR_UNKNOWN, {"base": "unknown"}),
(ERROR_CONNECTION, {"base": "cannot_connect"}),
],
)
async def test_reauth_errors(
hass: HomeAssistant, mock_get_state_of_all_vehicles, side_effect, error
) -> None:
"""Test reauth flows that fail."""
Add reauth to Tessie (#105419) * First pass at Tessie * Working POC * async_step_reauth * Config Flow tests * WIP * Add test requirement * correctly gen test requirements * 100% coverage * Remove remnants of copy paste * Add TPMS * Fix docstring * Remove redundant line * Fix some more copied docstrings * Grammar * Create reusable StrEnum * Streamline get * Add a couple more sensors * Removed need for a model * Move MODELS * Remove DOMAIN from config flow * Add translation strings * Remove unused parameter * Simplify error handling * Refactor coordinator to class * Add missing types * Add icon to shift state * Simplify setdefault Co-authored-by: J. Nick Koston <nick@koston.org> * Use walrus for async_unload_platforms Co-authored-by: J. Nick Koston <nick@koston.org> * Reformat entity init Co-authored-by: J. Nick Koston <nick@koston.org> * Remove Unique ID * Better Config Flow Tests * Fix all remaining tests * Standardise docstring * Remove redudnant test * Set TessieDataUpdateCoordinator on entity * Correct some sensors * add error types * Make shift state a ENUM sensor * Add more sensors * Fix translation string * Add precision suggestions * Move session from init to coordinator * Add api_key type * Remove api_key parameter * Meta changes * Update TessieEntity and TessieSensor translations * Goodbye translation keys * bump tessie-api to 0.0.9 * Fix only_active to be True * Per vehicle coordinator * Rework coordinator * Fix coverage * WIP * The grand rework * Add comments * Use ENUM more * Add ENUM translations * Update homeassistant/components/tessie/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add entity_category * Remove reauth * Remove session * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add property tag * Add error text * Complete config flow tests * Fix property and rename * Fix init test * Reworked coordinator tests * Add extra checks * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Update homeassistant/components/tessie/coordinator.py Co-authored-by: J. Nick Koston <nick@koston.org> * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove future ENUMs Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove reauth and already configured strings * Lowercase sensor values for translation * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Fixed, before using lambda * Add value lambda * fix lambda * Fix config flow test * @bdraco fix for 500 errors * format * Add reauth * Reuse string in reauth * Ruff * remove redundant check * Improve error tests --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-10 07:37:57 +00:00
mock_entry = await setup_platform(hass, [Platform.BINARY_SENSOR])
Add reauth to Tessie (#105419) * First pass at Tessie * Working POC * async_step_reauth * Config Flow tests * WIP * Add test requirement * correctly gen test requirements * 100% coverage * Remove remnants of copy paste * Add TPMS * Fix docstring * Remove redundant line * Fix some more copied docstrings * Grammar * Create reusable StrEnum * Streamline get * Add a couple more sensors * Removed need for a model * Move MODELS * Remove DOMAIN from config flow * Add translation strings * Remove unused parameter * Simplify error handling * Refactor coordinator to class * Add missing types * Add icon to shift state * Simplify setdefault Co-authored-by: J. Nick Koston <nick@koston.org> * Use walrus for async_unload_platforms Co-authored-by: J. Nick Koston <nick@koston.org> * Reformat entity init Co-authored-by: J. Nick Koston <nick@koston.org> * Remove Unique ID * Better Config Flow Tests * Fix all remaining tests * Standardise docstring * Remove redudnant test * Set TessieDataUpdateCoordinator on entity * Correct some sensors * add error types * Make shift state a ENUM sensor * Add more sensors * Fix translation string * Add precision suggestions * Move session from init to coordinator * Add api_key type * Remove api_key parameter * Meta changes * Update TessieEntity and TessieSensor translations * Goodbye translation keys * bump tessie-api to 0.0.9 * Fix only_active to be True * Per vehicle coordinator * Rework coordinator * Fix coverage * WIP * The grand rework * Add comments * Use ENUM more * Add ENUM translations * Update homeassistant/components/tessie/sensor.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add entity_category * Remove reauth * Remove session * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Add property tag * Add error text * Complete config flow tests * Fix property and rename * Fix init test * Reworked coordinator tests * Add extra checks * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Update homeassistant/components/tessie/coordinator.py Co-authored-by: J. Nick Koston <nick@koston.org> * Apply suggestions from code review Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove future ENUMs Co-authored-by: J. Nick Koston <nick@koston.org> * Ruff fix * Update homeassistant/components/tessie/config_flow.py Co-authored-by: J. Nick Koston <nick@koston.org> * Remove reauth and already configured strings * Lowercase sensor values for translation * Update homeassistant/components/tessie/__init__.py Co-authored-by: J. Nick Koston <nick@koston.org> * Fixed, before using lambda * Add value lambda * fix lambda * Fix config flow test * @bdraco fix for 500 errors * format * Add reauth * Reuse string in reauth * Ruff * remove redundant check * Improve error tests --------- Co-authored-by: J. Nick Koston <nick@koston.org>
2023-12-10 07:37:57 +00:00
mock_get_state_of_all_vehicles.side_effect = side_effect
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={
"source": config_entries.SOURCE_REAUTH,
"unique_id": mock_entry.unique_id,
"entry_id": mock_entry.entry_id,
},
data=TEST_CONFIG,
)
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
TEST_CONFIG,
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["errors"] == error
# Complete the flow
mock_get_state_of_all_vehicles.side_effect = None
result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"],
TEST_CONFIG,
)
assert "errors" not in result3
assert result3["type"] == FlowResultType.ABORT
assert result3["reason"] == "reauth_successful"
assert mock_entry.data == TEST_CONFIG