def test_handle_session_exception(self): session = mock.MagicMock() handler = ScopedSessionHandler(session) e = Exception() handler.handle_session(session, exc=e) self.assertTrue(session.rollback.called)
def test_handle_session(self): engine = create_engine('sqlite:///:memory:') handler = ScopedSessionHandler(engine) session = mock.MagicMock() handler.handle_session(session) self.assertTrue(session.close.called)