def test_close_connection(self, mock_commit): mock_session = MagicMock() mock_engine = MagicMock() testManager = SessionManager() testManager.session = mock_session testManager.engine = mock_engine testManager.closeConnection() mock_commit.assert_called_once() mock_session.close.assert_called_once() mock_engine.dispose.assert_called_once()
def test_commit_session(self): mock_session = MagicMock() testManager = SessionManager() testManager.session = mock_session testManager.commitChanges() mock_session.commit.assert_called_once()
def test_rollback_session(self): mock_session = MagicMock() testManager = SessionManager() testManager.session = mock_session testManager.rollbackChanges() mock_session.rollback.assert_called_once()
def test_start_session(self): mock_session = MagicMock() testManager = SessionManager() testManager.session = mock_session testManager.startSession() mock_session.begin_nested.assert_called_once()