Adds workflow_spec_id back in to WorkflowApi
This commit is contained in:
parent
eae6c8dd1a
commit
f142d02a30
10
crc/api.yml
10
crc/api.yml
|
@ -636,14 +636,16 @@ components:
|
|||
status:
|
||||
type: enum
|
||||
enum: ['new','user_input_required','waiting','complete']
|
||||
last_task_id:
|
||||
type: integer
|
||||
next_task_id:
|
||||
type: integer
|
||||
last_task:
|
||||
$ref: "#/components/schemas/Task"
|
||||
next_task:
|
||||
$ref: "#/components/schemas/Task"
|
||||
user_tasks:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Task"
|
||||
workflow_spec_id:
|
||||
type: string
|
||||
|
||||
example:
|
||||
id: 291234
|
||||
|
|
|
@ -70,10 +70,14 @@ def delete_workflow_specification(spec_id):
|
|||
def __get_workflow_api_model(workflow_model: WorkflowModel, processor: WorkflowProcessor):
|
||||
spiff_tasks = processor.get_all_user_tasks()
|
||||
user_tasks = map(Task.from_spiff, spiff_tasks)
|
||||
return WorkflowApi(id=workflow_model.id, status=workflow_model.status,
|
||||
last_task=Task.from_spiff(processor.bpmn_workflow.last_task),
|
||||
next_task=Task.from_spiff(processor.next_task()),
|
||||
user_tasks=user_tasks)
|
||||
return WorkflowApi(
|
||||
id=workflow_model.id,
|
||||
status=workflow_model.status,
|
||||
last_task=Task.from_spiff(processor.bpmn_workflow.last_task),
|
||||
next_task=Task.from_spiff(processor.next_task()),
|
||||
user_tasks=user_tasks,
|
||||
workflow_spec_id=workflow_model.workflow_spec_id
|
||||
)
|
||||
|
||||
|
||||
def get_workflow(workflow_id):
|
||||
|
|
|
@ -108,17 +108,18 @@ class TaskSchema(ma.Schema):
|
|||
|
||||
|
||||
class WorkflowApi(object):
|
||||
def __init__(self, id, status, user_tasks, last_task, next_task):
|
||||
def __init__(self, id, status, user_tasks, last_task, next_task, workflow_spec_id):
|
||||
self.id = id
|
||||
self.status = status
|
||||
self.user_tasks = user_tasks
|
||||
self.last_task = last_task
|
||||
self.next_task = next_task
|
||||
self.workflow_spec_id = workflow_spec_id
|
||||
|
||||
class WorkflowApiSchema(ma.Schema):
|
||||
class Meta:
|
||||
model = WorkflowApi
|
||||
fields = ["id", "status", "user_tasks", "last_task", "next_task"]
|
||||
fields = ["id", "status", "user_tasks", "last_task", "next_task", "workflow_spec_id"]
|
||||
unknown = INCLUDE
|
||||
status = EnumField(WorkflowStatus)
|
||||
user_tasks = marshmallow.fields.List(marshmallow.fields.Nested(TaskSchema, dump_only=True))
|
||||
|
@ -127,4 +128,4 @@ class WorkflowApiSchema(ma.Schema):
|
|||
|
||||
@marshmallow.post_load
|
||||
def make_workflow(self, data, **kwargs):
|
||||
return WorkflowApi(**data)
|
||||
return WorkflowApi(**data)
|
||||
|
|
|
@ -23,6 +23,7 @@ class TestTasksApi(BaseTest):
|
|||
rv = self.app.get('/v1.0/workflow/%i' % workflow.id, content_type="application/json")
|
||||
json_data = json.loads(rv.get_data(as_text=True))
|
||||
workflow_api = WorkflowApiSchema().load(json_data)
|
||||
self.assertEqual(workflow.workflow_spec_id, workflow_api.workflow_spec_id)
|
||||
return workflow_api
|
||||
|
||||
def complete_form(self, workflow, task, dict_data):
|
||||
|
@ -47,6 +48,7 @@ class TestTasksApi(BaseTest):
|
|||
workflow = self.create_workflow('two_forms')
|
||||
# get the first form in the two form workflow.
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
self.assertEqual('two_forms', workflow_api.workflow_spec_id)
|
||||
self.assertEqual(2, len(workflow_api.user_tasks))
|
||||
self.assertIsNotNone(workflow_api.user_tasks[0].form)
|
||||
self.assertEqual("UserTask", workflow_api.next_task['type'])
|
||||
|
|
Loading…
Reference in New Issue