From 820f4c36e45572bc45973be80e23f1d3c95825c7 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 25 Sep 2023 07:13:01 -0600 Subject: [PATCH 1/4] Ignore commit --- custom_components/frigate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/frigate/__init__.py b/custom_components/frigate/__init__.py index b4ad5177..c2b7b431 100644 --- a/custom_components/frigate/__init__.py +++ b/custom_components/frigate/__init__.py @@ -196,7 +196,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: except FrigateApiClientError as exc: raise ConfigEntryNotReady from exc - if AwesomeVersion(server_version) <= AwesomeVersion(FRIGATE_VERSION_ERROR_CUTOFF): + if AwesomeVersion(server_version.split('-')[0]) <= AwesomeVersion(FRIGATE_VERSION_ERROR_CUTOFF): _LOGGER.error( "Using a Frigate server (%s) with version %s <= %s which is not " "compatible -- you must upgrade: %s", From 6738825c036cc1888cdab0c28953eba88e7767fb Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Mon, 25 Sep 2023 07:18:00 -0600 Subject: [PATCH 2/4] Add test --- tests/test_init.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_init.py b/tests/test_init.py index 243659dd..bc4a1ac1 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -89,6 +89,17 @@ async def test_entry_async_get_version_incompatible(hass: HomeAssistant) -> None assert config_entry.state == ConfigEntryState.SETUP_ERROR +async def test_entry_async_get_version_compatible_leading_zero(hass: HomeAssistant) -> None: + """Test running an incompatible server version.""" + + client = create_mock_frigate_client() + client.async_get_version = AsyncMock(return_value="0.13.0-0858859") + + config_entry = await setup_mock_frigate_config_entry(hass, client=client) + print(config_entry.state) + assert config_entry.state == ConfigEntryState.LOADED + + async def test_entry_migration_v1_to_v2(hass: HomeAssistant) -> None: """Test migrating a config entry.""" entity_registry = er.async_get(hass) From 766d1363ac347d7352604fc9b40dcecb2e2b2661 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Mon, 25 Sep 2023 07:29:09 -0600 Subject: [PATCH 3/4] Formatting --- custom_components/frigate/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/frigate/__init__.py b/custom_components/frigate/__init__.py index c2b7b431..324aae66 100644 --- a/custom_components/frigate/__init__.py +++ b/custom_components/frigate/__init__.py @@ -196,7 +196,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: except FrigateApiClientError as exc: raise ConfigEntryNotReady from exc - if AwesomeVersion(server_version.split('-')[0]) <= AwesomeVersion(FRIGATE_VERSION_ERROR_CUTOFF): + if AwesomeVersion(server_version.split("-")[0]) <= AwesomeVersion( + FRIGATE_VERSION_ERROR_CUTOFF + ): _LOGGER.error( "Using a Frigate server (%s) with version %s <= %s which is not " "compatible -- you must upgrade: %s", From a31922f8bad76baa3fa25b78ab7fc1fc2d814f3f Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Mon, 25 Sep 2023 07:50:46 -0600 Subject: [PATCH 4/4] Format tests --- tests/test_init.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_init.py b/tests/test_init.py index bc4a1ac1..8eac455a 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -89,7 +89,9 @@ async def test_entry_async_get_version_incompatible(hass: HomeAssistant) -> None assert config_entry.state == ConfigEntryState.SETUP_ERROR -async def test_entry_async_get_version_compatible_leading_zero(hass: HomeAssistant) -> None: +async def test_entry_async_get_version_compatible_leading_zero( + hass: HomeAssistant, +) -> None: """Test running an incompatible server version.""" client = create_mock_frigate_client()