Mercurial > hg > orthanc-tests
comparison Tests/Tests.py @ 174:d468cbe1b161
added tests for IncomingWorklistRequestFilter
author | am@osimis.io |
---|---|
date | Thu, 20 Sep 2018 11:51:34 +0200 |
parents | ed3db6386587 |
children | 09ca519087a1 |
comparison
equal
deleted
inserted
replaced
173:ed3db6386587 | 174:d468cbe1b161 |
---|---|
52 result.append('') | 52 result.append('') |
53 else: | 53 else: |
54 result.append(match.group(1)) | 54 result.append(match.group(1)) |
55 | 55 |
56 return result | 56 return result |
57 | |
58 | |
59 def InstallLuaScript(path): | |
60 with open(GetDatabasePath(path), 'r') as f: | |
61 DoPost(_REMOTE, '/tools/execute-script', f.read(), 'application/lua') | |
62 | |
63 | |
64 def UninstallLuaCallbacks(): | |
65 DoPost(_REMOTE, '/tools/execute-script', 'function OnStoredInstance() end', 'application/lua') | |
66 InstallLuaScript('Lua/TransferSyntaxEnable.lua') | |
67 | 57 |
68 | 58 |
69 def CompareLists(a, b): | 59 def CompareLists(a, b): |
70 if len(a) != len(b): | 60 if len(a) != len(b): |
71 return False | 61 return False |
145 import warnings | 135 import warnings |
146 warnings.simplefilter("ignore", ResourceWarning) | 136 warnings.simplefilter("ignore", ResourceWarning) |
147 | 137 |
148 DropOrthanc(_LOCAL) | 138 DropOrthanc(_LOCAL) |
149 DropOrthanc(_REMOTE) | 139 DropOrthanc(_REMOTE) |
150 UninstallLuaCallbacks() | 140 UninstallLuaCallbacks(_REMOTE) |
151 #print "In test", self._testMethodName | 141 #print "In test", self._testMethodName |
152 | 142 |
153 def AssertSameImages(self, truth, url): | 143 def AssertSameImages(self, truth, url): |
154 im = GetImage(_REMOTE, url) | 144 im = GetImage(_REMOTE, url) |
155 self.assertTrue(CompareLists(truth, im.getdata())) | 145 self.assertTrue(CompareLists(truth, im.getdata())) |
1911 UploadInstance(_REMOTE, knee1) | 1901 UploadInstance(_REMOTE, knee1) |
1912 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | 1902 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
1913 | 1903 |
1914 DropOrthanc(_REMOTE) | 1904 DropOrthanc(_REMOTE) |
1915 DropOrthanc(_LOCAL) | 1905 DropOrthanc(_LOCAL) |
1916 InstallLuaScript('Lua/Autorouting.lua') | 1906 InstallLuaScriptFromPath(_REMOTE, 'Lua/Autorouting.lua') |
1917 UploadInstance(_REMOTE, knee1) | 1907 UploadInstance(_REMOTE, knee1) |
1918 UploadInstance(_REMOTE, knee2) | 1908 UploadInstance(_REMOTE, knee2) |
1919 UploadInstance(_REMOTE, other) | 1909 UploadInstance(_REMOTE, other) |
1920 WaitEmpty(_REMOTE) | 1910 WaitEmpty(_REMOTE) |
1921 UninstallLuaCallbacks() | 1911 UninstallLuaCallbacks(_REMOTE) |
1922 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) | 1912 self.assertEqual(3, len(DoGet(_LOCAL, '/instances'))) |
1923 | 1913 |
1924 DropOrthanc(_REMOTE) | 1914 DropOrthanc(_REMOTE) |
1925 DropOrthanc(_LOCAL) | 1915 DropOrthanc(_LOCAL) |
1926 InstallLuaScript('Lua/AutoroutingConditional.lua') | 1916 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingConditional.lua') |
1927 UploadInstance(_REMOTE, knee1) | 1917 UploadInstance(_REMOTE, knee1) |
1928 UploadInstance(_REMOTE, knee2) | 1918 UploadInstance(_REMOTE, knee2) |
1929 UploadInstance(_REMOTE, other) | 1919 UploadInstance(_REMOTE, other) |
1930 WaitEmpty(_REMOTE) | 1920 WaitEmpty(_REMOTE) |
1931 UninstallLuaCallbacks() | 1921 UninstallLuaCallbacks(_REMOTE) |
1932 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) | 1922 self.assertEqual(2, len(DoGet(_LOCAL, '/instances'))) |
1933 | 1923 |
1934 DropOrthanc(_REMOTE) | 1924 DropOrthanc(_REMOTE) |
1935 DropOrthanc(_LOCAL) | 1925 DropOrthanc(_LOCAL) |
1936 InstallLuaScript('Lua/AutoroutingModification.lua') | 1926 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingModification.lua') |
1937 UploadInstance(_REMOTE, knee1) | 1927 UploadInstance(_REMOTE, knee1) |
1938 WaitEmpty(_REMOTE) | 1928 WaitEmpty(_REMOTE) |
1939 UninstallLuaCallbacks() | 1929 UninstallLuaCallbacks(_REMOTE) |
1940 i = DoGet(_LOCAL, '/instances') | 1930 i = DoGet(_LOCAL, '/instances') |
1941 self.assertEqual(1, len(i)) | 1931 self.assertEqual(1, len(i)) |
1942 | 1932 |
1943 with tempfile.NamedTemporaryFile(delete = True) as f: | 1933 with tempfile.NamedTemporaryFile(delete = True) as f: |
1944 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) | 1934 f.write(DoGet(_LOCAL, '/instances/%s/file' % i[0])) |
2046 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), | 2036 [ _REMOTE['Server'], str(_REMOTE['DicomPort']), |
2047 GetDatabasePath(image) ], | 2037 GetDatabasePath(image) ], |
2048 stderr = FNULL) | 2038 stderr = FNULL) |
2049 | 2039 |
2050 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | 2040 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
2051 InstallLuaScript('Lua/TransferSyntaxDisable.lua') | 2041 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxDisable.lua') |
2052 self.assertRaises(Exception, lambda: storescu('Knix/Loc/IM-0001-0001.dcm', False)) | 2042 self.assertRaises(Exception, lambda: storescu('Knix/Loc/IM-0001-0001.dcm', False)) |
2053 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) | 2043 self.assertRaises(Exception, lambda: storescu('UnknownSopClassUid.dcm', True)) |
2054 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) | 2044 self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) |
2055 InstallLuaScript('Lua/TransferSyntaxEnable.lua') | 2045 InstallLuaScriptFromPath(_REMOTE, 'Lua/TransferSyntaxEnable.lua') |
2056 DoPost(_REMOTE, '/tools/execute-script', "print('All special transfer syntaxes are now accepted')") | 2046 DoPost(_REMOTE, '/tools/execute-script', "print('All special transfer syntaxes are now accepted')") |
2057 storescu('Knix/Loc/IM-0001-0001.dcm', False) | 2047 storescu('Knix/Loc/IM-0001-0001.dcm', False) |
2058 storescu('UnknownSopClassUid.dcm', True) | 2048 storescu('UnknownSopClassUid.dcm', True) |
2059 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) | 2049 self.assertEqual(2, len(DoGet(_REMOTE, '/patients'))) |
2060 | 2050 |
2262 self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % c['ID'])) | 2252 self.assertEqual('ORTHANC', DoGet(_LOCAL, '/instances/%s/metadata/RemoteAET' % c['ID'])) |
2263 | 2253 |
2264 DropOrthanc(_REMOTE) | 2254 DropOrthanc(_REMOTE) |
2265 DropOrthanc(_LOCAL) | 2255 DropOrthanc(_LOCAL) |
2266 | 2256 |
2267 InstallLuaScript('Lua/AutoroutingChangeAet.lua') | 2257 InstallLuaScriptFromPath(_REMOTE, 'Lua/AutoroutingChangeAet.lua') |
2268 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') | 2258 DoPost(_REMOTE, '/tools/execute-script', 'aet = "HELLO"', 'application/lua') |
2269 | 2259 |
2270 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) | 2260 self.assertEqual(0, len(DoGet(_LOCAL, '/instances'))) |
2271 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') | 2261 UploadInstance(_REMOTE, 'Knee/T1/IM-0001-0001.dcm') |
2272 WaitEmpty(_REMOTE) | 2262 WaitEmpty(_REMOTE) |
3824 # is with the lua script I'm using for conversion of images to | 3814 # is with the lua script I'm using for conversion of images to |
3825 # JPEG2000. When the script is used with 1.4.0 the first | 3815 # JPEG2000. When the script is used with 1.4.0 the first |
3826 # instance appears to be stored and then everything just | 3816 # instance appears to be stored and then everything just |
3827 # halts, ie Orthanc wont respond to anything after that." | 3817 # halts, ie Orthanc wont respond to anything after that." |
3828 # https://groups.google.com/d/msg/orthanc-users/Rc-Beb42xc8/JUgdzrmCAgAJ | 3818 # https://groups.google.com/d/msg/orthanc-users/Rc-Beb42xc8/JUgdzrmCAgAJ |
3829 InstallLuaScript('Lua/Jpeg2000Conversion.lua') | 3819 InstallLuaScriptFromPath(_REMOTE, 'Lua/Jpeg2000Conversion.lua') |
3830 | 3820 |
3831 subprocess.check_call([ FindExecutable('storescu'), | 3821 subprocess.check_call([ FindExecutable('storescu'), |
3832 _REMOTE['Server'], str(_REMOTE['DicomPort']), | 3822 _REMOTE['Server'], str(_REMOTE['DicomPort']), |
3833 GetDatabasePath('Brainix/Flair/IM-0001-0001.dcm'), | 3823 GetDatabasePath('Brainix/Flair/IM-0001-0001.dcm'), |
3834 GetDatabasePath('Brainix/Flair/IM-0001-0002.dcm'), | 3824 GetDatabasePath('Brainix/Flair/IM-0001-0002.dcm'), |