Improve Airgradient config flow tests (#133594)

pull/133605/head^2
Joost Lekkerkerker 2024-12-19 19:58:33 +01:00 committed by GitHub
parent 2f77cda822
commit 52683c5f75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View File

@ -7,9 +7,7 @@ rules:
appropriate-polling: done
brands: done
common-modules: done
config-flow-test-coverage:
status: todo
comment: Missing zeroconf duplicate entry test.
config-flow-test-coverage: done
config-flow: done
dependency-transparency: done
docs-actions:

View File

@ -255,6 +255,20 @@ async def test_zeroconf_flow_abort_old_firmware(hass: HomeAssistant) -> None:
assert result["reason"] == "invalid_version"
async def test_zeroconf_flow_abort_duplicate(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
) -> None:
"""Test zeroconf flow aborts with duplicate."""
mock_config_entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_ZEROCONF},
data=ZEROCONF_DISCOVERY,
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
async def test_user_flow_works_discovery(
hass: HomeAssistant,
mock_new_airgradient_client: AsyncMock,