Allow account linking to phase out services (#75447)
This commit is contained in:
parent
fe97f6791d
commit
460837e453
2 changed files with 60 additions and 2 deletions
|
@ -11,7 +11,7 @@ from homeassistant.components.cloud import account_link
|
|||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from tests.common import async_fire_time_changed, mock_platform
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, mock_platform
|
||||
|
||||
TEST_DOMAIN = "oauth2_test"
|
||||
|
||||
|
@ -38,6 +38,18 @@ def flow_handler(hass):
|
|||
|
||||
async def test_setup_provide_implementation(hass):
|
||||
"""Test that we provide implementations."""
|
||||
legacy_entry = MockConfigEntry(
|
||||
domain="legacy",
|
||||
version=1,
|
||||
data={"auth_implementation": "cloud"},
|
||||
)
|
||||
none_cloud_entry = MockConfigEntry(
|
||||
domain="no_cloud",
|
||||
version=1,
|
||||
data={"auth_implementation": "somethingelse"},
|
||||
)
|
||||
none_cloud_entry.add_to_hass(hass)
|
||||
legacy_entry.add_to_hass(hass)
|
||||
account_link.async_setup(hass)
|
||||
|
||||
with patch(
|
||||
|
@ -45,6 +57,21 @@ async def test_setup_provide_implementation(hass):
|
|||
return_value=[
|
||||
{"service": "test", "min_version": "0.1.0"},
|
||||
{"service": "too_new", "min_version": "1000000.0.0"},
|
||||
{
|
||||
"service": "deprecated",
|
||||
"min_version": "0.1.0",
|
||||
"accepts_new_authorizations": False,
|
||||
},
|
||||
{
|
||||
"service": "legacy",
|
||||
"min_version": "0.1.0",
|
||||
"accepts_new_authorizations": False,
|
||||
},
|
||||
{
|
||||
"service": "no_cloud",
|
||||
"min_version": "0.1.0",
|
||||
"accepts_new_authorizations": False,
|
||||
},
|
||||
],
|
||||
):
|
||||
assert (
|
||||
|
@ -57,15 +84,33 @@ async def test_setup_provide_implementation(hass):
|
|||
await config_entry_oauth2_flow.async_get_implementations(hass, "too_new")
|
||||
== {}
|
||||
)
|
||||
assert (
|
||||
await config_entry_oauth2_flow.async_get_implementations(hass, "deprecated")
|
||||
== {}
|
||||
)
|
||||
assert (
|
||||
await config_entry_oauth2_flow.async_get_implementations(hass, "no_cloud")
|
||||
== {}
|
||||
)
|
||||
|
||||
implementations = await config_entry_oauth2_flow.async_get_implementations(
|
||||
hass, "test"
|
||||
)
|
||||
|
||||
legacy_implementations = (
|
||||
await config_entry_oauth2_flow.async_get_implementations(hass, "legacy")
|
||||
)
|
||||
|
||||
assert "cloud" in implementations
|
||||
assert implementations["cloud"].domain == "cloud"
|
||||
assert implementations["cloud"].service == "test"
|
||||
assert implementations["cloud"].hass is hass
|
||||
|
||||
assert "cloud" in legacy_implementations
|
||||
assert legacy_implementations["cloud"].domain == "cloud"
|
||||
assert legacy_implementations["cloud"].service == "legacy"
|
||||
assert legacy_implementations["cloud"].hass is hass
|
||||
|
||||
|
||||
async def test_get_services_cached(hass):
|
||||
"""Test that we cache services."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue