Add transmission-integration path and protocol (#104334)

This updates the config_flow migration from v1.1 to v1.2
including migration tests
This commit is contained in:
Ingmar Delsink 2024-03-21 11:05:36 +01:00 committed by GitHub
parent ff6812a798
commit 67a14d0463
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 99 additions and 10 deletions

View file

@ -11,12 +11,17 @@ from transmission_rpc.error import (
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.components.transmission.const import DOMAIN
from homeassistant.components.transmission.const import (
DEFAULT_PATH,
DEFAULT_SSL,
DOMAIN,
)
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_PATH, CONF_SSL
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import MOCK_CONFIG_DATA, OLD_MOCK_CONFIG_DATA
from . import MOCK_CONFIG_DATA, MOCK_CONFIG_DATA_VERSION_1_1, OLD_MOCK_CONFIG_DATA
from tests.common import MockConfigEntry
@ -39,6 +44,27 @@ async def test_successful_config_entry(hass: HomeAssistant) -> None:
assert entry.state == ConfigEntryState.LOADED
async def test_config_flow_entry_migrate_1_1_to_1_2(hass: HomeAssistant) -> None:
"""Test that config flow entry is migrated correctly from v1.1 to v1.2."""
entry = MockConfigEntry(
domain=DOMAIN,
data=MOCK_CONFIG_DATA_VERSION_1_1,
version=1,
minor_version=1,
)
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
# Test that config entry is at the current version.
assert entry.version == 1
assert entry.minor_version == 2
assert entry.data[CONF_SSL] == DEFAULT_SSL
assert entry.data[CONF_PATH] == DEFAULT_PATH
async def test_setup_failed_connection_error(
hass: HomeAssistant, mock_api: MagicMock
) -> None: