Add entity registry test to Withings (#108900)

This commit is contained in:
Joost Lekkerkerker 2024-01-26 09:33:56 +01:00 committed by GitHub
parent b91e9edd16
commit d4ac5e492b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 2213 additions and 70 deletions

View file

@ -108,6 +108,26 @@
"type": 169,
"unit": 0,
"value": 100
},
{
"type": 198,
"unit": 0,
"value": 102
},
{
"type": 197,
"unit": 0,
"value": 102
},
{
"type": 196,
"unit": 0,
"value": 102
},
{
"type": 170,
"unit": 0,
"value": 102
}
],
"modelid": 45,

View file

@ -25,6 +25,10 @@
155,
168,
169,
198,
197,
196,
170,
]),
'received_sleep_data': True,
'received_workout_data': True,
@ -57,6 +61,10 @@
155,
168,
169,
198,
197,
196,
170,
]),
'received_sleep_data': True,
'received_workout_data': True,
@ -89,6 +97,10 @@
155,
168,
169,
198,
197,
196,
170,
]),
'received_sleep_data': True,
'received_workout_data': True,

File diff suppressed because it is too large Load diff

View file

@ -58,7 +58,6 @@ async def test_api_events(
async def test_calendar_created_when_workouts_available(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
withings: AsyncMock,
polling_config_entry: MockConfigEntry,
hass_client: ClientSessionGenerator,

View file

@ -30,25 +30,24 @@ async def test_all_entities(
snapshot: SnapshotAssertion,
withings: AsyncMock,
polling_config_entry: MockConfigEntry,
entity_registry: er.EntityRegistry,
) -> None:
"""Test all entities."""
with patch("homeassistant.components.withings.PLATFORMS", [Platform.SENSOR]):
await setup_integration(hass, polling_config_entry)
entity_registry = er.async_get(hass)
entity_entries = er.async_entries_for_config_entry(
entity_registry, polling_config_entry.entry_id
)
entity_entries = er.async_entries_for_config_entry(
entity_registry, polling_config_entry.entry_id
)
assert entity_entries
for entity_entry in entity_entries:
assert hass.states.get(entity_entry.entity_id) == snapshot(
name=entity_entry.entity_id
)
assert entity_entries
for entity_entry in entity_entries:
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
assert (state := hass.states.get(entity_entry.entity_id))
assert state == snapshot(name=f"{entity_entry.entity_id}-state")
async def test_update_failed(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
withings: AsyncMock,
polling_config_entry: MockConfigEntry,
freezer: FrozenDateTimeFactory,
@ -68,7 +67,6 @@ async def test_update_failed(
async def test_update_updates_incrementally(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
withings: AsyncMock,
polling_config_entry: MockConfigEntry,
freezer: FrozenDateTimeFactory,
@ -253,7 +251,6 @@ async def test_sleep_sensors_created_when_existed(
hass: HomeAssistant,
withings: AsyncMock,
polling_config_entry: MockConfigEntry,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test sleep sensors will be added if they existed before."""
await setup_integration(hass, polling_config_entry, False)
@ -301,7 +298,6 @@ async def test_workout_sensors_created_when_existed(
hass: HomeAssistant,
withings: AsyncMock,
polling_config_entry: MockConfigEntry,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test workout sensors will be added if they existed before."""
await setup_integration(hass, polling_config_entry, False)