'Test deleting old events.'

def test_purge_old_events(self):

    self._add_test_events()
    with session_scope(hass=self.hass) as session:
        events = session.query(Events).filter(Events.event_type.like('EVENT_TEST%'))
        self.assertEqual(events.count(), 5)
        purge_old_data(self.hass.data[DATA_INSTANCE], 4)
        self.assertEqual(events.count(), 3)
