# HG changeset patch # User Sebastien Jodogne # Date 1602323057 -7200 # Node ID ec13ace43bde3e31d1c3322b4002635bc325f9fb # Parent c8c76810c5bda8ca0d656b5f4f737a3f83cab983 trying webdav tests diff -r c8c76810c5bd -r ec13ace43bde GenerateConfigurationForTests.py --- a/GenerateConfigurationForTests.py Fri Sep 18 14:19:53 2020 +0200 +++ b/GenerateConfigurationForTests.py Sat Oct 10 11:44:17 2020 +0200 @@ -141,6 +141,10 @@ config['ExecuteLuaEnabled'] = True config['HttpTimeout'] = 2 config['SyncStorageArea'] = False # For tests to run more quickly +config['WebDavEnabled'] = True +config['WebDavDeleteAllowed'] = True +config['WebDavUploadAllowed'] = True + del config['KeepAlive'] config['Dictionary'] = { diff -r c8c76810c5bd -r ec13ace43bde Tests/Tests.py --- a/Tests/Tests.py Fri Sep 18 14:19:53 2020 +0200 +++ b/Tests/Tests.py Sat Oct 10 11:44:17 2020 +0200 @@ -6012,3 +6012,18 @@ i = CallFindScu([ '-k', '0008,0052=STUDY', '-k', '0020,000d=', '-k', '0008,0061=%s' % i ]) studyInstanceUid = re.findall('\(0020,000d\).*?\[(.*?)\]', i) self.assertEqual(expected, len(studyInstanceUid)) + + + def test_webdav(self): + self.assertRaises(Exception, lambda: DoPropFind(_REMOTE, '/webdav/', 2)) + + xml = DoPropFind(_REMOTE, '/webdav/', 1) + #print(xml.toprettyxml()) + for i in xml.getElementsByTagName('D:response'): + print(i.getElementsByTagName('D:href')[0].childNodes[0].data) + # print(i.getElementsByTagName('D:prop')[0].toprettyxml()) + + + + self.assertEqual(0, len(DoGet(_REMOTE, '/patients'))) + UploadInstance(_REMOTE, 'Comunix/Ct/IM-0001-0001.dcm') diff -r c8c76810c5bd -r ec13ace43bde Tests/Toolbox.py --- a/Tests/Toolbox.py Fri Sep 18 14:19:53 2020 +0200 +++ b/Tests/Toolbox.py Sat Oct 10 11:44:17 2020 +0200 @@ -32,6 +32,8 @@ import time import zipfile +from xml.dom import minidom + from PIL import Image, ImageChops import math import operator @@ -428,3 +430,17 @@ _GetMaxImageDifference(blue1, blue2) ]) else: return _GetMaxImageDifference(im1, im2) + + +def DoPropFind(orthanc, uri, depth): + http = httplib2.Http() + http.follow_redirects = False + _SetupCredentials(orthanc, http) + + resp, content = http.request(orthanc['Url'] + uri, 'PROPFIND', headers = { 'Depth' : str(depth) }) + + if not (resp.status in [ 207 ]): + raise Exception(resp.status, resp) + else: + return minidom.parseString(content) +