From bfb3871671bcd5f815380cfbe5b3ab58b21c7543 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Tue, 19 Jan 2021 15:27:44 -0500 Subject: [PATCH] Added method for restart_workflow_api. Pulled out some common code with get_workflow_api. --- tests/base_test.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/base_test.py b/tests/base_test.py index 28a62ffd..67510eb6 100644 --- a/tests/base_test.py +++ b/tests/base_test.py @@ -341,19 +341,30 @@ class BaseTest(unittest.TestCase): session.commit() return approval - def get_workflow_api(self, workflow, reload_spec=False, clear_data=False, do_engine_steps=True, user_uid="dhf8r"): - user = session.query(UserModel).filter_by(uid=user_uid).first() - self.assertIsNotNone(user) - url = (f'/v1.0/workflow/{workflow.id}' - f'?clear_data={str(clear_data)}' - f'&reload_spec={str(reload_spec)}' - f'&do_engine_steps={str(do_engine_steps)}') + def get_workflow_common(self, url, user): rv = self.app.get(url, headers=self.logged_in_headers(user), content_type="application/json") self.assert_success(rv) json_data = json.loads(rv.get_data(as_text=True)) workflow_api = WorkflowApiSchema().load(json_data) + return workflow_api + + def get_workflow_api(self, workflow, do_engine_steps=True, user_uid="dhf8r"): + user = session.query(UserModel).filter_by(uid=user_uid).first() + self.assertIsNotNone(user) + url = (f'/v1.0/workflow/{workflow.id}' + f'?do_engine_steps={str(do_engine_steps)}') + workflow_api = self.get_workflow_common(url, user) + self.assertEqual(workflow.workflow_spec_id, workflow_api.workflow_spec_id) + return workflow_api + + def restart_workflow_api(self, workflow, clear_data=False, user_uid="dhf8r"): + user = session.query(UserModel).filter_by(uid=user_uid).first() + self.assertIsNotNone(user) + url = (f'/v1.0/workflow/{workflow.id}/restart' + f'?clear_data={str(clear_data)}') + workflow_api = self.get_workflow_common(url, user) self.assertEqual(workflow.workflow_spec_id, workflow_api.workflow_spec_id) return workflow_api