Add the ability to delete a workflow.
This commit is contained in:
parent
b54bd49cf4
commit
fb465531ca
20
crc/api.yml
20
crc/api.yml
|
@ -290,12 +290,7 @@ paths:
|
|||
example: '<?xml version="1.0" encoding="UTF-8"?><bpmn:definitions></bpmn:definitions>'
|
||||
# /v1.0/workflow/0
|
||||
/workflow/{workflow_id}:
|
||||
get:
|
||||
operationId: crc.api.workflow.get_workflow
|
||||
summary: Detailed information for a specific workflow instance
|
||||
tags:
|
||||
- Workflows and Tasks
|
||||
parameters:
|
||||
parameters:
|
||||
- name: workflow_id
|
||||
in: path
|
||||
required: true
|
||||
|
@ -303,6 +298,11 @@ paths:
|
|||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
get:
|
||||
operationId: crc.api.workflow.get_workflow
|
||||
summary: Detailed information for a specific workflow instance
|
||||
tags:
|
||||
- Workflows and Tasks
|
||||
responses:
|
||||
'200':
|
||||
description: Returns details about the workflows state and current task
|
||||
|
@ -316,6 +316,14 @@ paths:
|
|||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
delete:
|
||||
operationId: crc.api.workflow.delete
|
||||
summary: Removes an existing workflow
|
||||
tags:
|
||||
- Files
|
||||
responses:
|
||||
'204':
|
||||
description: The workflow was removed
|
||||
/workflow/{workflow_id}/tasks:
|
||||
get:
|
||||
operationId: crc.api.workflow.get_tasks
|
||||
|
|
|
@ -50,4 +50,4 @@ def add_workflow_to_study(study_id, body):
|
|||
workflow_spec_id=workflow_spec_model.id)
|
||||
db.session.add(workflow)
|
||||
db.session.commit()
|
||||
return get_study_workflows(study_id)
|
||||
return WorkflowSchema().dump(workflow)
|
||||
|
|
|
@ -14,6 +14,8 @@ def get_workflow(workflow_id):
|
|||
workflow = db.session.query(WorkflowModel).filter_by(id=workflow_id).first()
|
||||
return schema.dump(workflow)
|
||||
|
||||
def delete(workflow_id):
|
||||
db.session.query(WorkflowModel).filter_by(id=workflow_id).delete()
|
||||
|
||||
def get_tasks(workflow_id):
|
||||
workflow = db.session.query(WorkflowModel).filter_by(id=workflow_id).first()
|
||||
|
|
|
@ -44,8 +44,8 @@ class BaseTest:
|
|||
self.auths = {}
|
||||
|
||||
def load_example_data(self):
|
||||
ExampleDataLoader.clean_db()
|
||||
from example_data import ExampleDataLoader
|
||||
ExampleDataLoader.clean_db()
|
||||
ExampleDataLoader().load_all()
|
||||
|
||||
def assert_success(self, rv, msg=""):
|
||||
|
|
|
@ -68,6 +68,20 @@ class TestStudy(BaseTest, unittest.TestCase):
|
|||
workflows = WorkflowSchema(many=True).load(json_data, session=db.session)
|
||||
self.assertEqual(workflows[0].id, workflow.id)
|
||||
|
||||
def test_delete_workflow(self):
|
||||
self.load_example_data()
|
||||
study = db.session.query(StudyModel).first()
|
||||
spec = db.session.query(WorkflowSpecModel).first()
|
||||
rv = self.app.post('/v1.0/study/%i/workflows' % study.id,content_type="application/json",
|
||||
data=json.dumps(WorkflowSpecSchema().dump(spec)))
|
||||
self.assertEqual(1, db.session.query(WorkflowModel).count())
|
||||
json_data = json.loads(rv.get_data(as_text=True))
|
||||
workflow = WorkflowSchema().load(json_data, session=db.session)
|
||||
rv = self.app.delete('/v1.0/workflow/%i' % workflow.id)
|
||||
self.assert_success(rv)
|
||||
self.assertEqual(0, db.session.query(WorkflowModel).count())
|
||||
|
||||
|
||||
def test_get_current_user_tasks(self):
|
||||
self.load_example_data()
|
||||
study = db.session.query(StudyModel).first()
|
||||
|
|
Loading…
Reference in New Issue