def testDicomWithBinaryValues(self):
     # One of the test files in the pydicom module will throw an IOError
     # when parsing metadata.  We should work around that and still be able
     # to import the file
     samplePath = os.path.join(os.path.dirname(os.path.abspath(
         pydicom.__file__)), 'data', 'test_files', 'OBXXXX1A.dcm')
     admin, user = self.users
     # Create a collection, folder, and item
     collection = Collection().createCollection('collection5', admin, public=True)
     folder = Folder().createFolder(collection, 'folder5', parentType='collection', public=True)
     item = Item().createItem('item5', admin, folder)
     # Upload this dicom file
     with open(samplePath, 'rb') as fp, _EventHelper('dicom_viewer.upload.success') as helper:
         dcmFile = Upload().uploadFromFile(
             obj=fp,
             size=os.path.getsize(samplePath),
             name=os.path.basename(samplePath),
             parentType='item',
             parent=item,
             mimeType='application/dicom',
             user=user
         )
         self.assertIsNotNone(dcmFile)
         # Wait for handler success event
         handled = helper.wait()
         self.assertTrue(handled)
     # Check if the 'dicomItem' is well processed
     dicomItem = Item().load(item['_id'], force=True)
     self.assertIn('dicom', dicomItem)
     self.assertHasKeys(dicomItem['dicom'], ['meta', 'files'])
Beispiel #2
0
 def testDicomWithBinaryValues(self):
     # One of the test files in the pydicom module will throw an IOError
     # when parsing metadata.  We should work around that and still be able
     # to import the file
     samplePath = os.path.join(os.path.dirname(os.path.abspath(
         pydicom.__file__)), 'data', 'test_files', 'OBXXXX1A.dcm')
     admin, user = self.users
     # Create a collection, folder, and item
     collection = Collection().createCollection('collection5', admin, public=True)
     folder = Folder().createFolder(collection, 'folder5', parentType='collection', public=True)
     item = Item().createItem('item5', admin, folder)
     # Upload this dicom file
     with open(samplePath, 'rb') as fp, _EventHelper('dicom_viewer.upload.success') as helper:
         dcmFile = Upload().uploadFromFile(
             obj=fp,
             size=os.path.getsize(samplePath),
             name=os.path.basename(samplePath),
             parentType='item',
             parent=item,
             mimeType='application/dicom',
             user=user
         )
         self.assertIsNotNone(dcmFile)
         # Wait for handler success event
         handled = helper.wait()
         self.assertTrue(handled)
     # Check if the 'dicomItem' is well processed
     dicomItem = Item().load(item['_id'], force=True)
     self.assertIn('dicom', dicomItem)
     self.assertHasKeys(dicomItem['dicom'], ['meta', 'files'])
 def _uploadDicomFiles(self, item, user):
     # Upload the files in the reverse order to check if they're well sorted
     for i in [1, 3, 0, 2]:
         file = os.path.join(self.dataDir, '00000%i.dcm' % i)
         with open(file, 'rb') as fp, _EventHelper('dicom_viewer.upload.success') as helper:
             dcmFile = Upload().uploadFromFile(
                 obj=fp,
                 size=os.path.getsize(file),
                 name='dicomFile{}.dcm'.format(i),
                 parentType='item',
                 parent=item,
                 mimeType='application/dicom',
                 user=user
             )
             self.assertIsNotNone(dcmFile)
             # Wait for handler success event
             handled = helper.wait()
             self.assertTrue(handled)
Beispiel #4
0
 def _uploadDicomFiles(self, item, user):
     # Upload the files in the reverse order to check if they're well sorted
     for i in [1, 3, 0, 2]:
         file = os.path.join(self.dataDir, '00000%i.dcm' % i)
         with open(file, 'rb') as fp, _EventHelper('dicom_viewer.upload.success') as helper:
             dcmFile = Upload().uploadFromFile(
                 obj=fp,
                 size=os.path.getsize(file),
                 name='dicomFile{}.dcm'.format(i),
                 parentType='item',
                 parent=item,
                 mimeType='application/dicom',
                 user=user
             )
             self.assertIsNotNone(dcmFile)
             # Wait for handler success event
             handled = helper.wait()
             self.assertTrue(handled)