Skip to content

Commit

Permalink
Ensure sensor and recorder converters align (#87138)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet committed Feb 2, 2023
1 parent cc469ab commit 58596d2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/components/recorder/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from homeassistant.components.recorder.db_schema import StatisticsShortTerm
from homeassistant.components.recorder.models import process_timestamp
from homeassistant.components.recorder.statistics import (
STATISTIC_UNIT_TO_UNIT_CONVERTER,
_statistics_during_period_with_session,
_update_or_add_metadata,
async_add_external_statistics,
Expand All @@ -29,6 +30,7 @@
list_statistic_ids,
)
from homeassistant.components.recorder.util import session_scope
from homeassistant.components.sensor import UNIT_CONVERTERS
from homeassistant.const import UnitOfTemperature
from homeassistant.core import callback
from homeassistant.exceptions import HomeAssistantError
Expand All @@ -49,6 +51,15 @@
ORIG_TZ = dt_util.DEFAULT_TIME_ZONE


def test_converters_align_with_sensor():
"""Ensure STATISTIC_UNIT_TO_UNIT_CONVERTER is aligned with UNIT_CONVERTERS."""
for converter in UNIT_CONVERTERS.values():
assert converter in STATISTIC_UNIT_TO_UNIT_CONVERTER.values()

for converter in STATISTIC_UNIT_TO_UNIT_CONVERTER.values():
assert converter in UNIT_CONVERTERS.values()


def test_compile_hourly_statistics(hass_recorder):
"""Test compiling hourly statistics."""
hass = hass_recorder()
Expand Down

0 comments on commit 58596d2

Please sign in to comment.