mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Use new Platform enum in Renault (#60903)
* Use Platform enum in Renault * Use Platform enum in Renault tests Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
231d434b76
commit
75ec937359
@ -1,9 +1,5 @@
|
||||
"""Constants for the Renault component."""
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
|
||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.const import Platform
|
||||
|
||||
DOMAIN = "renault"
|
||||
|
||||
@ -13,11 +9,11 @@ CONF_KAMEREON_ACCOUNT_ID = "kamereon_account_id"
|
||||
DEFAULT_SCAN_INTERVAL = 300 # 5 minutes
|
||||
|
||||
PLATFORMS = [
|
||||
BINARY_SENSOR_DOMAIN,
|
||||
BUTTON_DOMAIN,
|
||||
DEVICE_TRACKER_DOMAIN,
|
||||
SELECT_DOMAIN,
|
||||
SENSOR_DOMAIN,
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.BUTTON,
|
||||
Platform.DEVICE_TRACKER,
|
||||
Platform.SELECT,
|
||||
Platform.SENSOR,
|
||||
]
|
||||
|
||||
DEVICE_CLASS_PLUG_STATE = "renault__plug_state"
|
||||
|
@ -1,10 +1,5 @@
|
||||
"""Constants for the Renault integration tests."""
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DOMAIN as BINARY_SENSOR_DOMAIN,
|
||||
BinarySensorDeviceClass,
|
||||
)
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
|
||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||
from homeassistant.components.renault.const import (
|
||||
CONF_KAMEREON_ACCOUNT_ID,
|
||||
CONF_LOCALE,
|
||||
@ -13,11 +8,9 @@ from homeassistant.components.renault.const import (
|
||||
DEVICE_CLASS_PLUG_STATE,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN
|
||||
from homeassistant.components.select.const import ATTR_OPTIONS
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_STATE_CLASS,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorDeviceClass,
|
||||
SensorStateClass,
|
||||
)
|
||||
@ -46,6 +39,7 @@ from homeassistant.const import (
|
||||
TEMP_CELSIUS,
|
||||
TIME_MINUTES,
|
||||
VOLUME_LITERS,
|
||||
Platform,
|
||||
)
|
||||
|
||||
ATTR_DEFAULT_DISABLED = "default_disabled"
|
||||
@ -97,7 +91,7 @@ MOCK_VEHICLES = {
|
||||
"cockpit": "cockpit_ev.json",
|
||||
"hvac_status": "hvac_status.json",
|
||||
},
|
||||
BINARY_SENSOR_DOMAIN: [
|
||||
Platform.BINARY_SENSOR: [
|
||||
{
|
||||
ATTR_DEVICE_CLASS: BinarySensorDeviceClass.PLUG,
|
||||
ATTR_ENTITY_ID: "binary_sensor.reg_number_plugged_in",
|
||||
@ -111,7 +105,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging",
|
||||
},
|
||||
],
|
||||
BUTTON_DOMAIN: [
|
||||
Platform.BUTTON: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "button.reg_number_start_air_conditioner",
|
||||
ATTR_ICON: "mdi:air-conditioner",
|
||||
@ -125,8 +119,8 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_start_charge",
|
||||
},
|
||||
],
|
||||
DEVICE_TRACKER_DOMAIN: [],
|
||||
SELECT_DOMAIN: [
|
||||
Platform.DEVICE_TRACKER: [],
|
||||
Platform.SELECT: [
|
||||
{
|
||||
ATTR_DEVICE_CLASS: DEVICE_CLASS_CHARGE_MODE,
|
||||
ATTR_ENTITY_ID: "select.reg_number_charge_mode",
|
||||
@ -136,7 +130,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charge_mode",
|
||||
},
|
||||
],
|
||||
SENSOR_DOMAIN: [
|
||||
Platform.SENSOR: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_battery_autonomy",
|
||||
ATTR_ICON: "mdi:ev-station",
|
||||
@ -245,7 +239,7 @@ MOCK_VEHICLES = {
|
||||
"cockpit": "cockpit_ev.json",
|
||||
"location": "location.json",
|
||||
},
|
||||
BINARY_SENSOR_DOMAIN: [
|
||||
Platform.BINARY_SENSOR: [
|
||||
{
|
||||
ATTR_DEVICE_CLASS: BinarySensorDeviceClass.PLUG,
|
||||
ATTR_ENTITY_ID: "binary_sensor.reg_number_plugged_in",
|
||||
@ -259,7 +253,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charging",
|
||||
},
|
||||
],
|
||||
BUTTON_DOMAIN: [
|
||||
Platform.BUTTON: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "button.reg_number_start_air_conditioner",
|
||||
ATTR_ICON: "mdi:air-conditioner",
|
||||
@ -273,7 +267,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_start_charge",
|
||||
},
|
||||
],
|
||||
DEVICE_TRACKER_DOMAIN: [
|
||||
Platform.DEVICE_TRACKER: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "device_tracker.reg_number_location",
|
||||
ATTR_ICON: "mdi:car",
|
||||
@ -281,7 +275,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_location",
|
||||
}
|
||||
],
|
||||
SELECT_DOMAIN: [
|
||||
Platform.SELECT: [
|
||||
{
|
||||
ATTR_DEVICE_CLASS: DEVICE_CLASS_CHARGE_MODE,
|
||||
ATTR_ENTITY_ID: "select.reg_number_charge_mode",
|
||||
@ -291,7 +285,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777999_charge_mode",
|
||||
},
|
||||
],
|
||||
SENSOR_DOMAIN: [
|
||||
Platform.SENSOR: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_battery_autonomy",
|
||||
ATTR_ICON: "mdi:ev-station",
|
||||
@ -399,7 +393,7 @@ MOCK_VEHICLES = {
|
||||
"cockpit": "cockpit_fuel.json",
|
||||
"location": "location.json",
|
||||
},
|
||||
BINARY_SENSOR_DOMAIN: [
|
||||
Platform.BINARY_SENSOR: [
|
||||
{
|
||||
ATTR_DEVICE_CLASS: BinarySensorDeviceClass.PLUG,
|
||||
ATTR_ENTITY_ID: "binary_sensor.reg_number_plugged_in",
|
||||
@ -413,7 +407,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_charging",
|
||||
},
|
||||
],
|
||||
BUTTON_DOMAIN: [
|
||||
Platform.BUTTON: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "button.reg_number_start_air_conditioner",
|
||||
ATTR_ICON: "mdi:air-conditioner",
|
||||
@ -427,7 +421,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_start_charge",
|
||||
},
|
||||
],
|
||||
DEVICE_TRACKER_DOMAIN: [
|
||||
Platform.DEVICE_TRACKER: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "device_tracker.reg_number_location",
|
||||
ATTR_ICON: "mdi:car",
|
||||
@ -435,7 +429,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_location",
|
||||
}
|
||||
],
|
||||
SELECT_DOMAIN: [
|
||||
Platform.SELECT: [
|
||||
{
|
||||
ATTR_DEVICE_CLASS: DEVICE_CLASS_CHARGE_MODE,
|
||||
ATTR_ENTITY_ID: "select.reg_number_charge_mode",
|
||||
@ -445,7 +439,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_charge_mode",
|
||||
},
|
||||
],
|
||||
SENSOR_DOMAIN: [
|
||||
Platform.SENSOR: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_battery_autonomy",
|
||||
ATTR_ICON: "mdi:ev-station",
|
||||
@ -567,8 +561,8 @@ MOCK_VEHICLES = {
|
||||
"cockpit": "cockpit_fuel.json",
|
||||
"location": "location.json",
|
||||
},
|
||||
BINARY_SENSOR_DOMAIN: [],
|
||||
BUTTON_DOMAIN: [
|
||||
Platform.BINARY_SENSOR: [],
|
||||
Platform.BUTTON: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "button.reg_number_start_air_conditioner",
|
||||
ATTR_ICON: "mdi:air-conditioner",
|
||||
@ -576,7 +570,7 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_start_air_conditioner",
|
||||
},
|
||||
],
|
||||
DEVICE_TRACKER_DOMAIN: [
|
||||
Platform.DEVICE_TRACKER: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "device_tracker.reg_number_location",
|
||||
ATTR_ICON: "mdi:car",
|
||||
@ -584,8 +578,8 @@ MOCK_VEHICLES = {
|
||||
ATTR_UNIQUE_ID: "vf1aaaaa555777123_location",
|
||||
}
|
||||
],
|
||||
SELECT_DOMAIN: [],
|
||||
SENSOR_DOMAIN: [
|
||||
Platform.SELECT: [],
|
||||
Platform.SENSOR: [
|
||||
{
|
||||
ATTR_ENTITY_ID: "sensor.reg_number_fuel_autonomy",
|
||||
ATTR_ICON: "mdi:gas-station",
|
||||
|
@ -3,9 +3,8 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_OFF
|
||||
from homeassistant.const import STATE_OFF, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
@ -24,7 +23,7 @@ pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicle
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms():
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [BINARY_SENSOR_DOMAIN]):
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [Platform.BINARY_SENSOR]):
|
||||
yield
|
||||
|
||||
|
||||
@ -42,7 +41,7 @@ async def test_binary_sensors(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[BINARY_SENSOR_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.BINARY_SENSOR]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
check_entities(hass, entity_registry, expected_entities)
|
||||
@ -62,7 +61,7 @@ async def test_binary_sensor_empty(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[BINARY_SENSOR_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.BINARY_SENSOR]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
check_entities_no_data(hass, entity_registry, expected_entities, STATE_OFF)
|
||||
|
||||
@ -81,7 +80,7 @@ async def test_binary_sensor_errors(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[BINARY_SENSOR_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.BINARY_SENSOR]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
check_entities_unavailable(hass, entity_registry, expected_entities)
|
||||
|
@ -4,10 +4,9 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
from renault_api.kamereon import schemas
|
||||
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN
|
||||
from homeassistant.components.button.const import SERVICE_PRESS
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.const import STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import check_device_registry, check_entities_no_data
|
||||
@ -21,7 +20,7 @@ pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicle
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms():
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [BUTTON_DOMAIN]):
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [Platform.BUTTON]):
|
||||
yield
|
||||
|
||||
|
||||
@ -40,7 +39,7 @@ async def test_buttons(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[BUTTON_DOMAIN]
|
||||
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)
|
||||
@ -61,7 +60,7 @@ async def test_button_empty(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[BUTTON_DOMAIN]
|
||||
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)
|
||||
|
||||
@ -81,7 +80,7 @@ async def test_button_errors(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[BUTTON_DOMAIN]
|
||||
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)
|
||||
@ -103,7 +102,7 @@ async def test_button_access_denied(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[BUTTON_DOMAIN]
|
||||
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)
|
||||
@ -125,7 +124,7 @@ async def test_button_not_supported(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[BUTTON_DOMAIN]
|
||||
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)
|
||||
@ -151,7 +150,7 @@ async def test_button_start_charge(hass: HomeAssistant, config_entry: ConfigEntr
|
||||
),
|
||||
) as mock_action:
|
||||
await hass.services.async_call(
|
||||
BUTTON_DOMAIN, SERVICE_PRESS, service_data=data, blocking=True
|
||||
Platform.BUTTON, SERVICE_PRESS, service_data=data, blocking=True
|
||||
)
|
||||
assert len(mock_action.mock_calls) == 1
|
||||
assert mock_action.mock_calls[0][1] == ()
|
||||
@ -179,7 +178,7 @@ async def test_button_start_air_conditioner(
|
||||
),
|
||||
) as mock_action:
|
||||
await hass.services.async_call(
|
||||
BUTTON_DOMAIN, SERVICE_PRESS, service_data=data, blocking=True
|
||||
Platform.BUTTON, SERVICE_PRESS, service_data=data, blocking=True
|
||||
)
|
||||
assert len(mock_action.mock_calls) == 1
|
||||
assert mock_action.mock_calls[0][1] == (21, None)
|
||||
|
@ -3,9 +3,8 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.const import STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
@ -24,7 +23,7 @@ pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicle
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms():
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [DEVICE_TRACKER_DOMAIN]):
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [Platform.DEVICE_TRACKER]):
|
||||
yield
|
||||
|
||||
|
||||
@ -43,7 +42,7 @@ async def test_device_trackers(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[DEVICE_TRACKER_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.DEVICE_TRACKER]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
check_entities(hass, entity_registry, expected_entities)
|
||||
@ -64,7 +63,7 @@ async def test_device_tracker_empty(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[DEVICE_TRACKER_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.DEVICE_TRACKER]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
check_entities_no_data(hass, entity_registry, expected_entities, STATE_UNKNOWN)
|
||||
|
||||
@ -84,7 +83,7 @@ async def test_device_tracker_errors(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[DEVICE_TRACKER_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.DEVICE_TRACKER]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
check_entities_unavailable(hass, entity_registry, expected_entities)
|
||||
|
@ -4,10 +4,9 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
from renault_api.kamereon import schemas
|
||||
|
||||
from homeassistant.components.select import DOMAIN as SELECT_DOMAIN
|
||||
from homeassistant.components.select.const import ATTR_OPTION, SERVICE_SELECT_OPTION
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import (
|
||||
@ -26,7 +25,7 @@ pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicle
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms():
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [SELECT_DOMAIN]):
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [Platform.SELECT]):
|
||||
yield
|
||||
|
||||
|
||||
@ -44,7 +43,7 @@ async def test_selects(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[SELECT_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.SELECT]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
check_entities(hass, entity_registry, expected_entities)
|
||||
@ -64,7 +63,7 @@ async def test_select_empty(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[SELECT_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.SELECT]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
check_entities_no_data(hass, entity_registry, expected_entities, STATE_UNKNOWN)
|
||||
|
||||
@ -83,7 +82,7 @@ async def test_select_errors(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[SELECT_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.SELECT]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
check_entities_unavailable(hass, entity_registry, expected_entities)
|
||||
@ -146,7 +145,7 @@ async def test_select_charge_mode(hass: HomeAssistant, config_entry: ConfigEntry
|
||||
),
|
||||
) as mock_action:
|
||||
await hass.services.async_call(
|
||||
SELECT_DOMAIN, SERVICE_SELECT_OPTION, service_data=data, blocking=True
|
||||
Platform.SELECT, SERVICE_SELECT_OPTION, service_data=data, blocking=True
|
||||
)
|
||||
assert len(mock_action.mock_calls) == 1
|
||||
assert mock_action.mock_calls[0][1] == ("always",)
|
||||
|
@ -4,9 +4,8 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_registry import EntityRegistry
|
||||
|
||||
@ -26,7 +25,7 @@ pytestmark = pytest.mark.usefixtures("patch_renault_account", "patch_get_vehicle
|
||||
@pytest.fixture(autouse=True)
|
||||
def override_platforms():
|
||||
"""Override PLATFORMS."""
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [SENSOR_DOMAIN]):
|
||||
with patch("homeassistant.components.renault.PLATFORMS", [Platform.SENSOR]):
|
||||
yield
|
||||
|
||||
|
||||
@ -57,7 +56,7 @@ async def test_sensors(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[SENSOR_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.SENSOR]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
_check_and_enable_disabled_entities(entity_registry, expected_entities)
|
||||
@ -81,7 +80,7 @@ async def test_sensor_empty(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[SENSOR_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.SENSOR]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
_check_and_enable_disabled_entities(entity_registry, expected_entities)
|
||||
@ -105,7 +104,7 @@ async def test_sensor_errors(
|
||||
mock_vehicle = MOCK_VEHICLES[vehicle_type]
|
||||
check_device_registry(device_registry, mock_vehicle["expected_device"])
|
||||
|
||||
expected_entities = mock_vehicle[SENSOR_DOMAIN]
|
||||
expected_entities = mock_vehicle[Platform.SENSOR]
|
||||
assert len(entity_registry.entities) == len(expected_entities)
|
||||
|
||||
_check_and_enable_disabled_entities(entity_registry, expected_entities)
|
||||
|
Loading…
x
Reference in New Issue
Block a user