Make recorder execute avoid native conversion by default (#36938)
This commit is contained in:
parent
f4b8a95205
commit
edad387b12
9 changed files with 42 additions and 35 deletions
|
@ -3,8 +3,6 @@ from datetime import datetime, timedelta
|
|||
import statistics
|
||||
import unittest
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import recorder
|
||||
from homeassistant.components.statistics.sensor import StatisticsSensor
|
||||
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, STATE_UNKNOWN, TEMP_CELSIUS
|
||||
|
@ -17,6 +15,7 @@ from tests.common import (
|
|||
get_test_home_assistant,
|
||||
init_recorder_component,
|
||||
)
|
||||
from tests.components.recorder.common import wait_recording_done
|
||||
|
||||
|
||||
class TestStatisticsSensor(unittest.TestCase):
|
||||
|
@ -321,11 +320,12 @@ class TestStatisticsSensor(unittest.TestCase):
|
|||
) == state.attributes.get("max_age")
|
||||
assert self.change_rate == state.attributes.get("change_rate")
|
||||
|
||||
@pytest.mark.skip("Flaky in CI")
|
||||
def test_initialize_from_database(self):
|
||||
"""Test initializing the statistics from the database."""
|
||||
# enable the recorder
|
||||
init_recorder_component(self.hass)
|
||||
self.hass.block_till_done()
|
||||
self.hass.data[recorder.DATA_INSTANCE].block_till_done()
|
||||
# store some values
|
||||
for value in self.values:
|
||||
self.hass.states.set(
|
||||
|
@ -333,7 +333,7 @@ class TestStatisticsSensor(unittest.TestCase):
|
|||
)
|
||||
self.hass.block_till_done()
|
||||
# wait for the recorder to really store the data
|
||||
self.hass.data[recorder.DATA_INSTANCE].block_till_done()
|
||||
wait_recording_done(self.hass)
|
||||
# only now create the statistics component, so that it must read the
|
||||
# data from the database
|
||||
assert setup_component(
|
||||
|
@ -357,7 +357,6 @@ class TestStatisticsSensor(unittest.TestCase):
|
|||
state = self.hass.states.get("sensor.test")
|
||||
assert str(self.mean) == state.state
|
||||
|
||||
@pytest.mark.skip("Flaky in CI")
|
||||
def test_initialize_from_database_with_maxage(self):
|
||||
"""Test initializing the statistics from the database."""
|
||||
mock_data = {
|
||||
|
@ -381,6 +380,8 @@ class TestStatisticsSensor(unittest.TestCase):
|
|||
|
||||
# enable the recorder
|
||||
init_recorder_component(self.hass)
|
||||
self.hass.block_till_done()
|
||||
self.hass.data[recorder.DATA_INSTANCE].block_till_done()
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.statistics.sensor.dt_util.utcnow", new=mock_now
|
||||
|
@ -397,7 +398,7 @@ class TestStatisticsSensor(unittest.TestCase):
|
|||
mock_data["return_time"] += timedelta(hours=1)
|
||||
|
||||
# wait for the recorder to really store the data
|
||||
self.hass.data[recorder.DATA_INSTANCE].block_till_done()
|
||||
wait_recording_done(self.hass)
|
||||
# only now create the statistics component, so that it must read
|
||||
# the data from the database
|
||||
assert setup_component(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue