Mercurial > hg > orthanc-tests
changeset 239:8980bd19e31d
dicomweb: test_allowed_methods
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jun 2019 21:38:06 +0200 |
parents | 50c694cd5bbf |
children | 0b1023060421 |
files | Plugins/DicomWeb/Run.py Tests/Toolbox.py |
diffstat | 2 files changed, 18 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugins/DicomWeb/Run.py Wed May 29 17:49:02 2019 +0200 +++ b/Plugins/DicomWeb/Run.py Tue Jun 11 21:38:06 2019 +0200 @@ -641,6 +641,21 @@ self.assertEqual('SQ', a['00081199']['vr']) self.assertEqual(1, len(['00081199'])) + + def test_allowed_methods(self): + self.assertEqual(0, len(DoGet(ORTHANC, '/dicom-web/studies'))) + + with self.assertRaises(Exception) as e: + DoPut(ORTHANC, '/dicom-web/studies') + + self.assertEqual(405, e.exception[0]) + self.assertEqual("GET,POST", e.exception[1]['allow']) + + with self.assertRaises(Exception) as e: + DoDelete(ORTHANC, '/dicom-web/studies') + + self.assertEqual(405, e.exception[0]) + self.assertEqual("GET,POST", e.exception[1]['allow']) try: print('\nStarting the tests...')
--- a/Tests/Toolbox.py Wed May 29 17:49:02 2019 +0200 +++ b/Tests/Toolbox.py Tue Jun 11 21:38:06 2019 +0200 @@ -111,7 +111,7 @@ (resp, content) = DoGetRaw(orthanc, uri, data = data, body = body, headers = headers) if not (resp.status in [ 200 ]): - raise Exception(resp.status) + raise Exception(resp.status, resp) else: return _DecodeJson(content) @@ -134,7 +134,7 @@ body = body, headers = headers) if not (resp.status in [ 200, 302 ]): - raise Exception(resp.status) + raise Exception(resp.status, resp) else: return _DecodeJson(content) @@ -145,7 +145,7 @@ resp, content = http.request(orthanc['Url'] + uri, 'DELETE') if not (resp.status in [ 200 ]): - raise Exception(resp.status) + raise Exception(resp.status, resp) else: return _DecodeJson(content)