2021-11-30 13:54:15 +00:00
|
|
|
from tests.base_test import BaseTest
|
|
|
|
|
|
|
|
from crc import session
|
|
|
|
from crc.models.workflow import WorkflowModel
|
|
|
|
|
|
|
|
|
|
|
|
class TestGetWorkflowStatus(BaseTest):
|
|
|
|
|
|
|
|
def test_get_workflow_status_validation(self):
|
2022-02-10 02:06:55 +00:00
|
|
|
self.load_test_spec('empty_workflow', master_spec=True)
|
|
|
|
self.create_reference_document()
|
2021-11-30 13:54:15 +00:00
|
|
|
spec_model = self.load_test_spec('get_workflow_status')
|
|
|
|
rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers())
|
|
|
|
self.assertEqual([], rv.json)
|
|
|
|
|
|
|
|
def test_get_workflow_status(self):
|
2022-02-02 17:59:56 +00:00
|
|
|
self.create_workflow('random_fact')
|
2021-11-30 13:54:15 +00:00
|
|
|
workflow_model_1 = session.query(WorkflowModel).filter(WorkflowModel.id == 1).first()
|
2022-03-09 16:15:20 +00:00
|
|
|
workflow_spec_id = workflow_model_1.workflow_spec_id
|
2021-11-30 13:54:15 +00:00
|
|
|
workflow = self.create_workflow('get_workflow_status')
|
|
|
|
workflow_api = self.get_workflow_api(workflow)
|
|
|
|
task = workflow_api.next_task
|
|
|
|
|
|
|
|
# calls get_workflow_status(search_workflow_id)
|
2022-03-09 16:15:20 +00:00
|
|
|
workflow_api = self.complete_form(workflow, task, {'workflow_spec_id': workflow_spec_id})
|
2021-11-30 13:54:15 +00:00
|
|
|
task = workflow_api.next_task
|
|
|
|
self.assertEqual('Activity_StatusArg', task.name)
|
|
|
|
self.assertEqual(task.data['status_arg'], workflow_model_1.status.value)
|
|
|
|
|
|
|
|
# calls get_workflow_status(search_workflow_id=search_workflow_id)
|
|
|
|
workflow_api = self.complete_form(workflow, task, {})
|
|
|
|
task = workflow_api.next_task
|
|
|
|
self.assertEqual('Activity_StatusKwarg', task.name)
|
|
|
|
self.assertEqual(task.data['status_kwarg'], workflow_model_1.status.value)
|
|
|
|
|
|
|
|
|