diff Tests/Tests.py @ 61:967d44407308

test UnknownSopClassAccepted option
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 23 Nov 2015 15:24:45 +0100
parents cd3c7f70f139
children f9c4ce95756f
line wrap: on
line diff
--- a/Tests/Tests.py	Thu Nov 19 12:00:30 2015 +0100
+++ b/Tests/Tests.py	Mon Nov 23 15:24:45 2015 +0100
@@ -1868,21 +1868,27 @@
 
 
     def test_incoming_jpeg(self):
-        def storescu():
+        def storescu(image, acceptUnknownSopClassUid):
+            if acceptUnknownSopClassUid:
+                tmp = [ '-xf', GetDatabasePath('UnknownSopClassUid.cfg'), 'Default' ]
+            else:
+                tmp = [ '-xs' ]
+
             with open(os.devnull, 'w') as FNULL:
-                subprocess.check_call([ FindExecutable('storescu'), '-xs',
-                                        _REMOTE['Server'], str(_REMOTE['DicomPort']),
-                                        GetDatabasePath('Knix/Loc/IM-0001-0001.dcm') ],
+                subprocess.check_call([ FindExecutable('storescu') ] + tmp +
+                                      [ _REMOTE['Server'], str(_REMOTE['DicomPort']),
+                                        GetDatabasePath(image) ],
                                       stderr = FNULL)
 
         self.assertEqual(0, len(DoGet(_REMOTE, '/patients')))
         InstallLuaScript('Lua/TransferSyntaxDisable.lua')
-        self.assertRaises(Exception, storescu)
+        self.assertRaises(Exception, lambda: storescu('Knix/Loc/IM-0001-0001.dcm', False))
+        self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True))
         self.assertEqual(0, len(DoGet(_REMOTE, '/patients')))
         InstallLuaScript('Lua/TransferSyntaxEnable.lua')
-        DoPost(_REMOTE, '/tools/execute-script', "print('All special transfer syntaxes are now accepted')")
-        storescu()
-        self.assertEqual(1, len(DoGet(_REMOTE, '/patients')))
+        storescu('Knix/Loc/IM-0001-0001.dcm', False)
+        storescu('UnknownSopClassUid.dcm', True)
+        self.assertEqual(2, len(DoGet(_REMOTE, '/patients')))
 
 
     def test_storescu_jpeg(self):