def test_validate_validates_path_has_not_already_been_registered(self):
     """
     Test whether overriden validate method validates that the submitted path
     has not been already registered.
     """
     path = 'SERVICES/PACS/MyPACS/123456-crazy/brain_crazy_study/SAG_T1_MPRAGE/file1.dcm'
     data = {
         'PatientID': '123456',
         'PatientName': 'crazy',
         'StudyDate': '2020-07-15',
         'StudyInstanceUID': '1.1.3432.54.6545674765.765434',
         'StudyDescription': 'brain_crazy_study',
         'SeriesDescription': 'SAG T1 MPRAGE',
         'SeriesInstanceUID': '2.4.3432.54.845674765.763345',
         'pacs_name': 'MyPACS',
         'path': path
     }
     pacs = PACS(identifier='MyPACS')
     pacs.save()
     pacs_file = PACSFile(PatientID='123456',
                          StudyDate='2020-07-15',
                          StudyInstanceUID='1.1.3432.54.6545674765.765434',
                          SeriesInstanceUID='2.4.3432.54.845674765.763345',
                          pacs=pacs)
     pacs_file.fname.name = path
     pacs_file.save()
     with self.assertRaises(serializers.ValidationError):
         pacsfiles_serializer = PACSFileSerializer()
         pacsfiles_serializer.validate(data)
Beispiel #2
0
 def test_validate_updates_validated_data(self):
     """
     Test whether overriden validate method updates validated data with a PACS object.
     """
     path = 'SERVICES/PACS/MyPACS/123456-crazy/brain_crazy_study/SAG_T1_MPRAGE/file1.dcm'
     data = {
         'PatientID': '123456',
         'PatientName': 'crazy',
         'StudyInstanceUID': '1.1.3432.54.6545674765.765434',
         'StudyDescription': 'brain_crazy_study',
         'SeriesDescription': 'SAG T1 MPRAGE',
         'SeriesInstanceUID': '2.4.3432.54.845674765.763345',
         'pacs_name': 'MyPACS',
         'path': path
     }
     pacsfiles_serializer = PACSFileSerializer()
     new_data = pacsfiles_serializer.validate(data)
     self.assertIn('pacs', new_data)