From 6c595d8943b826a75809e56a97d4783ec23a764b Mon Sep 17 00:00:00 2001 From: John Davis Date: Fri, 21 Jul 2023 06:48:42 -0400 Subject: [PATCH] Fix SA2.0 syntax in test_workflow_refactoring .unique() is required due to joint eager loading specified in the StoredWorkflow model. --- test/integration/test_workflow_refactoring.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/integration/test_workflow_refactoring.py b/test/integration/test_workflow_refactoring.py index 476996174117..4048fcc9743a 100644 --- a/test/integration/test_workflow_refactoring.py +++ b/test/integration/test_workflow_refactoring.py @@ -6,6 +6,8 @@ List, ) +from sqlalchemy import select + from galaxy.managers.context import ProvidesAppContext from galaxy.managers.workflows import RefactorRequest from galaxy.model import ( @@ -767,7 +769,8 @@ def _export_for_update(self, workflow): yield workflow_object def _refactor(self, actions: List[Dict[str, Any]], stored_workflow=None, dry_run=False, style="ga"): - user = self._app.model.session.query(User).order_by(User.id.desc()).limit(1).one() + stmt = select(User).order_by(User.id.desc()).limit(1) + user = self._app.model.session.execute(stmt).scalar_one() mock_trans = MockTrans(self._app, user) app = self._app @@ -818,11 +821,13 @@ def _dry_run(self, actions: ActionsJson, stored_workflow=None): return response def _model_last_time(self, clazz): - obj = self._app.model.session.query(clazz).order_by(clazz.update_time.desc()).limit(1).one() + stmt = select(clazz).order_by(clazz.update_time.desc()).limit(1) + obj = self._app.model.session.execute(stmt).unique().scalar_one() return obj.update_time def _model_last_id(self, clazz): - obj = self._app.model.session.query(clazz).order_by(clazz.id.desc()).limit(1).one_or_none() + stmt = select(clazz).order_by(clazz.id.desc()).limit(1) + obj = self._app.model.session.execute(stmt).scalar_one_or_none() return obj.id if obj else None @property @@ -835,7 +840,8 @@ def _most_recent_stored_workflow(self): def _recent_stored_workflow(self, n=1): app = self._app - return app.model.session.query(StoredWorkflow).order_by(StoredWorkflow.id.desc()).limit(n).all()[-1] + stmt = select(StoredWorkflow).order_by(StoredWorkflow.id.desc()).limit(n) + return app.model.session.scalars(stmt).unique().all()[-1] @property def _latest_workflow(self):