Fixing broken test by using proper FileSchema

This commit is contained in:
Carlos Lopez 2020-05-31 22:00:52 -06:00
parent 311e180c65
commit bec11980eb
3 changed files with 20 additions and 22 deletions

View File

@ -151,7 +151,7 @@ class StudySchema(ma.Schema):
hsr_number = fields.String(allow_none=True) hsr_number = fields.String(allow_none=True)
sponsor = fields.String(allow_none=True) sponsor = fields.String(allow_none=True)
ind_number = fields.String(allow_none=True) ind_number = fields.String(allow_none=True)
files = fields.List(fields.Nested(SimpleFileSchema), dump_only=True) files = fields.List(fields.Nested(FileSchema), dump_only=True)
approvals = fields.List(fields.Nested('ApprovalSchema'), dump_only=True) approvals = fields.List(fields.Nested('ApprovalSchema'), dump_only=True)
class Meta: class Meta:

View File

@ -56,7 +56,6 @@ class StudyService(object):
study = Study.from_model(study_model) study = Study.from_model(study_model)
study.categories = StudyService.get_categories() study.categories = StudyService.get_categories()
workflow_metas = StudyService.__get_workflow_metas(study_id) workflow_metas = StudyService.__get_workflow_metas(study_id)
study.files = FileService.get_files_for_study(study.id)
approvals = ApprovalService.get_approvals_for_study(study.id) approvals = ApprovalService.get_approvals_for_study(study.id)
study.approvals = [Approval.from_model(approval_model) for approval_model in approvals] study.approvals = [Approval.from_model(approval_model) for approval_model in approvals]

View File

@ -72,28 +72,27 @@ class TestStudyApi(BaseTest):
def test_get_study_has_details_about_files(self): def test_get_study_has_details_about_files(self):
# # Set up the study and attach a file to it. # Set up the study and attach a file to it.
# self.load_example_data() self.load_example_data()
# self.create_reference_document() self.create_reference_document()
# workflow = self.create_workflow('file_upload_form') workflow = self.create_workflow('file_upload_form')
# processor = WorkflowProcessor(workflow) processor = WorkflowProcessor(workflow)
# task = processor.next_task() task = processor.next_task()
# irb_code = "UVACompl_PRCAppr" # The first file referenced in pb required docs. irb_code = "UVACompl_PRCAppr" # The first file referenced in pb required docs.
# FileService.add_workflow_file(workflow_id=workflow.id, FileService.add_workflow_file(workflow_id=workflow.id,
# name="anything.png", content_type="png", name="anything.png", content_type="png",
# binary_data=b'1234', irb_doc_code=irb_code) binary_data=b'1234', irb_doc_code=irb_code)
#
# api_response = self.app.get('/v1.0/study/%i' % workflow.study_id, api_response = self.app.get('/v1.0/study/%i' % workflow.study_id,
# headers=self.logged_in_headers(), content_type="application/json") headers=self.logged_in_headers(), content_type="application/json")
# self.assert_success(api_response) self.assert_success(api_response)
# study = StudySchema().loads(api_response.get_data(as_text=True)) study = StudySchema().loads(api_response.get_data(as_text=True))
# self.assertEquals(1, len(study.files)) self.assertEquals(1, len(study.files))
# self.assertEquals("UVA Compliance/PRC Approval", study.files[0]["category"]) self.assertEquals("UVA Compliance/PRC Approval", study.files[0]["category"])
# self.assertEquals("Cancer Center's PRC Approval Form", study.files[0]["description"]) self.assertEquals("Cancer Center's PRC Approval Form", study.files[0]["description"])
# self.assertEquals("UVA Compliance/PRC Approval.png", study.files[0]["download_name"]) self.assertEquals("UVA Compliance/PRC Approval.png", study.files[0]["download_name"])
# TODO: WRITE A TEST FOR STUDY FILES # TODO: WRITE A TEST FOR STUDY FILES
pass
def test_get_study_has_details_about_approvals(self): def test_get_study_has_details_about_approvals(self):
# TODO: WRITE A TEST FOR STUDY APPROVALS # TODO: WRITE A TEST FOR STUDY APPROVALS