Fix recorder platform tests (#88330)
parent
dfdd279add
commit
9989a4787b
|
@ -52,7 +52,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -13,8 +13,8 @@ from tests.common import async_fire_time_changed
|
|||
from tests.components.recorder.common import async_wait_recording_done
|
||||
|
||||
|
||||
async def test_events_http_api(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test the calendar demo view."""
|
||||
async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant) -> None:
|
||||
"""Test sensor attributes to be excluded."""
|
||||
await async_setup_component(hass, "calendar", {"calendar": {"platform": "demo"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -31,7 +31,11 @@ async def test_events_http_api(recorder_mock: Recorder, hass: HomeAssistant) ->
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -34,7 +34,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_camera_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -40,7 +40,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -28,7 +28,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -46,7 +46,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
attr_ids[
|
||||
db_state_attributes.attributes_id
|
||||
] = db_state_attributes.to_native()
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = attr_ids[db_state.attributes_id]
|
||||
native_states.append(state)
|
||||
|
|
|
@ -34,7 +34,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -34,7 +34,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -34,7 +34,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -38,7 +38,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -46,7 +46,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -45,7 +45,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -45,7 +45,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -35,7 +35,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -36,7 +36,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -30,7 +30,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -57,7 +57,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -68,7 +68,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -30,7 +30,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -4735,7 +4735,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -30,7 +30,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -38,7 +38,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_sun_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -28,7 +28,11 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -44,7 +44,11 @@ async def test_exclude_attributes(
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -29,7 +29,11 @@ async def test_exclude_attributes(recorder_mock, hass):
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -33,7 +33,11 @@ async def test_exclude_attributes(recorder_mock, hass):
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
|
@ -32,7 +32,11 @@ async def test_exclude_attributes(recorder_mock, hass: HomeAssistant) -> None:
|
|||
def _fetch_states() -> list[State]:
|
||||
with session_scope(hass=hass) as session:
|
||||
native_states = []
|
||||
for db_state, db_state_attributes in session.query(States, StateAttributes):
|
||||
for db_state, db_state_attributes in session.query(
|
||||
States, StateAttributes
|
||||
).outerjoin(
|
||||
StateAttributes, States.attributes_id == StateAttributes.attributes_id
|
||||
):
|
||||
state = db_state.to_native()
|
||||
state.attributes = db_state_attributes.to_native()
|
||||
native_states.append(state)
|
||||
|
|
Loading…
Reference in New Issue