Mercurial > hg > orthanc-tests
changeset 28:156c7ae164b5
new test
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 01 Jul 2015 12:10:30 +0200 |
parents | cde1691838d3 |
children | cbd6703ba4e7 |
files | Tests/Tests.py Tests/Toolbox.py |
diffstat | 2 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Tests/Tests.py Mon Jun 29 14:44:00 2015 +0200 +++ b/Tests/Tests.py Wed Jul 01 12:10:30 2015 +0200 @@ -1283,6 +1283,10 @@ self.assertTrue('store' in DoGet(_REMOTE, '/peers/peer')) self.assertTrue('matlab' in DoGet(_REMOTE, '/instances/%s/frames/0' % a)) self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/tools/nope')) + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope')) + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '/nope/nope.html')) + self.assertEqual(404, DoGetRaw(_REMOTE, '/nope')[0].status) + self.assertEqual(404, DoGetRaw(_REMOTE, '/nope/nope.html')[0].status) def test_echo(self):
--- a/Tests/Toolbox.py Mon Jun 29 14:44:00 2015 +0200 +++ b/Tests/Toolbox.py Wed Jul 01 12:10:30 2015 +0200 @@ -70,8 +70,7 @@ orthanc['Password'] != None): http.add_credentials(orthanc['Username'], orthanc['Password']) - -def DoGet(orthanc, uri, data = {}, body = None, headers = {}): +def DoGetRaw(orthanc, uri, data = {}, body = None, headers = {}): d = '' if len(data.keys()) > 0: d = '?' + urlencode(data) @@ -82,6 +81,12 @@ resp, content = http.request(orthanc['Url'] + uri + d, 'GET', body = body, headers = headers) + return (resp, content) + + +def DoGet(orthanc, uri, data = {}, body = None, headers = {}): + (resp, content) = DoGetRaw(orthanc, uri, data = data, body = body, headers = headers) + if not (resp.status in [ 200 ]): raise Exception(resp.status) else: