Exclude filter for event types (#7627)

* add exclude filter for event types to recorder component

* corrected long line (279)

* change source code structure
add test for exclude event types

* code cleanup

* change source code structure

* Update __init__.py

* Update test_init.py
This commit is contained in:
amigian74 authored and Paulus Schoutsen committed 2017-05-24 15:23:52 -07:00
1 parent e7d783ca2a
commit 775d45ae5a
2 files changed
+27

No files matched your search

+20
View File
@@ -114,6 +114,18 @@ def _add_entities(hass, entity_ids):
return [st.to_native() for st in session.query(States)]
def _add_events(hass, events):
with session_scope(hass=hass) as session:
session.query(Events).delete(synchronize_session=False)
for event_type in events:
hass.bus.fire(event_type)
hass.block_till_done()
hass.data[DATA_INSTANCE].block_till_done()
with session_scope(hass=hass) as session:
return [ev.to_native() for ev in session.query(Events)]
# pylint: disable=redefined-outer-name,invalid-name
def test_saving_state_include_domains(hass_recorder):
"""Test saving and restoring a state."""
@@ -131,6 +143,14 @@ def test_saving_state_incl_entities(hass_recorder):
assert hass.states.get('test2.recorder') == states[0]
def test_saving_event_exclude_event_type(hass_recorder):
"""Test saving and restoring an event."""
hass = hass_recorder({'exclude': {'event_types': 'test'}})
events = _add_events(hass, ['test', 'test2'])
assert len(events) == 1
assert events[0].event_type == 'test2'
def test_saving_state_exclude_domains(hass_recorder):
"""Test saving and restoring a state."""
hass = hass_recorder({'exclude': {'domains': 'test'}})