Rename variable in sensor tests (#122954)

This commit is contained in:
epenet 2024-07-31 20:42:05 +02:00 committed by GitHub
parent a23b3f84f0
commit 177690bcb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2466,30 +2466,29 @@ async def test_list_statistic_ids(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"_attributes", "energy_attributes",
[{**ENERGY_SENSOR_ATTRIBUTES, "last_reset": 0}, TEMPERATURE_SENSOR_ATTRIBUTES], [{**ENERGY_SENSOR_ATTRIBUTES, "last_reset": 0}, TEMPERATURE_SENSOR_ATTRIBUTES],
) )
async def test_list_statistic_ids_unsupported( async def test_list_statistic_ids_unsupported(
hass: HomeAssistant, hass: HomeAssistant,
caplog: pytest.LogCaptureFixture, energy_attributes: dict[str, Any],
_attributes,
) -> None: ) -> None:
"""Test listing future statistic ids for unsupported sensor.""" """Test listing future statistic ids for unsupported sensor."""
await async_setup_component(hass, "sensor", {}) await async_setup_component(hass, "sensor", {})
# Wait for the sensor recorder platform to be added # Wait for the sensor recorder platform to be added
await async_recorder_block_till_done(hass) await async_recorder_block_till_done(hass)
attributes = dict(_attributes) attributes = dict(energy_attributes)
hass.states.async_set("sensor.test1", 0, attributes=attributes) hass.states.async_set("sensor.test1", 0, attributes=attributes)
if "last_reset" in attributes: if "last_reset" in attributes:
attributes.pop("unit_of_measurement") attributes.pop("unit_of_measurement")
hass.states.async_set("last_reset.test2", 0, attributes=attributes) hass.states.async_set("last_reset.test2", 0, attributes=attributes)
attributes = dict(_attributes) attributes = dict(energy_attributes)
if "unit_of_measurement" in attributes: if "unit_of_measurement" in attributes:
attributes["unit_of_measurement"] = "invalid" attributes["unit_of_measurement"] = "invalid"
hass.states.async_set("sensor.test3", 0, attributes=attributes) hass.states.async_set("sensor.test3", 0, attributes=attributes)
attributes.pop("unit_of_measurement") attributes.pop("unit_of_measurement")
hass.states.async_set("sensor.test4", 0, attributes=attributes) hass.states.async_set("sensor.test4", 0, attributes=attributes)
attributes = dict(_attributes) attributes = dict(energy_attributes)
attributes["state_class"] = "invalid" attributes["state_class"] = "invalid"
hass.states.async_set("sensor.test5", 0, attributes=attributes) hass.states.async_set("sensor.test5", 0, attributes=attributes)
attributes.pop("state_class") attributes.pop("state_class")