This commit is contained in:
Dan Funk 2020-01-07 13:23:46 -05:00
parent 872f3fca1b
commit a3d7ba8114
3 changed files with 32 additions and 31 deletions

View File

@ -408,26 +408,26 @@ paths:
schema:
$ref: "#/components/schemas/Error"
# /v1.0/workflow/0/task/0
/workflow/{workflow_id}/task/{task_id}:
/workflow/{workflow_id}/task/{task_name}:
parameters:
- name: workflow_id
in: path
required: true
description: The id of the workflow
schema:
type: integer
format: int32
- name: task_name
in: path
required: true
description: The id of the task
schema:
type: string
get:
operationId: crc.api.workflow.get_task
summary: Get details of specific task in specific workflow instance
tags:
- Workflows and Tasks
parameters:
- name: workflow_id
in: path
required: true
description: The id of the workflow
schema:
type: integer
format: int32
- name: task_id
in: path
required: true
description: The id of the task
schema:
type: string
responses:
'200':
description: Expected response to a valid request
@ -452,19 +452,6 @@ paths:
name: task
schema:
$ref: '#/components/schemas/Task'
- name: workflow_id
in: path
required: true
description: The id of the workflow
schema:
type: integer
format: int32
- name: task_id
in: path
required: true
description: The id of the task
schema:
type: string
responses:
'201':
description: Null response

View File

@ -35,9 +35,10 @@ def get_task(workflow_id, task_id):
return workflow.bpmn_workflow().get_task(task_id)
def update_task(workflow_id, task_id, body):
def update_task(workflow_id, task_name, body):
workflow = db.session.query(WorkflowModel).filter_by(id=workflow_id).first()
task = workflow.bpmn_workflow().get_task(task_id)
processor = WorkflowProcessor(workflow.workflow_spec_id, workflow.bpmn_workflow_json)
task = processor.bpmn_workflow.get_tasks_from_spec_name(task_name)[0]
if workflow and task and body:
print('workflow', workflow.id)
print('task', task.id)

View File

@ -133,6 +133,7 @@ class TestStudy(BaseTest, unittest.TestCase):
self.assertEqual(3, len(tasks[0].form["fields"][0]["options"]))
def test_two_forms_task(self):
# Set up a new workfllow
self.load_example_data()
study = db.session.query(StudyModel).first()
spec = db.session.query(WorkflowSpecModel).filter_by(id='two_forms').first()
@ -141,13 +142,25 @@ class TestStudy(BaseTest, unittest.TestCase):
json_data = json.loads(rv.get_data(as_text=True))
workflow = WorkflowModelSchema().load(json_data, session=db.session)
# get the first from in the two form workflow.
rv = self.app.get('/v1.0/workflow/%i/tasks' % workflow.id, content_type="application/json")
json_data = json.loads(rv.get_data(as_text=True))
tasks = TaskSchema(many=True).load(json_data)
self.assertEqual(1, len(tasks))
self.assertIsNotNone(tasks[0].form)
self.assertEqual("StepOne", tasks[0].name)
self.assertEqual(1, len(tasks[0].form['fields']))
# Complete the form for Step one and post it.
tasks[0].form['fields'][0]['value']="Blue"
rv = self.app.put('/v1.0/workflow/%i/task/%s' % (workflow.id, tasks[0].id), content_type="application/json",
rv = self.app.put('/v1.0/workflow/%i/task/%s' % (workflow.id, tasks[0].name), content_type="application/json",
data=json.dumps(TaskSchema().dump(tasks[0])))
self.assert_success(rv)
# Get the next Task
rv = self.app.get('/v1.0/workflow/%i/tasks' % study.id, content_type="application/json")
self.assert_success(rv)
json_data = json.loads(rv.get_data(as_text=True))
tasks = TaskSchema(many=True).load(json_data)
self.assertEqual("StepTwo", tasks[0].name)
self.assertEqual(3, len(tasks[0].form["fields"][0]["options"]))