Use snapshot_platform in renault tests (#143864)

* Use snapshot_platform in renault tests

* More

* tweak

* Improve
This commit is contained in:
epenet 2025-04-30 08:08:24 +02:00 committed by GitHub
parent 34becb541a
commit dc02c37413
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 8387 additions and 11714 deletions

View File

@ -1,74 +1 @@
"""Tests for the Renault integration."""
from __future__ import annotations
from types import MappingProxyType
from homeassistant.const import ATTR_ENTITY_ID, ATTR_ICON, ATTR_STATE, STATE_UNAVAILABLE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_registry import EntityRegistry
from .const import (
ATTR_UNIQUE_ID,
DYNAMIC_ATTRIBUTES,
FIXED_ATTRIBUTES,
ICON_FOR_EMPTY_VALUES,
)
def get_no_data_icon(expected_entity: MappingProxyType):
"""Check icon attribute for inactive sensors."""
entity_id = expected_entity[ATTR_ENTITY_ID]
return ICON_FOR_EMPTY_VALUES.get(entity_id, expected_entity.get(ATTR_ICON))
def check_entities(
hass: HomeAssistant,
entity_registry: EntityRegistry,
expected_entities: MappingProxyType,
) -> None:
"""Ensure that the expected_entities are correct."""
for expected_entity in expected_entities:
entity_id = expected_entity[ATTR_ENTITY_ID]
registry_entry = entity_registry.entities.get(entity_id)
assert registry_entry is not None
assert registry_entry.unique_id == expected_entity[ATTR_UNIQUE_ID]
state = hass.states.get(entity_id)
assert state.state == expected_entity[ATTR_STATE]
for attr in FIXED_ATTRIBUTES + DYNAMIC_ATTRIBUTES:
assert state.attributes.get(attr) == expected_entity.get(attr)
def check_entities_no_data(
hass: HomeAssistant,
entity_registry: EntityRegistry,
expected_entities: MappingProxyType,
expected_state: str,
) -> None:
"""Ensure that the expected_entities are correct."""
for expected_entity in expected_entities:
entity_id = expected_entity[ATTR_ENTITY_ID]
registry_entry = entity_registry.entities.get(entity_id)
assert registry_entry is not None
assert registry_entry.unique_id == expected_entity[ATTR_UNIQUE_ID]
state = hass.states.get(entity_id)
assert state.state == expected_state
for attr in FIXED_ATTRIBUTES:
assert state.attributes.get(attr) == expected_entity.get(attr)
def check_entities_unavailable(
hass: HomeAssistant,
entity_registry: EntityRegistry,
expected_entities: MappingProxyType,
) -> None:
"""Ensure that the expected_entities are correct."""
for expected_entity in expected_entities:
entity_id = expected_entity[ATTR_ENTITY_ID]
registry_entry = entity_registry.entities.get(entity_id)
assert registry_entry is not None, f"{entity_id} not found in registry"
assert registry_entry.unique_id == expected_entity[ATTR_UNIQUE_ID]
state = hass.states.get(entity_id)
assert state.state == STATE_UNAVAILABLE
for attr in FIXED_ATTRIBUTES:
assert state.attributes.get(attr) == expected_entity.get(attr)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,445 +1,300 @@
# serializer version: 1
# name: test_device_tracker_empty[captur_fuel]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777123_location',
'unit_of_measurement': None,
# name: test_device_tracker_empty[zoe_50][device_tracker.reg_number_location-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
])
# ---
# name: test_device_tracker_empty[captur_fuel].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
])
# ---
# name: test_device_tracker_empty[captur_phev]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777123_location',
'unit_of_measurement': None,
'name': None,
'options': dict({
}),
])
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777999_location',
'unit_of_measurement': None,
})
# ---
# name: test_device_tracker_empty[captur_phev].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
# name: test_device_tracker_empty[zoe_50][device_tracker.reg_number_location-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'source_type': <SourceType.GPS: 'gps'>,
}),
])
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_device_tracker_empty[twingo_3_electric]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777999_location',
'unit_of_measurement': None,
# name: test_device_tracker_errors[zoe_50][device_tracker.reg_number_location-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
])
# ---
# name: test_device_tracker_empty[twingo_3_electric].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
])
# ---
# name: test_device_tracker_empty[zoe_40]
list([
])
# ---
# name: test_device_tracker_empty[zoe_40].1
list([
])
# ---
# name: test_device_tracker_empty[zoe_50]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777999_location',
'unit_of_measurement': None,
'name': None,
'options': dict({
}),
])
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777999_location',
'unit_of_measurement': None,
})
# ---
# name: test_device_tracker_empty[zoe_50].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
# name: test_device_tracker_errors[zoe_50][device_tracker.reg_number_location-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
}),
])
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
})
# ---
# name: test_device_trackers[captur_fuel]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777123_location',
'unit_of_measurement': None,
# name: test_device_trackers[captur_fuel][device_tracker.reg_number_location-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
])
# ---
# name: test_device_trackers[captur_fuel].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'gps_accuracy': 0,
'latitude': 48.1234567,
'longitude': 11.1234567,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
])
# ---
# name: test_device_trackers[captur_phev]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777123_location',
'unit_of_measurement': None,
'name': None,
'options': dict({
}),
])
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777123_location',
'unit_of_measurement': None,
})
# ---
# name: test_device_trackers[captur_phev].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'gps_accuracy': 0,
'latitude': 48.1234567,
'longitude': 11.1234567,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
# name: test_device_trackers[captur_fuel][device_tracker.reg_number_location-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'gps_accuracy': 0,
'latitude': 48.1234567,
'longitude': 11.1234567,
'source_type': <SourceType.GPS: 'gps'>,
}),
])
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
})
# ---
# name: test_device_trackers[twingo_3_electric]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777999_location',
'unit_of_measurement': None,
# name: test_device_trackers[captur_phev][device_tracker.reg_number_location-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
])
# ---
# name: test_device_trackers[twingo_3_electric].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'gps_accuracy': 0,
'latitude': 48.1234567,
'longitude': 11.1234567,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
])
# ---
# name: test_device_trackers[zoe_40]
list([
])
# ---
# name: test_device_trackers[zoe_40].1
list([
])
# ---
# name: test_device_trackers[zoe_50]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777999_location',
'unit_of_measurement': None,
'name': None,
'options': dict({
}),
])
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777123_location',
'unit_of_measurement': None,
})
# ---
# name: test_device_trackers[zoe_50].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'gps_accuracy': 0,
'latitude': 48.1234567,
'longitude': 11.1234567,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
# name: test_device_trackers[captur_phev][device_tracker.reg_number_location-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'gps_accuracy': 0,
'latitude': 48.1234567,
'longitude': 11.1234567,
'source_type': <SourceType.GPS: 'gps'>,
}),
])
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
})
# ---
# name: test_device_trackers[twingo_3_electric][device_tracker.reg_number_location-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777999_location',
'unit_of_measurement': None,
})
# ---
# name: test_device_trackers[twingo_3_electric][device_tracker.reg_number_location-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'gps_accuracy': 0,
'latitude': 48.1234567,
'longitude': 11.1234567,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
})
# ---
# name: test_device_trackers[zoe_50][device_tracker.reg_number_location-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.reg_number_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'vf1aaaaa555777999_location',
'unit_of_measurement': None,
})
# ---
# name: test_device_trackers[zoe_50][device_tracker.reg_number_location-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Location',
'gps_accuracy': 0,
'latitude': 48.1234567,
'longitude': 11.1234567,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.reg_number_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
})
# ---

