Skip to content

Commit

Permalink
Merge 0aa879d into 128b7d6
Browse files Browse the repository at this point in the history
  • Loading branch information
glenrobson committed Mar 10, 2020
2 parents 128b7d6 + 0aa879d commit 44db4ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions iiif-presentation-validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def fetch(self, url):
try:
wh = urlopen(req)
except HTTPError as wh:
pass
raise wh
data = wh.read()
wh.close()

Expand All @@ -53,7 +53,7 @@ def fetch(self, url):
try:
data = data.decode('utf-8')
except:
pass
raise
return(data, wh)

def check_manifest(self, data, version, url=None, warnings=[]):
Expand Down Expand Up @@ -113,8 +113,8 @@ def do_GET_test(self):

try:
(data, webhandle) = self.fetch(url)
except:
return self.return_json({'okay': 0, 'error': 'Cannot fetch url', 'url': url})
except Exception as error:
return self.return_json({'okay': 0, 'error': 'Cannot fetch url. Got "{}"'.format(error), 'url': url})

# First check HTTP level
ct = webhandle.headers.get('content-type', '')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test05_do_GET_test(self):
v.fetch.side_effect = Exception('Fetch failed')
j = json.loads(v.do_GET_test())
self.assertEqual(j['okay'], 0)
self.assertEqual(j['error'], 'Cannot fetch url')
self.assertTrue(j['error'].startswith('Cannot fetch url'))
# bogus URL
v = val_mod.Validator()
request = LocalRequest({'QUERY_STRING': 'url=not_http://a.b.c/'})
Expand Down

0 comments on commit 44db4ca

Please sign in to comment.