diff Tests/Toolbox.py @ 391:227d9a932467

testing revisions in metadata
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Apr 2021 17:13:53 +0200
parents 79ce0f7a9714
children 9528e2a03d3c
line wrap: on
line diff
--- a/Tests/Toolbox.py	Mon Mar 08 16:59:25 2021 +0100
+++ b/Tests/Toolbox.py	Fri Apr 16 17:13:53 2021 +0200
@@ -141,28 +141,43 @@
     resp, content = http.request(orthanc['Url'] + uri, method,
                                  body = body,
                                  headers = headers)
+    return (resp, content)
+
+def DoDeleteRaw(orthanc, uri, headers = {}):
+    http = httplib2.Http()
+    http.follow_redirects = False
+    _SetupCredentials(orthanc, http)
+
+    resp, content = http.request(orthanc['Url'] + uri, 'DELETE', headers = headers)
+    return (resp, content)
+
+def DoDelete(orthanc, uri, headers = {}):
+    (resp, content) = DoDeleteRaw(orthanc, uri, headers)
+    if not (resp.status in [ 200 ]):
+        raise Exception(resp.status, resp)
+    else:
+        return _DecodeJson(content)
+
+def DoPutRaw(orthanc, uri, data = {}, contentType = '', headers = {}):
+    return _DoPutOrPost(orthanc, uri, 'PUT', data, contentType, headers)
+
+def DoPut(orthanc, uri, data = {}, contentType = '', headers = {}):
+    (resp, content) = DoPutRaw(orthanc, uri, data, contentType, headers)
     if not (resp.status in [ 200, 201, 302 ]):
         raise Exception(resp.status, resp)
     else:
         return _DecodeJson(content)
 
-def DoDelete(orthanc, uri):
-    http = httplib2.Http()
-    http.follow_redirects = False
-    _SetupCredentials(orthanc, http)
-
-    resp, content = http.request(orthanc['Url'] + uri, 'DELETE')
-    if not (resp.status in [ 200 ]):
+def DoPostRaw(orthanc, uri, data = {}, contentType = '', headers = {}):
+    return _DoPutOrPost(orthanc, uri, 'POST', data, contentType, headers)
+    
+def DoPost(orthanc, uri, data = {}, contentType = '', headers = {}):
+    (resp, content) = DoPostRaw(orthanc, uri, data, contentType, headers)
+    if not (resp.status in [ 200, 201, 302 ]):
         raise Exception(resp.status, resp)
     else:
         return _DecodeJson(content)
 
-def DoPut(orthanc, uri, data = {}, contentType = ''):
-    return _DoPutOrPost(orthanc, uri, 'PUT', data, contentType, {})
-
-def DoPost(orthanc, uri, data = {}, contentType = '', headers = {}):
-    return _DoPutOrPost(orthanc, uri, 'POST', data, contentType, headers)
-
 def GetDatabasePath(filename):
     return os.path.join(os.path.dirname(__file__), '..', 'Database', filename)