Adds endpoint for adding a workflow specification
This commit is contained in:
parent
53d72bdaae
commit
75881bf1d3
23
crc/api.yml
23
crc/api.yml
|
@ -217,6 +217,29 @@ paths:
|
|||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
post:
|
||||
operationId: crc.api.workflow.add_workflow_specification
|
||||
summary: Creates a new workflow specification with the given parameters.
|
||||
tags:
|
||||
- Workflows and Tasks
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/WorkflowSpec'
|
||||
responses:
|
||||
'200':
|
||||
description: Workflow specification created successfully.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/WorkflowSpec"
|
||||
default:
|
||||
description: unexpected error
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Error"
|
||||
/file:
|
||||
parameters:
|
||||
- name: spec_id
|
||||
|
|
|
@ -9,6 +9,13 @@ def all_specifications():
|
|||
return schema.dump(db.session.query(WorkflowSpecModel).all())
|
||||
|
||||
|
||||
def add_workflow_specification(body):
|
||||
workflow_spec = WorkflowSpecModelSchema().load(body, session=db.session)
|
||||
db.session.add(workflow_spec)
|
||||
db.session.commit()
|
||||
return WorkflowSpecModelSchema().dump(workflow_spec)
|
||||
|
||||
|
||||
def get_workflow(workflow_id):
|
||||
schema = WorkflowModelSchema()
|
||||
workflow = db.session.query(WorkflowModel).filter_by(id=workflow_id).first()
|
||||
|
|
|
@ -87,6 +87,18 @@ class TestStudy(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(spec.display_name, spec2.display_name)
|
||||
self.assertEqual(spec.description, spec2.description)
|
||||
|
||||
def test_add_new_workflow_specification(self):
|
||||
self.load_example_data();
|
||||
num_before = db.session.query(WorkflowSpecModel).count()
|
||||
spec = WorkflowSpecModel(id='make_cookies', display_name='Cooooookies', description='Om nom nom delicious cookies')
|
||||
rv = self.app.post('/v1.0/workflow-specification', content_type="application/json",
|
||||
data=json.dumps(WorkflowSpecModelSchema().dump(spec)))
|
||||
self.assert_success(rv)
|
||||
db_spec = db.session.query(WorkflowSpecModel).filter_by(id='make_cookies').first()
|
||||
self.assertEqual(spec.display_name, db_spec.display_name)
|
||||
num_after = db.session.query(WorkflowSpecModel).count()
|
||||
self.assertEqual(num_after, num_before + 1)
|
||||
|
||||
def test_add_workflow_to_study(self):
|
||||
self.load_example_data()
|
||||
study = db.session.query(StudyModel).first()
|
||||
|
|
Loading…
Reference in New Issue