changeset 192:6ff9d035b26b Orthanc-1.5.1

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 15 Dec 2018 10:50:45 +0100
parents bc8bc83465dc
children ef2c66f81249
files Tests/Tests.py Tests/Toolbox.py
diffstat 2 files changed, 21 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Fri Dec 14 11:42:18 2018 +0100
+++ b/Tests/Tests.py	Sat Dec 15 10:50:45 2018 +0100
@@ -487,8 +487,9 @@
     def test_archive(self):
         UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')
         UploadInstance(_REMOTE, 'Knee/T2/IM-0001-0001.dcm')
-
-        z = GetArchive(_REMOTE, '/patients/%s/archive' % DoGet(_REMOTE, '/patients')[0])
+        knee = 'ca29faea-b6a0e17f-067743a1-8b778011-a48b2a17'
+
+        z = GetArchive(_REMOTE, '/patients/%s/archive' % knee)
         self.assertEqual(2, len(z.namelist()))
 
         z = GetArchive(_REMOTE, '/studies/%s/archive' % DoGet(_REMOTE, '/studies')[0])
@@ -498,10 +499,16 @@
         self.assertEqual(1, len(z.namelist()))
 
         UploadInstance(_REMOTE, 'Brainix/Flair/IM-0001-0001.dcm')
-
-        z = GetArchive(_REMOTE, '/patients/%s/archive' % DoGet(_REMOTE, '/patients')[0])
+        brainix = '16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0'
+
+        z = GetArchive(_REMOTE, '/patients/%s/archive' % knee)
         self.assertEqual(2, len(z.namelist()))
-        
+
+        z = PostArchive(_REMOTE, '/tools/create-archive', {
+            'Resources' : [ brainix, knee ]
+            })
+        self.assertEqual(3, len(z.namelist()))
+       
 
     def test_media_archive(self):
         UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')
--- a/Tests/Toolbox.py	Fri Dec 14 11:42:18 2018 +0100
+++ b/Tests/Toolbox.py	Sat Dec 15 10:50:45 2018 +0100
@@ -214,6 +214,15 @@
     else:
         return zipfile.ZipFile(StringIO(s), "r")
 
+def PostArchive(orthanc, uri, body):
+    # http://stackoverflow.com/a/1313868/881731
+    s = DoPost(orthanc, uri, body)
+
+    if (sys.version_info >= (3, 0)):
+        return zipfile.ZipFile(BytesIO(s), "r")
+    else:
+        return zipfile.ZipFile(StringIO(s), "r")
+
 def IsDefinedInLua(orthanc, name):
     s = DoPost(orthanc, '/tools/execute-script', 'print(type(%s))' % name, 'application/lua')
     return (s.strip() != 'nil')