Merge remote-tracking branch 'origin/feature/update-task-data' into feature/update-task-data

This commit is contained in:
Aaron Louie 2020-01-28 13:25:57 -05:00
commit f312a0a0de
3 changed files with 28 additions and 1 deletions

View File

@ -247,6 +247,18 @@ paths:
description: The unique id of an existing workflow specification to modify.
schema:
type: string
get:
operationId: crc.api.workflow.get_workflow_specification
summary: Returns a single workflow specification
tags:
- Workflows and Tasks
responses:
'200':
description: Workflow specification.
content:
application/json:
schema:
$ref: "#/components/schemas/WorkflowSpec"
put:
operationId: crc.api.workflow.update_workflow_specification
summary: Modifies an existing workflow specification with the given parameters.

View File

@ -21,7 +21,7 @@ def add_workflow_specification(body):
return WorkflowSpecModelSchema().dump(new_spec)
def update_workflow_specification(spec_id, body):
def get_workflow_specification(spec_id):
if spec_id is None:
error = ApiError('unknown_spec', 'Please provide a valid Workflow Specification ID.')
return ApiErrorSchema.dump(error), 404
@ -32,7 +32,12 @@ def update_workflow_specification(spec_id, body):
error = ApiError('unknown_spec', 'The Workflow Specification "' + spec_id + '" is not recognized.')
return ApiErrorSchema.dump(error), 404
return WorkflowSpecModelSchema().dump(spec)
def update_workflow_specification(spec_id, body):
spec = WorkflowSpecModelSchema().load(body, session=session)
spec.id = spec_id
session.add(spec)
session.commit()
return WorkflowSpecModelSchema().dump(spec)

View File

@ -100,6 +100,16 @@ class TestStudy(BaseTest):
num_after = session.query(WorkflowSpecModel).count()
self.assertEqual(num_after, num_before + 1)
def test_get_workflow_specification(self):
self.load_example_data()
db_spec = session.query(WorkflowSpecModel).first()
rv = self.app.get('/v1.0/workflow-specification/%s' % db_spec.id)
self.assert_success(rv)
json_data = json.loads(rv.get_data(as_text=True))
api_spec = WorkflowSpecModelSchema().load(json_data, session=session)
self.assertEqual(db_spec, api_spec)
def test_modify_workflow_specification(self):
self.load_example_data()
old_id = 'random_fact'