Allow nightly Mealie versions to pass (#121761)
* Allow invalid versions to pass * Add log warning * Change log message * Add assert for log
This commit is contained in:
parent
e8eb1ed35c
commit
131ce09490
4 changed files with 25 additions and 5 deletions
|
@ -16,7 +16,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
|||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import DOMAIN, MIN_REQUIRED_MEALIE_VERSION
|
||||
from .const import DOMAIN, LOGGER, MIN_REQUIRED_MEALIE_VERSION
|
||||
from .coordinator import (
|
||||
MealieConfigEntry,
|
||||
MealieData,
|
||||
|
@ -55,7 +55,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: MealieConfigEntry) -> bo
|
|||
except MealieConnectionError as error:
|
||||
raise ConfigEntryNotReady(error) from error
|
||||
|
||||
if not version.valid or version < MIN_REQUIRED_MEALIE_VERSION:
|
||||
if not version.valid:
|
||||
LOGGER.warning(
|
||||
"It seems like you are using the nightly version of Mealie, nightly versions could have changes that stop this integration working"
|
||||
)
|
||||
if version.valid and version < MIN_REQUIRED_MEALIE_VERSION:
|
||||
raise ConfigEntryError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="version_error",
|
||||
|
|
|
@ -55,7 +55,7 @@ class MealieConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
except Exception: # noqa: BLE001
|
||||
LOGGER.exception("Unexpected error")
|
||||
return {"base": "unknown"}, None
|
||||
if not version.valid or version < MIN_REQUIRED_MEALIE_VERSION:
|
||||
if version.valid and version < MIN_REQUIRED_MEALIE_VERSION:
|
||||
return {"base": "mealie_version"}, None
|
||||
return {}, info.user_id
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ async def test_flow_errors(
|
|||
("v1.0.0beta-5"),
|
||||
("v1.0.0-RC2"),
|
||||
("v0.1.0"),
|
||||
("something"),
|
||||
],
|
||||
)
|
||||
async def test_flow_version_error(
|
||||
|
|
|
@ -70,7 +70,6 @@ async def test_setup_failure(
|
|||
("v1.0.0beta-5"),
|
||||
("v1.0.0-RC2"),
|
||||
("v0.1.0"),
|
||||
("something"),
|
||||
],
|
||||
)
|
||||
async def test_setup_too_old(
|
||||
|
@ -87,6 +86,24 @@ async def test_setup_too_old(
|
|||
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
||||
|
||||
async def test_setup_invalid(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test setup of Mealie entry with too old version of Mealie."""
|
||||
mock_mealie_client.get_about.return_value = About(version="nightly")
|
||||
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
assert (
|
||||
"It seems like you are using the nightly version of Mealie, nightly versions could have changes that stop this integration working"
|
||||
in caplog.text
|
||||
)
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_load_unload_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_mealie_client: AsyncMock,
|
||||
|
|
Loading…
Add table
Reference in a new issue