Cleanup ESPHome update tests to avoid accessing integration internals (#141786)

We should not access DomainData directly in the test
This commit is contained in:
J. Nick Koston
2025-03-29 22:30:06 -10:00
committed by GitHub
parent 29219afb7f
commit d4970f81aa

View File

@@ -2,7 +2,7 @@
from collections.abc import Awaitable, Callable from collections.abc import Awaitable, Callable
from typing import Any from typing import Any
from unittest.mock import Mock, patch from unittest.mock import patch
from aioesphomeapi import ( from aioesphomeapi import (
APIClient, APIClient,
@@ -374,17 +374,22 @@ async def test_update_entity_dashboard_discovered_after_startup_but_update_faile
async def test_update_entity_not_present_without_dashboard( async def test_update_entity_not_present_without_dashboard(
hass: HomeAssistant, stub_reconnect, mock_config_entry, mock_device_info hass: HomeAssistant,
mock_client: APIClient,
mock_esphome_device: Callable[
[APIClient, list[EntityInfo], list[UserService], list[EntityState]],
Awaitable[MockESPHomeDevice],
],
) -> None: ) -> None:
"""Test ESPHome update entity does not get created if there is no dashboard.""" """Test ESPHome update entity does not get created if there is no dashboard."""
with patch( await mock_esphome_device(
"homeassistant.components.esphome.update.DomainData.get_entry_data", mock_client=mock_client,
return_value=Mock(available=True, device_info=mock_device_info, info={}), entity_info=[],
): user_service=[],
assert await hass.config_entries.async_setup(mock_config_entry.entry_id) states=[],
await hass.async_block_till_done() )
state = hass.states.get("update.none_firmware") state = hass.states.get("update.test_firmware")
assert state is None assert state is None