View File

@ -1,529 +1,361 @@
# serializer version: 1
# name: test_select_empty[captur_fuel]
list([
])
# ---
# name: test_select_empty[captur_fuel].1
list([
])
# ---
# name: test_select_empty[captur_phev]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777123_charge_mode',
'unit_of_measurement': None,
# name: test_select_empty[zoe_40][select.reg_number_charge_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
])
# ---
# name: test_select_empty[captur_phev].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
])
# ---
# name: test_select_empty[twingo_3_electric]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
])
# ---
# name: test_select_empty[twingo_3_electric].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
'name': None,
'options': dict({
}),
])
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
})
# ---
# name: test_select_empty[zoe_40]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
# name: test_select_empty[zoe_40][select.reg_number_charge_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
])
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_select_empty[zoe_40].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
# name: test_select_errors[zoe_40][select.reg_number_charge_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
])
# ---
# name: test_select_empty[zoe_50]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
])
# ---
# name: test_select_empty[zoe_50].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
])
# ---
# name: test_selects[captur_fuel]
list([
])
# ---
# name: test_selects[captur_fuel].1
list([
])
# ---
# name: test_selects[captur_phev]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777123_charge_mode',
'unit_of_measurement': None,
'name': None,
'options': dict({
}),
])
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
})
# ---
# name: test_selects[captur_phev].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'always',
# name: test_select_errors[zoe_40][select.reg_number_charge_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
])
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unavailable',
})
# ---
# name: test_selects[twingo_3_electric]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
# name: test_selects[captur_phev][select.reg_number_charge_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
])
# ---
# name: test_selects[twingo_3_electric].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'always_charging',
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
])
# ---
# name: test_selects[zoe_40]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
])
# ---
# name: test_selects[zoe_40].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'always',
'name': None,
'options': dict({
}),
])
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777123_charge_mode',
'unit_of_measurement': None,
})
# ---
# name: test_selects[zoe_50]
list([
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
# name: test_selects[captur_phev][select.reg_number_charge_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
])
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'always',
})
# ---
# name: test_selects[zoe_50].1
list([
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'schedule_mode',
# name: test_selects[twingo_3_electric][select.reg_number_charge_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
])
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
})
# ---
# name: test_selects[twingo_3_electric][select.reg_number_charge_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'always_charging',
})
# ---
# name: test_selects[zoe_40][select.reg_number_charge_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
})
# ---
# name: test_selects[zoe_40][select.reg_number_charge_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'always',
})
# ---
# name: test_selects[zoe_50][select.reg_number_charge_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.reg_number_charge_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge mode',
'platform': 'renault',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_mode',
'unique_id': 'vf1aaaaa555777999_charge_mode',
'unit_of_measurement': None,
})
# ---
# name: test_selects[zoe_50][select.reg_number_charge_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'REG-NUMBER Charge mode',
'options': list([
'always',
'always_charging',
'schedule_mode',
'scheduled',
]),
}),
'context': <ANY>,
'entity_id': 'select.reg_number_charge_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'schedule_mode',
})
# ---

