Skip to content

Commit

Permalink
Add missing string to tedee plus test (home-assistant#130081)
Browse files Browse the repository at this point in the history
  • Loading branch information
zweckj authored and frenck committed Nov 8, 2024
1 parent 9012b11 commit 29620ef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
3 changes: 2 additions & 1 deletion homeassistant/components/tedee/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]"
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]",
"unique_id_mismatch": "You selected a different bridge than the one this config entry was configured with, this is not allowed."
},
"error": {
"invalid_api_key": "[%key:common::config_flow::error::invalid_api_key%]",
Expand Down
37 changes: 30 additions & 7 deletions tests/components/tedee/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
TedeeDataUpdateException,
TedeeLocalAuthException,
)
from pytedee_async.bridge import TedeeBridge
import pytest

from homeassistant.components.tedee.const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.config_entries import SOURCE_USER, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_WEBHOOK_ID
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
Expand Down Expand Up @@ -134,23 +135,30 @@ async def test_reauth_flow(
assert result["reason"] == "reauth_successful"


async def test_reconfigure_flow(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_tedee: MagicMock
) -> None:
"""Test that the reconfigure flow works."""

async def __do_reconfigure_flow(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
) -> ConfigFlowResult:
"""Initialize a reconfigure flow."""
mock_config_entry.add_to_hass(hass)

reconfigure_result = await mock_config_entry.start_reconfigure_flow(hass)

assert reconfigure_result["type"] is FlowResultType.FORM
assert reconfigure_result["step_id"] == "reconfigure"

result = await hass.config_entries.flow.async_configure(
return await hass.config_entries.flow.async_configure(
reconfigure_result["flow_id"],
{CONF_LOCAL_ACCESS_TOKEN: LOCAL_ACCESS_TOKEN, CONF_HOST: "192.168.1.43"},
)


async def test_reconfigure_flow(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_tedee: MagicMock
) -> None:
"""Test that the reconfigure flow works."""

result = await __do_reconfigure_flow(hass, mock_config_entry)

assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reconfigure_successful"

Expand All @@ -162,3 +170,18 @@ async def test_reconfigure_flow(
CONF_LOCAL_ACCESS_TOKEN: LOCAL_ACCESS_TOKEN,
CONF_WEBHOOK_ID: WEBHOOK_ID,
}


async def test_reconfigure_unique_id_mismatch(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_tedee: MagicMock
) -> None:
"""Ensure reconfigure flow aborts when the bride changes."""

mock_tedee.get_local_bridge.return_value = TedeeBridge(
0, "1111-1111", "Bridge-R2D2"
)

result = await __do_reconfigure_flow(hass, mock_config_entry)

assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unique_id_mismatch"

0 comments on commit 29620ef

Please sign in to comment.