def remove_session(exc): if exc and not is_fake_error(exc): app.logger.exception("Rolling back database") Session.rollback() else: Session.commit() Session.remove()
def test_events_persist(self): e = event.Event.for_name("Drink glass of water") o = e.track(attrs=dict(size="16", location="office")) when = o.when attrs = dict(o.attrs) # Reload from db Session.commit() Session.remove() e = event.Event.for_name("Drink glass of water") o1 = e.entries()[0] self.assertDatetimesEqual(when, o1.when) self.assertEqual(attrs, o1.attrs)
def tearDown(self): Session.remove()