Mercurial > hg > orthanc-tests
changeset 337:ec13ace43bde
trying webdav tests
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 10 Oct 2020 11:44:17 +0200 |
parents | c8c76810c5bd |
children | edaeb57bf01f |
files | GenerateConfigurationForTests.py Tests/Tests.py Tests/Toolbox.py |
diffstat | 3 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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'] = {
--- 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')
--- 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) +