def _add_test_events(hass):
    'Add a few events for testing.'
    now = datetime.now()
    five_days_ago = (now - timedelta(days=5))
    eleven_days_ago = (now - timedelta(days=11))
    event_data = {'test_attr': 5, 'test_attr_10': 'nice'}
    hass.block_till_done()
    hass.data[DATA_INSTANCE].block_till_done()
    wait_recording_done(hass)
    with recorder.session_scope(hass=hass) as session:
        for event_id in range(6):
            if (event_id < 2):
                timestamp = eleven_days_ago
                event_type = 'EVENT_TEST_AUTOPURGE'
            elif (event_id < 4):
                timestamp = five_days_ago
                event_type = 'EVENT_TEST_PURGE'
            else:
                timestamp = now
                event_type = 'EVENT_TEST'
            session.add(Events(event_type=event_type, event_data=json.dumps(event_data), origin='LOCAL', created=timestamp, time_fired=timestamp))
Add a few events for testing.
def _add_test_events(hass):
    
    now = datetime.now()
    five_days_ago = (now - timedelta(days=5))
    eleven_days_ago = (now - timedelta(days=11))
    event_data = {'test_attr': 5, 'test_attr_10': 'nice'}
    hass.block_till_done()
    hass.data[DATA_INSTANCE].block_till_done()
    wait_recording_done(hass)
    with recorder.session_scope(hass=hass) as session:
        for event_id in range(6):
            if (event_id < 2):
                timestamp = eleven_days_ago
                event_type = 'EVENT_TEST_AUTOPURGE'
            elif (event_id < 4):
                timestamp = five_days_ago
                event_type = 'EVENT_TEST_PURGE'
            else:
                timestamp = now
                event_type = 'EVENT_TEST'
            session.add(Events(event_type=event_type, event_data=json.dumps(event_data), origin='LOCAL', created=timestamp, time_fired=timestamp))