Improve statistics metadata WS API (#77209)

This commit is contained in:
Erik Montnemery 2022-08-31 11:30:45 +02:00 committed by GitHub
parent 7c585bd380
commit 008ac8d10d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 360 additions and 207 deletions

View file

@ -1118,18 +1118,24 @@ async def test_statistics_during_period_bad_end_time(
@pytest.mark.parametrize(
"units, attributes, unit",
"units, attributes, display_unit, statistics_unit",
[
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"),
(METRIC_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"),
(IMPERIAL_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°F"),
(METRIC_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°C"),
(IMPERIAL_SYSTEM, PRESSURE_SENSOR_ATTRIBUTES, "psi"),
(METRIC_SYSTEM, PRESSURE_SENSOR_ATTRIBUTES, "Pa"),
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "W"),
(METRIC_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "W"),
(IMPERIAL_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°F", "°C"),
(METRIC_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°C", "°C"),
(IMPERIAL_SYSTEM, PRESSURE_SENSOR_ATTRIBUTES, "psi", "Pa"),
(METRIC_SYSTEM, PRESSURE_SENSOR_ATTRIBUTES, "Pa", "Pa"),
],
)
async def test_list_statistic_ids(
hass, hass_ws_client, recorder_mock, units, attributes, unit
hass,
hass_ws_client,
recorder_mock,
units,
attributes,
display_unit,
statistics_unit,
):
"""Test list_statistic_ids."""
now = dt_util.utcnow()
@ -1158,7 +1164,8 @@ async def test_list_statistic_ids(
"has_sum": False,
"name": None,
"source": "recorder",
"unit_of_measurement": unit,
"display_unit_of_measurement": display_unit,
"statistics_unit_of_measurement": statistics_unit,
}
]
@ -1178,7 +1185,8 @@ async def test_list_statistic_ids(
"has_sum": False,
"name": None,
"source": "recorder",
"unit_of_measurement": unit,
"display_unit_of_measurement": display_unit,
"statistics_unit_of_measurement": statistics_unit,
}
]
@ -1200,7 +1208,8 @@ async def test_list_statistic_ids(
"has_sum": False,
"name": None,
"source": "recorder",
"unit_of_measurement": unit,
"display_unit_of_measurement": display_unit,
"statistics_unit_of_measurement": statistics_unit,
}
]