changeset 26:040f6ef1394a

test_storescu_custom_aet
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 Jun 2015 13:26:56 +0200
parents d99a759910db
children cde1691838d3
files Database/Lua/AutoroutingChangeAet.lua Tests/Tests.py
diffstat 2 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Database/Lua/AutoroutingChangeAet.lua	Mon Jun 29 13:26:56 2015 +0200
@@ -0,0 +1,3 @@
+function OnStoredInstance(instanceId, tags, metadata)
+   Delete(SendToModality(instanceId, 'orthanctest', aet))
+end
--- a/Tests/Tests.py	Fri Jun 26 14:31:26 2015 +0200
+++ b/Tests/Tests.py	Mon Jun 29 13:26:56 2015 +0200
@@ -82,6 +82,7 @@
     def setUp(self):
         DropOrthanc(_LOCAL)
         DropOrthanc(_REMOTE)
+        UninstallLuaCallbacks()
         #print "In test", self._testMethodName
 
     def AssertSameImages(self, truth, url):
@@ -1992,3 +1993,51 @@
         self.assertEqual('ImiÄ™ i Nazwisko osoby opisujÄ…cej', 
                          i['ContentSequence'][4]['ConceptNameCodeSequence'][0]['CodeMeaning'].encode('utf-8'))
         
+
+    def test_storescu_custom_aet(self):
+        # This tests a feature introduced in Orthanc 0.9.1: "Custom
+        # setting of the local AET during C-Store SCU (both in Lua and
+        # in the REST API)."
+        # https://groups.google.com/forum/#!msg/orthanc-users/o5qMULformU/wZjW2iSaMcAJ
+
+        self.assertEqual(0, len(DoGet(_LOCAL, '/patients')))
+        
+        a = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')
+        b = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')
+        c = UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0003.dcm')
+
+        j = DoPost(_REMOTE, '/modalities/orthanctest/store', {
+            'LocalAet' : 'YOP',
+            'Resources' : [ a['ID'], b['ID'] ]
+        })
+
+        self.assertEqual(2, len(DoGet(_LOCAL, '/instances')))
+        self.assertEqual('YOP', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % a['ID']))
+
+        DropOrthanc(_LOCAL)
+        self.assertEqual(0, len(DoGet(_LOCAL, '/instances')))
+
+        j = DoPost(_REMOTE, '/modalities/orthanctest/store', {
+            'Resources' : [ c['ID'] ]
+        })
+
+        self.assertEqual(1, len(DoGet(_LOCAL, '/instances')))
+        self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % c['ID']))
+
+        DropOrthanc(_REMOTE)        
+        DropOrthanc(_LOCAL)        
+
+        InstallLuaScript('Lua/AutoroutingChangeAet.lua')
+        DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua')
+
+        self.assertEqual(0, len(DoGet(_LOCAL, '/instances')))
+        UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm')
+        WaitEmpty(_REMOTE)
+        self.assertEqual(1, len(DoGet(_LOCAL, '/instances')))
+        self.assertEqual('HELLO', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % a['ID']))
+
+        DoPost(_REMOTE, '/tools/execute-script', 'aet = nill', 'application/lua')
+        UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0002.dcm')
+        WaitEmpty(_REMOTE)
+        self.assertEqual(2, len(DoGet(_LOCAL, '/instances')))
+        self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % b['ID']))