Skip to content

Commit 37152a2

Browse files
authored
Remove old migration from Tuya (home-assistant#157237)
1 parent 5025af8 commit 37152a2

File tree

5 files changed

+8
-98
lines changed

5 files changed

+8
-98
lines changed

homeassistant/components/tuya/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from homeassistant.helpers.dispatcher import dispatcher_send
2020

2121
from .const import (
22-
CONF_APP_TYPE,
2322
CONF_ENDPOINT,
2423
CONF_TERMINAL_ID,
2524
CONF_TOKEN_INFO,
@@ -47,9 +46,6 @@ class HomeAssistantTuyaData(NamedTuple):
4746

4847
async def async_setup_entry(hass: HomeAssistant, entry: TuyaConfigEntry) -> bool:
4948
"""Async setup hass config entry."""
50-
if CONF_APP_TYPE in entry.data:
51-
raise ConfigEntryAuthFailed("Authentication failed. Please re-authenticate.")
52-
5349
token_listener = TokenListener(hass, entry)
5450
manager = Manager(
5551
TUYA_CLIENT_ID,

homeassistant/components/tuya/const.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
DOMAIN = "tuya"
3131
LOGGER = logging.getLogger(__package__)
3232

33-
CONF_APP_TYPE = "tuya_app_type"
3433
CONF_ENDPOINT = "endpoint"
3534
CONF_TERMINAL_ID = "terminal_id"
3635
CONF_TOKEN_INFO = "token_info"

tests/components/tuya/conftest.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
)
1616

1717
from homeassistant.components.tuya.const import (
18-
CONF_APP_TYPE,
1918
CONF_ENDPOINT,
2019
CONF_TERMINAL_ID,
2120
CONF_TOKEN_INFO,
@@ -31,17 +30,6 @@
3130
from tests.common import MockConfigEntry, async_load_json_object_fixture
3231

3332

34-
@pytest.fixture
35-
def mock_old_config_entry() -> MockConfigEntry:
36-
"""Mock an old config entry that can be migrated."""
37-
return MockConfigEntry(
38-
title="Old Tuya configuration entry",
39-
domain=DOMAIN,
40-
data={CONF_APP_TYPE: "tuyaSmart"},
41-
unique_id="12345",
42-
)
43-
44-
4533
@pytest.fixture
4634
def mock_config_entry() -> MockConfigEntry:
4735
"""Mock a config entry."""

tests/components/tuya/snapshots/test_config_flow.ambr

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,6 @@
3131
'version': 1,
3232
})
3333
# ---
34-
# name: test_reauth_flow_migration
35-
ConfigEntrySnapshot({
36-
'data': dict({
37-
'endpoint': 'mocked_endpoint',
38-
'terminal_id': 'mocked_terminal_id',
39-
'token_info': dict({
40-
'access_token': 'mocked_access_token',
41-
'expire_time': 'mocked_expire_time',
42-
'refresh_token': 'mocked_refresh_token',
43-
't': 'mocked_t',
44-
'uid': 'mocked_uid',
45-
}),
46-
'user_code': '12345',
47-
}),
48-
'disabled_by': None,
49-
'discovery_keys': dict({
50-
}),
51-
'domain': 'tuya',
52-
'entry_id': <ANY>,
53-
'minor_version': 1,
54-
'options': dict({
55-
}),
56-
'pref_disable_new_entities': False,
57-
'pref_disable_polling': False,
58-
'source': 'user',
59-
'subentries': list([
60-
]),
61-
'title': 'Old Tuya configuration entry',
62-
'unique_id': '12345',
63-
'version': 1,
64-
})
65-
# ---
6634
# name: test_user_flow
6735
FlowResultSnapshot({
6836
'context': dict({

tests/components/tuya/test_config_flow.py

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88
from syrupy.assertion import SnapshotAssertion
99

10-
from homeassistant.components.tuya.const import CONF_APP_TYPE, CONF_USER_CODE, DOMAIN
10+
from homeassistant.components.tuya.const import CONF_USER_CODE, DOMAIN
1111
from homeassistant.config_entries import SOURCE_USER
1212
from homeassistant.core import HomeAssistant
1313
from homeassistant.data_entry_flow import FlowResultType
@@ -161,63 +161,22 @@ async def test_reauth_flow(
161161
assert mock_config_entry == snapshot
162162

163163

164-
@pytest.mark.usefixtures("mock_tuya_login_control")
165-
async def test_reauth_flow_migration(
166-
hass: HomeAssistant,
167-
mock_old_config_entry: MockConfigEntry,
168-
snapshot: SnapshotAssertion,
169-
) -> None:
170-
"""Test the reauthentication configuration flow.
171-
172-
This flow tests the migration from an old config entry.
173-
"""
174-
mock_old_config_entry.add_to_hass(hass)
175-
176-
# Ensure old data is there, new data is missing
177-
assert CONF_APP_TYPE in mock_old_config_entry.data
178-
assert CONF_USER_CODE not in mock_old_config_entry.data
179-
180-
result = await mock_old_config_entry.start_reauth_flow(hass)
181-
182-
assert result.get("type") is FlowResultType.FORM
183-
assert result.get("step_id") == "reauth_user_code"
184-
185-
result2 = await hass.config_entries.flow.async_configure(
186-
result["flow_id"],
187-
user_input={CONF_USER_CODE: "12345"},
188-
)
189-
190-
assert result2.get("type") is FlowResultType.FORM
191-
assert result2.get("step_id") == "scan"
192-
193-
result3 = await hass.config_entries.flow.async_configure(
194-
result["flow_id"],
195-
user_input={},
196-
)
197-
198-
assert result3.get("type") is FlowResultType.ABORT
199-
assert result3.get("reason") == "reauth_successful"
200-
201-
# Ensure the old data is gone, new data is present
202-
assert CONF_APP_TYPE not in mock_old_config_entry.data
203-
assert CONF_USER_CODE in mock_old_config_entry.data
204-
205-
assert mock_old_config_entry == snapshot
206-
207-
208164
async def test_reauth_flow_failed_qr_code(
209165
hass: HomeAssistant,
210166
mock_tuya_login_control: MagicMock,
211-
mock_old_config_entry: MockConfigEntry,
167+
mock_config_entry: MockConfigEntry,
212168
) -> None:
213169
"""Test an error occurring while retrieving the QR code."""
214-
mock_old_config_entry.add_to_hass(hass)
215-
216-
result = await mock_old_config_entry.start_reauth_flow(hass)
170+
mock_config_entry.add_to_hass(hass)
217171

218172
# Something went wrong getting the QR code (like an invalid user code)
219173
mock_tuya_login_control.qr_code.return_value["success"] = False
220174

175+
result = await mock_config_entry.start_reauth_flow(hass)
176+
177+
assert result.get("type") is FlowResultType.FORM
178+
assert result.get("step_id") == "reauth_user_code"
179+
221180
result2 = await hass.config_entries.flow.async_configure(
222181
result["flow_id"],
223182
user_input={CONF_USER_CODE: "12345"},

0 commit comments

Comments
 (0)