Adding tests

This commit is contained in:
Carlos Lopez 2020-08-10 21:18:41 -06:00
parent a561a5cddc
commit cef7c48be2
3 changed files with 11 additions and 3 deletions

View File

@ -11,7 +11,7 @@ from crc.models.protocol_builder import ProtocolBuilderStatus, \
ProtocolBuilderStudySchema ProtocolBuilderStudySchema
from crc.models.approval import ApprovalStatus from crc.models.approval import ApprovalStatus
from crc.models.task_event import TaskEventModel from crc.models.task_event import TaskEventModel
from crc.models.study import StudyModel, StudySchema, StudyStatus from crc.models.study import StudyEvent, StudyModel, StudySchema, StudyStatus
from crc.models.workflow import WorkflowSpecModel, WorkflowModel from crc.models.workflow import WorkflowSpecModel, WorkflowModel
from crc.services.file_service import FileService from crc.services.file_service import FileService
from crc.services.workflow_processor import WorkflowProcessor from crc.services.workflow_processor import WorkflowProcessor
@ -134,10 +134,12 @@ class TestStudyApi(BaseTest):
def test_update_study(self): def test_update_study(self):
self.load_example_data() self.load_example_data()
update_comment = 'Updating the study'
study: StudyModel = session.query(StudyModel).first() study: StudyModel = session.query(StudyModel).first()
study.title = "Pilot Study of Fjord Placement for Single Fraction Outcomes to Cortisol Susceptibility" study.title = "Pilot Study of Fjord Placement for Single Fraction Outcomes to Cortisol Susceptibility"
study_schema = StudySchema().dump(study) study_schema = StudySchema().dump(study)
study_schema['status'] = StudyStatus.in_progress.value study_schema['status'] = StudyStatus.in_progress.value
study_schema['comment'] = update_comment
rv = self.app.put('/v1.0/study/%i' % study.id, rv = self.app.put('/v1.0/study/%i' % study.id,
content_type="application/json", content_type="application/json",
headers=self.logged_in_headers(), headers=self.logged_in_headers(),
@ -147,6 +149,12 @@ class TestStudyApi(BaseTest):
self.assertEqual(study.title, json_data['title']) self.assertEqual(study.title, json_data['title'])
self.assertEqual(study.status.value, json_data['status']) self.assertEqual(study.status.value, json_data['status'])
# Making sure events history is being properly recorded
study_events = session.query(StudyEvent)
self.assertEqual(study_events.count(), 1)
self.assertEqual(study_events.first().status, StudyStatus.in_progress)
self.assertEqual(study_events.first().comment, update_comment)
@patch('crc.services.protocol_builder.ProtocolBuilderService.get_investigators') # mock_studies @patch('crc.services.protocol_builder.ProtocolBuilderService.get_investigators') # mock_studies
@patch('crc.services.protocol_builder.ProtocolBuilderService.get_required_docs') # mock_docs @patch('crc.services.protocol_builder.ProtocolBuilderService.get_required_docs') # mock_docs
@patch('crc.services.protocol_builder.ProtocolBuilderService.get_study_details') # mock_details @patch('crc.services.protocol_builder.ProtocolBuilderService.get_study_details') # mock_details

View File

@ -19,7 +19,7 @@ class TestStudyDetailsDocumentsScript(BaseTest):
""" """
1. get a list of all documents related to the study. 1. get a list of all documents related to the study.
2. For this study, is this document required accroding to the protocol builder? 2. For this study, is this document required accroding to the protocol builder?
3. For ALL uploaded documents, what the total number of files that were uploaded? per instance of this document naming 3. For ALL uploaded documents, what the total number of files that were uploaded? per instance of this document naming
convention that we are implementing for the IRB. convention that we are implementing for the IRB.
""" """

View File

@ -84,7 +84,7 @@ class TestStudyService(BaseTest):
# Assure the workflow is now started, and knows the total and completed tasks. # Assure the workflow is now started, and knows the total and completed tasks.
studies = StudyService.get_studies_for_user(user) studies = StudyService.get_studies_for_user(user)
workflow = next(iter(studies[0].categories[0].workflows)) # Workflows is a set. workflow = next(iter(studies[0].categories[0].workflows)) # Workflows is a set.
# self.assertEqual(WorkflowStatus.user_input_required, workflow.status) # self.assertEqual(WorkflowStatus.user_input_required, workflow.status)
self.assertTrue(workflow.total_tasks > 0) self.assertTrue(workflow.total_tasks > 0)
self.assertEqual(0, workflow.completed_tasks) self.assertEqual(0, workflow.completed_tasks)
self.assertIsNotNone(workflow.spec_version) self.assertIsNotNone(workflow.spec_version)