Improve test coverage for ESPHome manager (#120400)

This commit is contained in:
J. Nick Koston 2024-06-25 13:14:11 +02:00 committed by GitHub
parent 76e890865e
commit c15718519b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 54 additions and 6 deletions

View file

@ -1156,3 +1156,28 @@ async def test_start_reauth(
assert len(flows) == 1
flow = flows[0]
assert flow["context"]["source"] == "reauth"
async def test_entry_missing_unique_id(
hass: HomeAssistant,
mock_client: APIClient,
mock_esphome_device: Callable[
[APIClient, list[EntityInfo], list[UserService], list[EntityState]],
Awaitable[MockESPHomeDevice],
],
) -> None:
"""Test the unique id is added from storage if available."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=None,
data={
CONF_HOST: "test.local",
CONF_PORT: 6053,
CONF_PASSWORD: "",
},
options={CONF_ALLOW_SERVICE_CALLS: True},
)
entry.add_to_hass(hass)
await mock_esphome_device(mock_client=mock_client, mock_storage=True)
await hass.async_block_till_done()
assert entry.unique_id == "11:22:33:44:55:aa"