Patch platform in Withings sensor test (#102155)

* Patch platform in Withings sensor test

* Fix feedback
This commit is contained in:
Joost Lekkerkerker 2023-10-19 11:33:31 +02:00 committed by GitHub
parent ea61160fd8
commit 857f2e1d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
"""Tests for the Withings component.""" """Tests for the Withings component."""
from datetime import timedelta from datetime import timedelta
from unittest.mock import AsyncMock from unittest.mock import AsyncMock, patch
from aiowithings import MeasurementGroup from aiowithings import MeasurementGroup
from freezegun.api import FrozenDateTimeFactory from freezegun.api import FrozenDateTimeFactory
@ -29,16 +29,16 @@ async def test_all_entities(
polling_config_entry: MockConfigEntry, polling_config_entry: MockConfigEntry,
) -> None: ) -> None:
"""Test all entities.""" """Test all entities."""
await setup_integration(hass, polling_config_entry) with patch("homeassistant.components.withings.PLATFORMS", [Platform.SENSOR]):
entity_registry = er.async_get(hass) await setup_integration(hass, polling_config_entry)
entities = er.async_entries_for_config_entry( entity_registry = er.async_get(hass)
entity_registry, polling_config_entry.entry_id entity_entries = er.async_entries_for_config_entry(
) entity_registry, polling_config_entry.entry_id
)
for entity in entities: assert entity_entries
if entity.domain == Platform.SENSOR: for entity_entry in entity_entries:
assert hass.states.get(entity.entity_id) == snapshot assert hass.states.get(entity_entry.entity_id) == snapshot
assert entities
async def test_update_failed( async def test_update_failed(