mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Adjust version comparison in HA Cloud account linking (#76978)
This commit is contained in:
parent
1aef60c81c
commit
c212fe7ca5
@ -18,6 +18,9 @@ CACHE_TIMEOUT = 3600
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CURRENT_VERSION = AwesomeVersion(HA_VERSION)
|
||||
CURRENT_PLAIN_VERSION = AwesomeVersion(
|
||||
CURRENT_VERSION.string.removesuffix(f"{CURRENT_VERSION.modifier}")
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
@ -35,7 +38,7 @@ async def async_provide_implementation(hass: HomeAssistant, domain: str):
|
||||
for service in services:
|
||||
if (
|
||||
service["service"] == domain
|
||||
and CURRENT_VERSION >= service["min_version"]
|
||||
and CURRENT_PLAIN_VERSION >= service["min_version"]
|
||||
and (
|
||||
service.get("accepts_new_authorizations", True)
|
||||
or (
|
||||
|
@ -57,6 +57,7 @@ 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": "dev", "min_version": "2022.9.0"},
|
||||
{
|
||||
"service": "deprecated",
|
||||
"min_version": "0.1.0",
|
||||
@ -73,6 +74,8 @@ async def test_setup_provide_implementation(hass):
|
||||
"accepts_new_authorizations": False,
|
||||
},
|
||||
],
|
||||
), patch(
|
||||
"homeassistant.components.cloud.account_link.HA_VERSION", "2022.9.0.dev20220817"
|
||||
):
|
||||
assert (
|
||||
await config_entry_oauth2_flow.async_get_implementations(
|
||||
@ -101,6 +104,10 @@ async def test_setup_provide_implementation(hass):
|
||||
await config_entry_oauth2_flow.async_get_implementations(hass, "legacy")
|
||||
)
|
||||
|
||||
dev_implementations = await config_entry_oauth2_flow.async_get_implementations(
|
||||
hass, "dev"
|
||||
)
|
||||
|
||||
assert "cloud" in implementations
|
||||
assert implementations["cloud"].domain == "cloud"
|
||||
assert implementations["cloud"].service == "test"
|
||||
@ -111,6 +118,11 @@ async def test_setup_provide_implementation(hass):
|
||||
assert legacy_implementations["cloud"].service == "legacy"
|
||||
assert legacy_implementations["cloud"].hass is hass
|
||||
|
||||
assert "cloud" in dev_implementations
|
||||
assert dev_implementations["cloud"].domain == "cloud"
|
||||
assert dev_implementations["cloud"].service == "dev"
|
||||
assert dev_implementations["cloud"].hass is hass
|
||||
|
||||
|
||||
async def test_get_services_cached(hass):
|
||||
"""Test that we cache services."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user