mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Improve error reporting in recorder purge test (#47929)
This commit is contained in:
parent
9dabc988fb
commit
61a2460c87
@ -207,11 +207,14 @@ class RecorderRuns(Base): # type: ignore
|
|||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Return string representation of instance for debugging."""
|
"""Return string representation of instance for debugging."""
|
||||||
|
end = (
|
||||||
|
f"'{self.end.isoformat(sep=' ', timespec='seconds')}'" if self.end else None
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
f"<recorder.RecorderRuns("
|
f"<recorder.RecorderRuns("
|
||||||
f"id={self.run_id}, start='{self.start.isoformat(sep='', timespec='seconds')}', "
|
f"id={self.run_id}, start='{self.start.isoformat(sep=' ', timespec='seconds')}', "
|
||||||
f"end='{self.end.isoformat(sep='', timespec='seconds')}', closed_incorrect={self.closed_incorrect}, "
|
f"end={end}, closed_incorrect={self.closed_incorrect}, "
|
||||||
f"created='{self.created.isoformat(sep='', timespec='seconds')}'"
|
f"created='{self.created.isoformat(sep=' ', timespec='seconds')}'"
|
||||||
f")>"
|
f")>"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -105,6 +105,8 @@ async def test_purge_method(
|
|||||||
await _add_test_events(hass, instance)
|
await _add_test_events(hass, instance)
|
||||||
await _add_test_states(hass, instance)
|
await _add_test_states(hass, instance)
|
||||||
await _add_test_recorder_runs(hass, instance)
|
await _add_test_recorder_runs(hass, instance)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
await async_wait_recording_done(hass, instance)
|
||||||
|
|
||||||
# make sure we start with 6 states
|
# make sure we start with 6 states
|
||||||
with session_scope(hass=hass) as session:
|
with session_scope(hass=hass) as session:
|
||||||
@ -116,9 +118,7 @@ async def test_purge_method(
|
|||||||
|
|
||||||
recorder_runs = session.query(RecorderRuns)
|
recorder_runs = session.query(RecorderRuns)
|
||||||
assert recorder_runs.count() == 7
|
assert recorder_runs.count() == 7
|
||||||
|
runs_before_purge = recorder_runs.all()
|
||||||
await hass.async_block_till_done()
|
|
||||||
await async_wait_recording_done(hass, instance)
|
|
||||||
|
|
||||||
# run purge method - no service data, use defaults
|
# run purge method - no service data, use defaults
|
||||||
await hass.services.async_call("recorder", "purge")
|
await hass.services.async_call("recorder", "purge")
|
||||||
@ -145,7 +145,10 @@ async def test_purge_method(
|
|||||||
assert events.count() == 2
|
assert events.count() == 2
|
||||||
|
|
||||||
# now we should only have 3 recorder runs left
|
# now we should only have 3 recorder runs left
|
||||||
assert recorder_runs.count() == 3
|
runs = recorder_runs.all()
|
||||||
|
assert runs[0] == runs_before_purge[0]
|
||||||
|
assert runs[1] == runs_before_purge[5]
|
||||||
|
assert runs[2] == runs_before_purge[6]
|
||||||
|
|
||||||
assert not ("EVENT_TEST_PURGE" in (event.event_type for event in events.all()))
|
assert not ("EVENT_TEST_PURGE" in (event.event_type for event in events.all()))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user