Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break out statistics repairs into a auto_repairs modules #90068

Merged
merged 8 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix patch targets
  • Loading branch information
bdraco committed Mar 21, 2023
commit 7aa6361f1d22c5095007eb5826882a991f5d80cb
4 changes: 2 additions & 2 deletions tests/components/recorder/repairs/statistics/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def test_validate_db_schema_fix_float_issue(
"homeassistant.components.recorder.repairs.statistics.schema._get_future_year",
return_value=fixed_future_year,
), patch(
"homeassistant.components.recorder.statistics._statistics_during_period_with_session",
"homeassistant.components.recorder.repairs.statistics.schema._statistics_during_period_with_session",
side_effect=fake_statistics,
wraps=_statistics_during_period_with_session,
), patch(
Expand Down Expand Up @@ -216,7 +216,7 @@ async def test_validate_db_schema_fix_statistics_datetime_issue(
with patch(
"homeassistant.components.recorder.core.Recorder.dialect_name", db_engine
), patch(
"homeassistant.components.recorder.statistics._statistics_during_period_with_session",
"homeassistant.components.recorder.repairs.statistics.schema._statistics_during_period_with_session",
side_effect=fake_statistics,
wraps=_statistics_during_period_with_session,
), patch(
Expand Down
30 changes: 16 additions & 14 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,18 +1282,19 @@ def hass_recorder(
# pylint: disable-next=import-outside-toplevel
from homeassistant.components import recorder

# pylint: disable-next=import-outside-toplevel
from homeassistant.components.recorder.repairs.statistics import schema

original_tz = dt_util.DEFAULT_TIME_ZONE

hass = get_test_home_assistant()
nightly = recorder.Recorder.async_nightly_tasks if enable_nightly_purge else None
stats = recorder.Recorder.async_periodic_statistics if enable_statistics else None
stats_validate = itertools.repeat(set())
if enable_statistics_table_validation:
from homeassistant.components.recorder.repairs.statistics.schema import (
validate_db_schema,
)

stats_validate = validate_db_schema
stats_validate = (
schema.validate_db_schema
if enable_statistics_table_validation
else itertools.repeat(set())
)
migrate_states_context_ids = (
recorder.Recorder._migrate_states_context_ids
if enable_migrate_context_ids
Expand Down Expand Up @@ -1399,18 +1400,19 @@ async def async_setup_recorder_instance(
# pylint: disable-next=import-outside-toplevel
from homeassistant.components import recorder

# pylint: disable-next=import-outside-toplevel
from homeassistant.components.recorder.repairs.statistics import schema

# pylint: disable-next=import-outside-toplevel
from .components.recorder.common import async_recorder_block_till_done

nightly = recorder.Recorder.async_nightly_tasks if enable_nightly_purge else None
stats = recorder.Recorder.async_periodic_statistics if enable_statistics else None
stats_validate = itertools.repeat(set())
if enable_statistics_table_validation:
from homeassistant.components.recorder.repairs.statistics.schema import (
validate_db_schema,
)

stats_validate = validate_db_schema
stats_validate = (
schema.validate_db_schema
if enable_statistics_table_validation
else itertools.repeat(set())
)
migrate_states_context_ids = (
recorder.Recorder._migrate_states_context_ids
if enable_migrate_context_ids
Expand Down