Mercurial > hg > orthanc-tests
comparison Tests/Toolbox.py @ 239:8980bd19e31d
dicomweb: test_allowed_methods
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jun 2019 21:38:06 +0200 |
parents | 0f03ee6ffa80 |
children | 24e5c8ca9440 |
comparison
equal
deleted
inserted
replaced
238:50c694cd5bbf | 239:8980bd19e31d |
---|---|
109 | 109 |
110 def DoGet(orthanc, uri, data = {}, body = None, headers = {}): | 110 def DoGet(orthanc, uri, data = {}, body = None, headers = {}): |
111 (resp, content) = DoGetRaw(orthanc, uri, data = data, body = body, headers = headers) | 111 (resp, content) = DoGetRaw(orthanc, uri, data = data, body = body, headers = headers) |
112 | 112 |
113 if not (resp.status in [ 200 ]): | 113 if not (resp.status in [ 200 ]): |
114 raise Exception(resp.status) | 114 raise Exception(resp.status, resp) |
115 else: | 115 else: |
116 return _DecodeJson(content) | 116 return _DecodeJson(content) |
117 | 117 |
118 def _DoPutOrPost(orthanc, uri, method, data, contentType, headers): | 118 def _DoPutOrPost(orthanc, uri, method, data, contentType, headers): |
119 http = httplib2.Http() | 119 http = httplib2.Http() |
132 | 132 |
133 resp, content = http.request(orthanc['Url'] + uri, method, | 133 resp, content = http.request(orthanc['Url'] + uri, method, |
134 body = body, | 134 body = body, |
135 headers = headers) | 135 headers = headers) |
136 if not (resp.status in [ 200, 302 ]): | 136 if not (resp.status in [ 200, 302 ]): |
137 raise Exception(resp.status) | 137 raise Exception(resp.status, resp) |
138 else: | 138 else: |
139 return _DecodeJson(content) | 139 return _DecodeJson(content) |
140 | 140 |
141 def DoDelete(orthanc, uri): | 141 def DoDelete(orthanc, uri): |
142 http = httplib2.Http() | 142 http = httplib2.Http() |
143 http.follow_redirects = False | 143 http.follow_redirects = False |
144 _SetupCredentials(orthanc, http) | 144 _SetupCredentials(orthanc, http) |
145 | 145 |
146 resp, content = http.request(orthanc['Url'] + uri, 'DELETE') | 146 resp, content = http.request(orthanc['Url'] + uri, 'DELETE') |
147 if not (resp.status in [ 200 ]): | 147 if not (resp.status in [ 200 ]): |
148 raise Exception(resp.status) | 148 raise Exception(resp.status, resp) |
149 else: | 149 else: |
150 return _DecodeJson(content) | 150 return _DecodeJson(content) |
151 | 151 |
152 def DoPut(orthanc, uri, data = {}, contentType = ''): | 152 def DoPut(orthanc, uri, data = {}, contentType = ''): |
153 return _DoPutOrPost(orthanc, uri, 'PUT', data, contentType, {}) | 153 return _DoPutOrPost(orthanc, uri, 'PUT', data, contentType, {}) |