mirror of
https://github.com/home-assistant/core.git
synced 2026-04-19 08:19:26 +01:00
Require firmware version 3.1.1 for airgradient (#118744)
This commit is contained in:
committed by
GitHub
parent
dd1dd4c6a3
commit
2a92f78453
@@ -4,6 +4,7 @@ from ipaddress import ip_address
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from airgradient import AirGradientConnectionError, ConfigurationControl
|
||||
from mashumaro import MissingField
|
||||
|
||||
from homeassistant.components.airgradient import DOMAIN
|
||||
from homeassistant.components.zeroconf import ZeroconfServiceInfo
|
||||
@@ -14,7 +15,7 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
OLD_ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("10.0.0.131"),
|
||||
ip_addresses=[ip_address("10.0.0.131")],
|
||||
hostname="airgradient_84fce612f5b8.local.",
|
||||
@@ -29,6 +30,21 @@ ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
},
|
||||
)
|
||||
|
||||
ZEROCONF_DISCOVERY = ZeroconfServiceInfo(
|
||||
ip_address=ip_address("10.0.0.131"),
|
||||
ip_addresses=[ip_address("10.0.0.131")],
|
||||
hostname="airgradient_84fce612f5b8.local.",
|
||||
name="airgradient_84fce612f5b8._airgradient._tcp.local.",
|
||||
port=80,
|
||||
type="_airgradient._tcp.local.",
|
||||
properties={
|
||||
"vendor": "AirGradient",
|
||||
"fw_ver": "3.1.1",
|
||||
"serialno": "84fce612f5b8",
|
||||
"model": "I-9PSL",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
async def test_full_flow(
|
||||
hass: HomeAssistant,
|
||||
@@ -119,6 +135,34 @@ async def test_flow_errors(
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_flow_old_firmware_version(
|
||||
hass: HomeAssistant,
|
||||
mock_airgradient_client: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test flow with old firmware version."""
|
||||
mock_airgradient_client.get_current_measures.side_effect = MissingField(
|
||||
"", object, object
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{CONF_HOST: "10.0.0.131"},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "invalid_version"
|
||||
|
||||
|
||||
async def test_duplicate(
|
||||
hass: HomeAssistant,
|
||||
mock_airgradient_client: AsyncMock,
|
||||
@@ -197,3 +241,14 @@ async def test_zeroconf_flow_cloud_device(
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
mock_cloud_airgradient_client.set_configuration_control.assert_not_called()
|
||||
|
||||
|
||||
async def test_zeroconf_flow_abort_old_firmware(hass: HomeAssistant) -> None:
|
||||
"""Test zeroconf flow aborts with old firmware."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data=OLD_ZEROCONF_DISCOVERY,
|
||||
)
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "invalid_version"
|
||||
|
||||
Reference in New Issue
Block a user