def test_event(session):
    e = Event()
    e.event = EventType.on
    e.event_description == 'test description'

    session.add(e)
    session.commit()

    t = session.query(Event).first()

    assert t is not None
    assert e == t
    assert t.event == EventType.on
def fake_events(session, request):
    test_event, e2, e3 = Event(), Event(), Event()

    test_event.event = EventType.on
    e2.event = EventType.off
    e3.event = EventType.on
    e2.event_description = 'test description'

    test_event.timestamp = arrow.utcnow().replace(minutes=-5)
    e2.timestamp = test_event.timestamp.replace(minutes=-5)
    e3.timestamp = test_event.timestamp.replace(minutes=-10)

    session.add_all([e3, e2, test_event])
    session.commit()

    yield test_event