throw a sensible error when study is not found on get_study (don't 500)
some ugly fixes in the file_service for improving panda output from spreadsheet processing that I need to revist. now that the spiff-workflow handles multi-instance, we can't have random multi-instance tasks around. Improved tests around study deletion.
This commit is contained in:
parent
519a034d87
commit
c79415a794
|
@ -47,6 +47,8 @@ def update_study(study_id, body):
|
|||
def get_study(study_id):
|
||||
study_service = StudyService()
|
||||
study = study_service.get_study(study_id)
|
||||
` if(study is None):
|
||||
raise ApiError("Study not found", status_code=404)
|
||||
schema = StudySchema()
|
||||
return schema.dump(study)
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
@ -67,7 +68,14 @@ class FileService(object):
|
|||
data_model = FileService.get_reference_file_data(FileService.IRB_PRO_CATEGORIES_FILE)
|
||||
xls = ExcelFile(data_model.data)
|
||||
df = xls.parse(xls.sheet_names[0])
|
||||
return df.set_index('Code').to_dict('index')
|
||||
df['Id'] = df['Id'].fillna(0)
|
||||
df = df.astype({'Id': 'Int64'})
|
||||
df = df.fillna('')
|
||||
df = df.applymap(str)
|
||||
df = df.set_index('Code')
|
||||
# IF we need to convert the column names to something more sensible.
|
||||
# df.columns = [snakeCase(x) for x in df.columns]
|
||||
return json.loads(df.to_json(orient='index'))
|
||||
# # Pandas is lovely, but weird. Here we drop records without an Id, and convert it to an integer.
|
||||
# df = df.drop_duplicates(subset='Id').astype({'Id': 'Int64'})
|
||||
# Now we index on the ID column and convert to a dictionary, where the key is the id, and the value
|
||||
|
|
|
@ -50,6 +50,7 @@ class StudyService(object):
|
|||
session.query(TaskEventModel).filter_by(study_id=study_id).delete()
|
||||
session.query(WorkflowModel).filter_by(study_id=study_id).delete()
|
||||
session.query(StudyModel).filter_by(id=study_id).delete()
|
||||
session.commit()
|
||||
|
||||
@staticmethod
|
||||
def get_categories():
|
||||
|
|
Binary file not shown.
|
@ -27,7 +27,6 @@
|
|||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>SequenceFlow_00p5po6</bpmn:incoming>
|
||||
<bpmn:outgoing>SequenceFlow_17ggqu2</bpmn:outgoing>
|
||||
<bpmn:multiInstanceLoopCharacteristics />
|
||||
</bpmn:userTask>
|
||||
<bpmn:textAnnotation id="TextAnnotation_1haj11l">
|
||||
<bpmn:text>We have a test that replaces tow_forms with this file, which adds a new step to the process. A breaking change.</bpmn:text>
|
||||
|
|
|
@ -195,6 +195,9 @@ class TestStudyApi(BaseTest):
|
|||
session.commit()
|
||||
rv = self.app.delete('/v1.0/study/%i' % study.id, headers=self.logged_in_headers())
|
||||
self.assert_success(rv)
|
||||
del_study = session.query(StudyModel).filter(StudyModel.id == study.id).first()
|
||||
self.assertIsNone(del_study)
|
||||
|
||||
|
||||
|
||||
# """
|
||||
|
|
Loading…
Reference in New Issue