Merge pull request #394 from sartography/varchar-category-id-483

Varchar category id 483
This commit is contained in:
Dan Funk 2021-10-07 14:44:13 -04:00 committed by GitHub
commit 5cb5338fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 7 deletions

View File

@ -430,19 +430,23 @@ class StudyService(object):
def _update_status_of_workflow_meta(workflow_metas, status):
# Update the status on each workflow
warnings = []
unused_statuses = status.copy() # A list of all the statuses that are not used.
for wfm in workflow_metas:
unused_statuses.pop(wfm.workflow_spec_id, None)
wfm.state_message = ''
# do we have a status for you
if wfm.workflow_spec_id not in status.keys():
warnings.append(ApiError("missing_status", "No status specified for workflow %s" % wfm.workflow_spec_id))
warnings.append(ApiError("missing_status", "No status information provided about workflow %s" % wfm.workflow_spec_id))
continue
if not isinstance(status[wfm.workflow_spec_id], dict):
warnings.append(ApiError(code='invalid_status',
message=f'Status must be a dictionary with "status" and "message" keys. Name is {wfm.workflow_spec_id}. Status is {status[wfm.workflow_spec_id]}'))
continue
if 'message' in status[wfm.workflow_spec_id].keys():
wfm.state_message = status[wfm.workflow_spec_id]['message']
if 'status' not in status[wfm.workflow_spec_id].keys():
warnings.append(ApiError("missing_status",
"Workflow '%s' does not have a status setting" % wfm.workflow_spec_id))
warnings.append(ApiError("missing_status_key",
"Workflow '%s' is present in master workflow, but doesn't have a status" % wfm.workflow_spec_id))
continue
if not WorkflowState.has_value(status[wfm.workflow_spec_id]['status']):
warnings.append(ApiError("invalid_state",
@ -450,9 +454,15 @@ class StudyService(object):
wfm.workflow_spec_id, status[wfm.workflow_spec_id]['status'], ",".join(WorkflowState.list())
)))
continue
wfm.state = WorkflowState[status[wfm.workflow_spec_id]['status']]
if 'message' in status[wfm.workflow_spec_id].keys():
wfm.state_message = status[wfm.workflow_spec_id]['message']
for status in unused_statuses:
if isinstance(unused_statuses[status], dict) and 'status' in unused_statuses[status]:
warnings.append(ApiError("unmatched_status", "The master workflow provided a status for '%s' a "
"workflow that doesn't seem to exist." %
status))
return warnings
@staticmethod

View File

@ -41,9 +41,12 @@ class TestStudyStatusMessage(BaseTest):
status = {'bad_name': {'status': 'hidden', 'message': 'This is my status message!'}}
workflow_metas, warnings = self.run_update_status(status)
self.assertEqual(1, len(warnings))
self.assertEqual(2, len(warnings))
self.assertEqual('missing_status', warnings[0].code)
self.assertEqual('No status specified for workflow random_fact', warnings[0].message)
self.assertEqual('No status information provided about workflow random_fact', warnings[0].message)
self.assertEqual('unmatched_status', warnings[1].code)
self.assertEqual('The master workflow provided a status for \'bad_name\' a workflow that doesn\'t'
' seem to exist.', warnings[1].message)
def test_study_status_message_not_dict(self):
# your entry in the status dictionary is not a dictionary