changeset 293:032722c3e919

extended test_archive_transcode
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 08 May 2020 19:15:00 +0200
parents e1827a4f5d3b
children 192665e6113f f95cd3af1c7a
files Tests/Tests.py
diffstat 1 files changed, 67 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Fri May 08 19:05:06 2020 +0200
+++ b/Tests/Tests.py	Fri May 08 19:15:00 2020 +0200
@@ -5535,7 +5535,7 @@
     def test_archive_transcode(self):
         info = UploadInstance(_REMOTE, 'KarstenHilbertRF.dcm')
 
-        # "/media"
+        # GET on "/media"
         z = GetArchive(_REMOTE, '/patients/%s/media' % info['ParentPatient'])
         self.assertEqual(2, len(z.namelist()))
         self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(z.read('IMAGES/IM0')))
@@ -5551,7 +5551,28 @@
         z = GetArchive(_REMOTE, '/series/%s/media?transcode=1.2.840.10008.1.2.4.57' % info['ParentSeries'])
         self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0')))
 
-        # "/archive"
+
+        # POST on "/media"
+        self.assertRaises(Exception, lambda: PostArchive(
+            _REMOTE, '/patients/%s/media' % info['ParentPatient'], { 'Transcode' : 'nope' }))
+
+        z = PostArchive(_REMOTE, '/patients/%s/media' % info['ParentPatient'], {
+            'Transcode' : '1.2.840.10008.1.2.4.50',
+            })
+        self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(z.read('IMAGES/IM0')))
+
+        z = PostArchive(_REMOTE, '/studies/%s/media' % info['ParentStudy'], {
+            'Transcode' : '1.2.840.10008.1.2.4.51',
+            })
+        self.assertEqual('1.2.840.10008.1.2.4.51', GetTransferSyntax(z.read('IMAGES/IM0')))
+
+        z = PostArchive(_REMOTE, '/series/%s/media' % info['ParentSeries'], {
+            'Transcode' : '1.2.840.10008.1.2.4.57',
+            })
+        self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0')))
+
+        
+        # GET on "/archive"
         z = GetArchive(_REMOTE, '/patients/%s/archive' % info['ParentPatient'])
         self.assertEqual(1, len(z.namelist()))
         self.assertEqual('1.2.840.10008.1.2.1', GetTransferSyntax(z.read(z.namelist()[0])))
@@ -5566,4 +5587,48 @@
 
         z = GetArchive(_REMOTE, '/series/%s/archive?transcode=1.2.840.10008.1.2.4.70' % info['ParentSeries'])
         self.assertEqual('1.2.840.10008.1.2.4.70', GetTransferSyntax(z.read(z.namelist()[0])))
+
+
+        # POST on "/archive"
+        self.assertRaises(Exception, lambda: PostArchive(
+            _REMOTE, '/patients/%s/archive' % info['ParentPatient'], { 'Transcode' : 'nope' }))
+
+        z = PostArchive(_REMOTE, '/patients/%s/archive' % info['ParentPatient'], {
+            'Transcode' : '1.2.840.10008.1.2.4.50',
+            })
+        self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(z.read(z.namelist()[0])))
+
+        z = PostArchive(_REMOTE, '/studies/%s/archive' % info['ParentStudy'], {
+            'Transcode' : '1.2.840.10008.1.2.4.51',
+            })
+        self.assertEqual('1.2.840.10008.1.2.4.51', GetTransferSyntax(z.read(z.namelist()[0])))
+
+        z = PostArchive(_REMOTE, '/series/%s/archive' % info['ParentSeries'], {
+            'Transcode' : '1.2.840.10008.1.2.4.57',
+            })
+        self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read(z.namelist()[0])))
         
+
+        # "/tools/create-*"
+        z = PostArchive(_REMOTE, '/tools/create-archive', {
+            'Resources' : [ info['ParentStudy'] ],
+            'Transcode' : '1.2.840.10008.1.2.4.50',
+            })
+        self.assertEqual(1, len(z.namelist()))
+        self.assertEqual('1.2.840.10008.1.2.4.50', GetTransferSyntax(z.read(z.namelist()[0])))
+
+        z = PostArchive(_REMOTE, '/tools/create-media', {
+            'Resources' : [ info['ParentStudy'] ],
+            'Transcode' : '1.2.840.10008.1.2.4.51',
+            })
+        self.assertEqual(2, len(z.namelist()))
+        self.assertEqual('1.2.840.10008.1.2.4.51', GetTransferSyntax(z.read('IMAGES/IM0')))
+
+        z = PostArchive(_REMOTE, '/tools/create-media-extended', {
+            'Resources' : [ info['ParentStudy'] ],
+            'Transcode' : '1.2.840.10008.1.2.4.57',
+            })
+        self.assertEqual(2, len(z.namelist()))
+        self.assertEqual('1.2.840.10008.1.2.4.57', GetTransferSyntax(z.read('IMAGES/IM0')))
+
+