Fix parameter order in FirmwareUpdateCoordinator and use MockConfigEntry in tests

Co-authored-by: joostlek <7083755+joostlek@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-07-30 18:04:36 +00:00
parent 31c7b6b549
commit cd46541b9d
4 changed files with 7 additions and 6 deletions

View File

@ -28,9 +28,9 @@ class FirmwareUpdateCoordinator(DataUpdateCoordinator[FirmwareManifest]):
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
config_entry: ConfigEntry,
session: ClientSession, session: ClientSession,
url: str, url: str,
config_entry: ConfigEntry,
) -> None: ) -> None:
"""Initialize the firmware update coordinator.""" """Initialize the firmware update coordinator."""
super().__init__( super().__init__(

View File

@ -124,9 +124,9 @@ def _async_create_update_entity(
config_entry=config_entry, config_entry=config_entry,
update_coordinator=FirmwareUpdateCoordinator( update_coordinator=FirmwareUpdateCoordinator(
hass, hass,
config_entry,
session, session,
NABU_CASA_FIRMWARE_RELEASES_URL, NABU_CASA_FIRMWARE_RELEASES_URL,
config_entry,
), ),
entity_description=entity_description, entity_description=entity_description,
) )

View File

@ -129,9 +129,9 @@ def _async_create_update_entity(
config_entry=config_entry, config_entry=config_entry,
update_coordinator=FirmwareUpdateCoordinator( update_coordinator=FirmwareUpdateCoordinator(
hass, hass,
config_entry,
session, session,
NABU_CASA_FIRMWARE_RELEASES_URL, NABU_CASA_FIRMWARE_RELEASES_URL,
config_entry,
), ),
entity_description=entity_description, entity_description=entity_description,
) )

View File

@ -9,11 +9,12 @@ from yarl import URL
from homeassistant.components.homeassistant_hardware.coordinator import ( from homeassistant.components.homeassistant_hardware.coordinator import (
FirmwareUpdateCoordinator, FirmwareUpdateCoordinator,
) )
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from tests.common import MockConfigEntry
async def test_firmware_update_coordinator_fetching( async def test_firmware_update_coordinator_fetching(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture hass: HomeAssistant, caplog: pytest.LogCaptureFixture
@ -21,7 +22,7 @@ async def test_firmware_update_coordinator_fetching(
"""Test the firmware update coordinator loads manifests.""" """Test the firmware update coordinator loads manifests."""
session = async_get_clientsession(hass) session = async_get_clientsession(hass)
mock_config_entry = Mock(spec=ConfigEntry) mock_config_entry = MockConfigEntry()
manifest = FirmwareManifest( manifest = FirmwareManifest(
url=URL("https://example.org/firmware"), url=URL("https://example.org/firmware"),
@ -38,7 +39,7 @@ async def test_firmware_update_coordinator_fetching(
return_value=mock_client, return_value=mock_client,
): ):
coordinator = FirmwareUpdateCoordinator( coordinator = FirmwareUpdateCoordinator(
hass, session, "https://example.org/firmware", mock_config_entry hass, mock_config_entry, session, "https://example.org/firmware"
) )
listener = Mock() listener = Mock()