mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Fix consider-using-dict-items warnings in tests (#119497)
This commit is contained in:
parent
cb39d2d16b
commit
99b349fa2c
@ -3986,7 +3986,7 @@ async def test_sensorstate(
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
for sensor_type in sensor_types:
|
for sensor_type, item in sensor_types.items():
|
||||||
assert helpers.get_google_type(sensor.DOMAIN, None) is not None
|
assert helpers.get_google_type(sensor.DOMAIN, None) is not None
|
||||||
assert trait.SensorStateTrait.supported(sensor.DOMAIN, None, sensor_type, None)
|
assert trait.SensorStateTrait.supported(sensor.DOMAIN, None, sensor_type, None)
|
||||||
|
|
||||||
@ -4002,8 +4002,8 @@ async def test_sensorstate(
|
|||||||
BASIC_CONFIG,
|
BASIC_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
name = sensor_types[sensor_type][0]
|
name = item[0]
|
||||||
unit = sensor_types[sensor_type][1]
|
unit = item[1]
|
||||||
|
|
||||||
if sensor_type == sensor.SensorDeviceClass.AQI:
|
if sensor_type == sensor.SensorDeviceClass.AQI:
|
||||||
assert trt.sync_attributes() == {
|
assert trt.sync_attributes() == {
|
||||||
|
@ -94,8 +94,8 @@ def setup_api(hass, data, requests_mock):
|
|||||||
"units": desc.native_unit_of_measurement,
|
"units": desc.native_unit_of_measurement,
|
||||||
"icon": desc.icon,
|
"icon": desc.icon,
|
||||||
}
|
}
|
||||||
for name in sensor_dict:
|
for value in sensor_dict.values():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
sensor.hass = hass
|
sensor.hass = hass
|
||||||
|
|
||||||
return api, sensor_dict
|
return api, sensor_dict
|
||||||
@ -111,9 +111,9 @@ def fake_delay(hass, ha_delay):
|
|||||||
def test_name(requests_mock: requests_mock.Mocker) -> None:
|
def test_name(requests_mock: requests_mock.Mocker) -> None:
|
||||||
"""Test the name."""
|
"""Test the name."""
|
||||||
api, sensor_dict = setup_api(None, MOCK_DATA, requests_mock)
|
api, sensor_dict = setup_api(None, MOCK_DATA, requests_mock)
|
||||||
for name in sensor_dict:
|
for value in sensor_dict.values():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
test_name = sensor_dict[name]["name"]
|
test_name = value["name"]
|
||||||
assert test_name == sensor.name
|
assert test_name == sensor.name
|
||||||
|
|
||||||
|
|
||||||
@ -122,17 +122,17 @@ def test_unit_of_measurement(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test the unit of measurement."""
|
"""Test the unit of measurement."""
|
||||||
api, sensor_dict = setup_api(hass, MOCK_DATA, requests_mock)
|
api, sensor_dict = setup_api(hass, MOCK_DATA, requests_mock)
|
||||||
for name in sensor_dict:
|
for value in sensor_dict.values():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
assert sensor_dict[name]["units"] == sensor.unit_of_measurement
|
assert value["units"] == sensor.unit_of_measurement
|
||||||
|
|
||||||
|
|
||||||
def test_icon(requests_mock: requests_mock.Mocker) -> None:
|
def test_icon(requests_mock: requests_mock.Mocker) -> None:
|
||||||
"""Test the icon."""
|
"""Test the icon."""
|
||||||
api, sensor_dict = setup_api(None, MOCK_DATA, requests_mock)
|
api, sensor_dict = setup_api(None, MOCK_DATA, requests_mock)
|
||||||
for name in sensor_dict:
|
for value in sensor_dict.values():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
assert sensor_dict[name]["icon"] == sensor.icon
|
assert value["icon"] == sensor.icon
|
||||||
|
|
||||||
|
|
||||||
def test_state(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> None:
|
def test_state(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> None:
|
||||||
@ -140,8 +140,8 @@ def test_state(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> None
|
|||||||
api, sensor_dict = setup_api(hass, MOCK_DATA, requests_mock)
|
api, sensor_dict = setup_api(hass, MOCK_DATA, requests_mock)
|
||||||
now = datetime(1970, month=1, day=1)
|
now = datetime(1970, month=1, day=1)
|
||||||
with patch("homeassistant.util.dt.now", return_value=now):
|
with patch("homeassistant.util.dt.now", return_value=now):
|
||||||
for name in sensor_dict:
|
for name, value in sensor_dict.items():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
fake_delay(hass, 2)
|
fake_delay(hass, 2)
|
||||||
sensor.update()
|
sensor.update()
|
||||||
if name == google_wifi.ATTR_LAST_RESTART:
|
if name == google_wifi.ATTR_LAST_RESTART:
|
||||||
@ -159,8 +159,8 @@ def test_update_when_value_is_none(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test state gets updated to unknown when sensor returns no data."""
|
"""Test state gets updated to unknown when sensor returns no data."""
|
||||||
api, sensor_dict = setup_api(hass, None, requests_mock)
|
api, sensor_dict = setup_api(hass, None, requests_mock)
|
||||||
for name in sensor_dict:
|
for value in sensor_dict.values():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
fake_delay(hass, 2)
|
fake_delay(hass, 2)
|
||||||
sensor.update()
|
sensor.update()
|
||||||
assert sensor.state is None
|
assert sensor.state is None
|
||||||
@ -173,8 +173,8 @@ def test_update_when_value_changed(
|
|||||||
api, sensor_dict = setup_api(hass, MOCK_DATA_NEXT, requests_mock)
|
api, sensor_dict = setup_api(hass, MOCK_DATA_NEXT, requests_mock)
|
||||||
now = datetime(1970, month=1, day=1)
|
now = datetime(1970, month=1, day=1)
|
||||||
with patch("homeassistant.util.dt.now", return_value=now):
|
with patch("homeassistant.util.dt.now", return_value=now):
|
||||||
for name in sensor_dict:
|
for name, value in sensor_dict.items():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
fake_delay(hass, 2)
|
fake_delay(hass, 2)
|
||||||
sensor.update()
|
sensor.update()
|
||||||
if name == google_wifi.ATTR_LAST_RESTART:
|
if name == google_wifi.ATTR_LAST_RESTART:
|
||||||
@ -198,8 +198,8 @@ def test_when_api_data_missing(
|
|||||||
api, sensor_dict = setup_api(hass, MOCK_DATA_MISSING, requests_mock)
|
api, sensor_dict = setup_api(hass, MOCK_DATA_MISSING, requests_mock)
|
||||||
now = datetime(1970, month=1, day=1)
|
now = datetime(1970, month=1, day=1)
|
||||||
with patch("homeassistant.util.dt.now", return_value=now):
|
with patch("homeassistant.util.dt.now", return_value=now):
|
||||||
for name in sensor_dict:
|
for value in sensor_dict.values():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
fake_delay(hass, 2)
|
fake_delay(hass, 2)
|
||||||
sensor.update()
|
sensor.update()
|
||||||
assert sensor.state is None
|
assert sensor.state is None
|
||||||
@ -214,8 +214,8 @@ def test_update_when_unavailable(
|
|||||||
"google_wifi.GoogleWifiAPI.update",
|
"google_wifi.GoogleWifiAPI.update",
|
||||||
side_effect=update_side_effect(hass, requests_mock),
|
side_effect=update_side_effect(hass, requests_mock),
|
||||||
)
|
)
|
||||||
for name in sensor_dict:
|
for value in sensor_dict.values():
|
||||||
sensor = sensor_dict[name]["sensor"]
|
sensor = value["sensor"]
|
||||||
sensor.update()
|
sensor.update()
|
||||||
assert sensor.state is None
|
assert sensor.state is None
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ async def test_site_cannot_connect(
|
|||||||
|
|
||||||
assert hass.states.get("weather.met_office_wavertree_3hourly") is None
|
assert hass.states.get("weather.met_office_wavertree_3hourly") is None
|
||||||
assert hass.states.get("weather.met_office_wavertree_daily") is None
|
assert hass.states.get("weather.met_office_wavertree_daily") is None
|
||||||
for sensor_id in WAVERTREE_SENSOR_RESULTS:
|
for sensor in WAVERTREE_SENSOR_RESULTS.values():
|
||||||
sensor_name, _ = WAVERTREE_SENSOR_RESULTS[sensor_id]
|
sensor_name = sensor[0]
|
||||||
sensor = hass.states.get(f"sensor.wavertree_{sensor_name}")
|
sensor = hass.states.get(f"sensor.wavertree_{sensor_name}")
|
||||||
assert sensor is None
|
assert sensor is None
|
||||||
|
|
||||||
|
@ -266,13 +266,11 @@ async def test_if_fires_on_event_legacy(
|
|||||||
("platform", "camera_type", "event_type", "sub_type"),
|
("platform", "camera_type", "event_type", "sub_type"),
|
||||||
[
|
[
|
||||||
("climate", "Smart Valve", trigger, subtype)
|
("climate", "Smart Valve", trigger, subtype)
|
||||||
for trigger in SUBTYPES
|
for trigger, subtype in SUBTYPES.items()
|
||||||
for subtype in SUBTYPES[trigger]
|
|
||||||
]
|
]
|
||||||
+ [
|
+ [
|
||||||
("climate", "Smart Thermostat", trigger, subtype)
|
("climate", "Smart Thermostat", trigger, subtype)
|
||||||
for trigger in SUBTYPES
|
for trigger, subtype in SUBTYPES.items()
|
||||||
for subtype in SUBTYPES[trigger]
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_if_fires_on_event_with_subtype(
|
async def test_if_fires_on_event_with_subtype(
|
||||||
|
@ -20,7 +20,7 @@ async def test_create_binary_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("binary_sensor.downstairs_east_wing_blower_active")
|
state = hass.states.get("binary_sensor.downstairs_east_wing_blower_active")
|
||||||
@ -32,5 +32,5 @@ async def test_create_binary_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
@ -39,7 +39,7 @@ async def test_climate_zones(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("climate.kitchen")
|
state = hass.states.get("climate.kitchen")
|
||||||
@ -72,5 +72,5 @@ async def test_climate_zones(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ async def test_create_fan_speed_number_entities(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("number.downstairs_east_wing_fan_speed")
|
state = hass.states.get("number.downstairs_east_wing_fan_speed")
|
||||||
@ -40,7 +40,7 @@ async def test_create_fan_speed_number_entities(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ async def test_automation_scenes(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("scene.power_outage")
|
state = hass.states.get("scene.power_outage")
|
||||||
@ -55,7 +55,7 @@ async def test_automation_scenes(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("scene.power_restored")
|
state = hass.states.get("scene.power_restored")
|
||||||
@ -73,5 +73,5 @@ async def test_automation_scenes(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
@ -23,7 +23,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.nick_office_zone_setpoint_status")
|
state = hass.states.get("sensor.nick_office_zone_setpoint_status")
|
||||||
@ -35,7 +35,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.nick_office_zone_status")
|
state = hass.states.get("sensor.nick_office_zone_status")
|
||||||
@ -48,7 +48,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.master_suite_air_cleaner_mode")
|
state = hass.states.get("sensor.master_suite_air_cleaner_mode")
|
||||||
@ -61,7 +61,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.master_suite_current_compressor_speed")
|
state = hass.states.get("sensor.master_suite_current_compressor_speed")
|
||||||
@ -75,7 +75,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.master_suite_outdoor_temperature")
|
state = hass.states.get("sensor.master_suite_outdoor_temperature")
|
||||||
@ -90,7 +90,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.master_suite_humidity")
|
state = hass.states.get("sensor.master_suite_humidity")
|
||||||
@ -105,7 +105,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.master_suite_requested_compressor_speed")
|
state = hass.states.get("sensor.master_suite_requested_compressor_speed")
|
||||||
@ -119,7 +119,7 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
|
||||||
state = hass.states.get("sensor.master_suite_system_status")
|
state = hass.states.get("sensor.master_suite_system_status")
|
||||||
@ -132,5 +132,5 @@ async def test_create_sensors(hass: HomeAssistant) -> None:
|
|||||||
# Only test for a subset of attributes in case
|
# Only test for a subset of attributes in case
|
||||||
# HA changes the implementation and a new one appears
|
# HA changes the implementation and a new one appears
|
||||||
assert all(
|
assert all(
|
||||||
state.attributes[key] == expected_attributes[key] for key in expected_attributes
|
state.attributes[key] == value for key, value in expected_attributes.items()
|
||||||
)
|
)
|
||||||
|
@ -846,13 +846,10 @@ def test_device_classes_aligned() -> None:
|
|||||||
assert hasattr(NumberDeviceClass, device_class.name)
|
assert hasattr(NumberDeviceClass, device_class.name)
|
||||||
assert getattr(NumberDeviceClass, device_class.name).value == device_class.value
|
assert getattr(NumberDeviceClass, device_class.name).value == device_class.value
|
||||||
|
|
||||||
for device_class in SENSOR_DEVICE_CLASS_UNITS:
|
for device_class, unit in SENSOR_DEVICE_CLASS_UNITS.items():
|
||||||
if device_class in NON_NUMERIC_DEVICE_CLASSES:
|
if device_class in NON_NUMERIC_DEVICE_CLASSES:
|
||||||
continue
|
continue
|
||||||
assert (
|
assert unit == NUMBER_DEVICE_CLASS_UNITS[device_class]
|
||||||
SENSOR_DEVICE_CLASS_UNITS[device_class]
|
|
||||||
== NUMBER_DEVICE_CLASS_UNITS[device_class]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class MockFlow(ConfigFlow):
|
class MockFlow(ConfigFlow):
|
||||||
|
@ -782,8 +782,8 @@ async def test_import_expose_settings_1(
|
|||||||
expose_settings = exposed_entities.async_get_entity_settings(
|
expose_settings = exposed_entities.async_get_entity_settings(
|
||||||
hass, entity_entry.entity_id
|
hass, entity_entry.entity_id
|
||||||
)
|
)
|
||||||
for assistant in EXPOSE_SETTINGS:
|
for assistant, settings in EXPOSE_SETTINGS.items():
|
||||||
assert expose_settings[assistant]["should_expose"] == EXPOSE_SETTINGS[assistant]
|
assert expose_settings[assistant]["should_expose"] == settings
|
||||||
|
|
||||||
# Check the switch is no longer exposed
|
# Check the switch is no longer exposed
|
||||||
expose_settings = exposed_entities.async_get_entity_settings(
|
expose_settings = exposed_entities.async_get_entity_settings(
|
||||||
@ -856,18 +856,15 @@ async def test_import_expose_settings_2(
|
|||||||
expose_settings = exposed_entities.async_get_entity_settings(
|
expose_settings = exposed_entities.async_get_entity_settings(
|
||||||
hass, entity_entry.entity_id
|
hass, entity_entry.entity_id
|
||||||
)
|
)
|
||||||
for assistant in EXPOSE_SETTINGS:
|
for assistant, settings in EXPOSE_SETTINGS.items():
|
||||||
assert (
|
assert expose_settings[assistant]["should_expose"] is not settings
|
||||||
expose_settings[assistant]["should_expose"]
|
|
||||||
is not EXPOSE_SETTINGS[assistant]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Check the switch settings were not modified
|
# Check the switch settings were not modified
|
||||||
expose_settings = exposed_entities.async_get_entity_settings(
|
expose_settings = exposed_entities.async_get_entity_settings(
|
||||||
hass, switch_entity_entry.entity_id
|
hass, switch_entity_entry.entity_id
|
||||||
)
|
)
|
||||||
for assistant in EXPOSE_SETTINGS:
|
for assistant, settings in EXPOSE_SETTINGS.items():
|
||||||
assert expose_settings[assistant]["should_expose"] == EXPOSE_SETTINGS[assistant]
|
assert expose_settings[assistant]["should_expose"] == settings
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("target_domain", PLATFORMS_TO_TEST)
|
@pytest.mark.parametrize("target_domain", PLATFORMS_TO_TEST)
|
||||||
@ -922,8 +919,8 @@ async def test_restore_expose_settings(
|
|||||||
expose_settings = exposed_entities.async_get_entity_settings(
|
expose_settings = exposed_entities.async_get_entity_settings(
|
||||||
hass, switch_entity_entry.entity_id
|
hass, switch_entity_entry.entity_id
|
||||||
)
|
)
|
||||||
for assistant in EXPOSE_SETTINGS:
|
for assistant, settings in EXPOSE_SETTINGS.items():
|
||||||
assert expose_settings[assistant]["should_expose"] == EXPOSE_SETTINGS[assistant]
|
assert expose_settings[assistant]["should_expose"] == settings
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("target_domain", PLATFORMS_TO_TEST)
|
@pytest.mark.parametrize("target_domain", PLATFORMS_TO_TEST)
|
||||||
|
@ -1273,9 +1273,9 @@ async def test_trigger_entity_restore_state(
|
|||||||
|
|
||||||
state = hass.states.get("binary_sensor.test")
|
state = hass.states.get("binary_sensor.test")
|
||||||
assert state.state == initial_state
|
assert state.state == initial_state
|
||||||
for attr in restored_attributes:
|
for attr, value in restored_attributes.items():
|
||||||
if attr in initial_attributes:
|
if attr in initial_attributes:
|
||||||
assert state.attributes[attr] == restored_attributes[attr]
|
assert state.attributes[attr] == value
|
||||||
else:
|
else:
|
||||||
assert attr not in state.attributes
|
assert attr not in state.attributes
|
||||||
assert "another" not in state.attributes
|
assert "another" not in state.attributes
|
||||||
|
@ -1828,9 +1828,9 @@ async def test_trigger_entity_restore_state(
|
|||||||
|
|
||||||
state = hass.states.get("sensor.test")
|
state = hass.states.get("sensor.test")
|
||||||
assert state.state == initial_state
|
assert state.state == initial_state
|
||||||
for attr in restored_attributes:
|
for attr, value in restored_attributes.items():
|
||||||
if attr in initial_attributes:
|
if attr in initial_attributes:
|
||||||
assert state.attributes[attr] == restored_attributes[attr]
|
assert state.attributes[attr] == value
|
||||||
else:
|
else:
|
||||||
assert attr not in state.attributes
|
assert attr not in state.attributes
|
||||||
assert "another" not in state.attributes
|
assert "another" not in state.attributes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user