File diff suppressed because it is too large Load Diff

View File

@ -11,8 +11,7 @@ from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import check_entities_unavailable
from .const import MOCK_VEHICLES
from tests.common import snapshot_platform
pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicles")
@ -35,18 +34,11 @@ async def test_binary_sensors(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_no_data")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
async def test_binary_sensor_empty(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -57,34 +49,22 @@ async def test_binary_sensor_empty(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_invalid_upstream_exception")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
async def test_binary_sensor_errors(
hass: HomeAssistant,
config_entry: ConfigEntry,
vehicle_type: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test for Renault binary sensors with temporary failure."""
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
mock_vehicle = MOCK_VEHICLES[vehicle_type]
expected_entities = mock_vehicle[Platform.BINARY_SENSOR]
assert len(entity_registry.entities) == len(expected_entities)
check_entities_unavailable(hass, entity_registry, expected_entities)
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_access_denied_exception")

View File

@ -9,14 +9,11 @@ from syrupy.assertion import SnapshotAssertion
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_UNKNOWN, Platform
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import check_entities_no_data
from .const import ATTR_ENTITY_ID, MOCK_VEHICLES
from tests.common import load_fixture
from tests.common import load_fixture, snapshot_platform
pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicles")
@ -39,18 +36,11 @@ async def test_buttons(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_no_data")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
async def test_button_empty(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -61,34 +51,22 @@ async def test_button_empty(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_invalid_upstream_exception")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
async def test_button_errors(
hass: HomeAssistant,
config_entry: ConfigEntry,
vehicle_type: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test for Renault device trackers with temporary failure."""
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
mock_vehicle = MOCK_VEHICLES[vehicle_type]
expected_entities = mock_vehicle[Platform.BUTTON]
assert len(entity_registry.entities) == len(expected_entities)
check_entities_no_data(hass, entity_registry, expected_entities, STATE_UNKNOWN)
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_access_denied_exception")
@ -96,19 +74,14 @@ async def test_button_errors(
async def test_button_access_denied(
hass: HomeAssistant,
config_entry: ConfigEntry,
vehicle_type: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test for Renault device trackers with access denied failure."""
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
mock_vehicle = MOCK_VEHICLES[vehicle_type]
expected_entities = mock_vehicle[Platform.BUTTON]
assert len(entity_registry.entities) == len(expected_entities)
check_entities_no_data(hass, entity_registry, expected_entities, STATE_UNKNOWN)
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_not_supported_exception")
@ -116,19 +89,14 @@ async def test_button_access_denied(
async def test_button_not_supported(
hass: HomeAssistant,
config_entry: ConfigEntry,
vehicle_type: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test for Renault device trackers with not supported failure."""
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
mock_vehicle = MOCK_VEHICLES[vehicle_type]
expected_entities = mock_vehicle[Platform.BUTTON]
assert len(entity_registry.entities) == len(expected_entities)
check_entities_no_data(hass, entity_registry, expected_entities, STATE_UNKNOWN)
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_data")

View File

@ -11,11 +11,15 @@ from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import check_entities_unavailable
from .const import MOCK_VEHICLES
from tests.common import snapshot_platform
pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicles")
# Zoe 40 does not expose GPS information
_TEST_VEHICLES = [v for v in MOCK_VEHICLES if v != "zoe_40"]
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
@ -25,6 +29,7 @@ def override_platforms() -> Generator[None]:
@pytest.mark.usefixtures("fixtures_with_data")
@pytest.mark.parametrize("vehicle_type", _TEST_VEHICLES, indirect=True)
async def test_device_trackers(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -35,18 +40,11 @@ async def test_device_trackers(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_no_data")
@pytest.mark.parametrize("vehicle_type", ["zoe_50"], indirect=True)
async def test_device_tracker_empty(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -57,38 +55,26 @@ async def test_device_tracker_empty(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_invalid_upstream_exception")
@pytest.mark.parametrize("vehicle_type", ["zoe_50"], indirect=True)
async def test_device_tracker_errors(
hass: HomeAssistant,
config_entry: ConfigEntry,
vehicle_type: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test for Renault device trackers with temporary failure."""
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
mock_vehicle = MOCK_VEHICLES[vehicle_type]
expected_entities = mock_vehicle[Platform.DEVICE_TRACKER]
assert len(entity_registry.entities) == len(expected_entities)
check_entities_unavailable(hass, entity_registry, expected_entities)
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_access_denied_exception")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
@pytest.mark.parametrize("vehicle_type", ["zoe_50"], indirect=True)
async def test_device_tracker_access_denied(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -102,7 +88,7 @@ async def test_device_tracker_access_denied(
@pytest.mark.usefixtures("fixtures_with_not_supported_exception")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
@pytest.mark.parametrize("vehicle_type", ["zoe_50"], indirect=True)
async def test_device_tracker_not_supported(
hass: HomeAssistant,
config_entry: ConfigEntry,

View File

@ -17,14 +17,17 @@ from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import check_entities_unavailable
from .const import MOCK_VEHICLES
from tests.common import load_fixture
from tests.common import load_fixture, snapshot_platform
pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicles")
# Captur (fuel version) does not have a charge mode select
_TEST_VEHICLES = [v for v in MOCK_VEHICLES if v != "captur_fuel"]
@pytest.fixture(autouse=True)
def override_platforms() -> Generator[None]:
"""Override PLATFORMS."""
@ -33,6 +36,7 @@ def override_platforms() -> Generator[None]:
@pytest.mark.usefixtures("fixtures_with_data")
@pytest.mark.parametrize("vehicle_type", _TEST_VEHICLES, indirect=True)
async def test_selects(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -43,18 +47,11 @@ async def test_selects(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_no_data")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
async def test_select_empty(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -65,34 +62,22 @@ async def test_select_empty(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_invalid_upstream_exception")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
async def test_select_errors(
hass: HomeAssistant,
config_entry: ConfigEntry,
vehicle_type: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test for Renault selects with temporary failure."""
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
mock_vehicle = MOCK_VEHICLES[vehicle_type]
expected_entities = mock_vehicle[Platform.SELECT]
assert len(entity_registry.entities) == len(expected_entities)
check_entities_unavailable(hass, entity_registry, expected_entities)
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_access_denied_exception")

View File

@ -18,11 +18,9 @@ from homeassistant.const import ATTR_ASSUMED_STATE, STATE_UNAVAILABLE, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import check_entities_unavailable
from .conftest import _get_fixtures, patch_get_vehicle_data
from .const import MOCK_VEHICLES
from tests.common import async_fire_time_changed
from tests.common import async_fire_time_changed, snapshot_platform
pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicles")
@ -34,7 +32,7 @@ def override_platforms() -> Generator[None]:
yield
@pytest.mark.usefixtures("fixtures_with_data")
@pytest.mark.usefixtures("fixtures_with_data", "entity_registry_enabled_by_default")
async def test_sensors(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -45,24 +43,11 @@ async def test_sensors(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Some entities are disabled, enable them and reload before checking states
for ent in entity_entries:
entity_registry.async_update_entity(ent.entity_id, disabled_by=None)
await hass.config_entries.async_reload(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_no_data", "entity_registry_enabled_by_default")
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
async def test_sensor_empty(
hass: HomeAssistant,
config_entry: ConfigEntry,
@ -73,39 +58,24 @@ async def test_sensor_empty(
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
# Ensure entities are correctly registered
entity_entries = er.async_entries_for_config_entry(
entity_registry, config_entry.entry_id
)
assert entity_entries == snapshot
# Ensure entity states are correct
states = [hass.states.get(ent.entity_id) for ent in entity_entries]
assert states == snapshot
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures(
"fixtures_with_invalid_upstream_exception", "entity_registry_enabled_by_default"
)
@pytest.mark.parametrize("vehicle_type", ["zoe_40"], indirect=True)
async def test_sensor_errors(
hass: HomeAssistant,
config_entry: ConfigEntry,
vehicle_type: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test for Renault sensors with temporary failure."""
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
mock_vehicle = MOCK_VEHICLES[vehicle_type]
expected_entities = mock_vehicle[Platform.SENSOR]
assert len(entity_registry.entities) == len(expected_entities)
await hass.config_entries.async_reload(config_entry.entry_id)
await hass.async_block_till_done()
check_entities_unavailable(hass, entity_registry, expected_entities)
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
@pytest.mark.usefixtures("fixtures_with_access_denied_exception")