Skip to content

Commit

Permalink
Fix history YAML deprecation (home-assistant#92238)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Apr 29, 2023
1 parent 06c4da2 commit acc4b00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
21 changes: 11 additions & 10 deletions homeassistant/components/history/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from homeassistant.components.http import HomeAssistantView
from homeassistant.components.recorder import get_instance, history
from homeassistant.components.recorder.util import session_scope
from homeassistant.const import CONF_EXCLUDE, CONF_INCLUDE
from homeassistant.core import HomeAssistant, valid_entity_id
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entityfilter import INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA
Expand All @@ -27,16 +28,16 @@
_ONE_DAY = timedelta(days=1)

CONFIG_SCHEMA = vol.Schema(
vol.All(
cv.deprecated(DOMAIN),
{
DOMAIN: vol.All(
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA.extend(
{vol.Optional(CONF_ORDER, default=False): cv.boolean}
),
)
},
),
{
DOMAIN: vol.All(
cv.deprecated(CONF_INCLUDE),
cv.deprecated(CONF_EXCLUDE),
cv.deprecated(CONF_ORDER),
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA.extend(
{vol.Optional(CONF_ORDER, default=False): cv.boolean}
),
)
},
extra=vol.ALLOW_EXTRA,
)

Expand Down
15 changes: 13 additions & 2 deletions tests/components/history/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ async def test_fetch_period_api(


async def test_fetch_period_api_with_use_include_order(
recorder_mock: Recorder, hass: HomeAssistant, hass_client: ClientSessionGenerator
recorder_mock: Recorder,
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test the fetch period view for history with include order."""
await async_setup_component(
Expand All @@ -418,6 +421,8 @@ async def test_fetch_period_api_with_use_include_order(
)
assert response.status == HTTPStatus.OK

assert "The 'use_include_order' option is deprecated" in caplog.text


async def test_fetch_period_api_with_minimal_response(
recorder_mock: Recorder, hass: HomeAssistant, hass_client: ClientSessionGenerator
Expand Down Expand Up @@ -472,7 +477,10 @@ async def test_fetch_period_api_with_no_timestamp(


async def test_fetch_period_api_with_include_order(
recorder_mock: Recorder, hass: HomeAssistant, hass_client: ClientSessionGenerator
recorder_mock: Recorder,
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test the fetch period view for history."""
await async_setup_component(
Expand All @@ -492,6 +500,9 @@ async def test_fetch_period_api_with_include_order(
)
assert response.status == HTTPStatus.OK

assert "The 'use_include_order' option is deprecated" in caplog.text
assert "The 'include' option is deprecated" in caplog.text


async def test_entity_ids_limit_via_api(
recorder_mock: Recorder, hass: HomeAssistant, hass_client: ClientSessionGenerator
Expand Down

0 comments on commit acc4b00

Please sign in to comment.