def test_upsert_session_exists(self): with Transaction() as t: r = VioscreenSessionRepo(t) obs = r.upsert_session(VIOSCREEN_SESSION) self.assertEqual(obs, True) # upsert of unmodified should have no change obs = r.upsert_session(VIOSCREEN_SESSION) # ...however the ON CONFLICT won't realize nothing # is different and still report something changed self.assertEqual(obs, True) session_modified = copy(VIOSCREEN_SESSION) session_modified.endDate = _to_dt(2, 1, 1970) obs = r.upsert_session(session_modified) self.assertEqual(obs, True) obs = r.get_session(VIOSCREEN_SESSION.sessionId) self.assertEqual(obs, session_modified)
def test_get_session_does_not_exist(self): with Transaction() as t: r = VioscreenSessionRepo(t) obs = r.get_session('does not exist') self.assertEqual(obs, None)
def test_get_session_exists(self): with Transaction() as t: r = VioscreenSessionRepo(t) r.upsert_session(VIOSCREEN_SESSION) obs = r.get_session(VIOSCREEN_SESSION.sessionId) self.assertEqual(obs, VIOSCREEN_SESSION)