Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http errors #65

Merged
merged 1 commit into from
Oct 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions siphon/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, catalog_url):

# get catalog.xml file
resp = session.get(self.catalog_url)
resp.raise_for_status()

# If we were given an HTML link, warn about it and try to fix to xml
if 'html' in resp.headers['content-type']:
Expand All @@ -61,6 +62,7 @@ def __init__(self, catalog_url):
new_url))
self.catalog_url = new_url
resp = session.get(self.catalog_url)
resp.raise_for_status()

# begin parsing the xml doc
root = ET.fromstring(resp.text)
Expand Down
17 changes: 17 additions & 0 deletions siphon/tests/fixtures/radarserver_ds_denied
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [Siphon (0.3.1+20.gdd8f139.dirty)]
method: GET
uri: http://thredds-aws.unidata.ucar.edu/thredds/radarServer/nexrad/level2/S3/dataset.xml
response:
body: {string: ''}
headers:
Date: ['Thu, 29 Oct 2015 14:35:24 GMT']
Server: [Apache-Coyote/1.1]
status: {code: 403, message: Forbidden}
version: 1
17 changes: 17 additions & 0 deletions siphon/tests/fixtures/radarserver_toplevel_denied
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
interactions:
- request:
body: null
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: [keep-alive]
User-Agent: [Siphon (0.3.1+20.gdd8f139.dirty)]
method: GET
uri: http://thredds-aws.unidata.ucar.edu/thredds/radarServer/catalog.xml
response:
body: {string: ''}
headers:
Date: ['Thu, 29 Oct 2015 14:35:24 GMT']
Server: [Apache-Coyote/1.1]
status: {code: 403, message: Forbidden}
version: 1
14 changes: 14 additions & 0 deletions siphon/tests/test_radarsever.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
get_radarserver_datasets)

from nose.tools import eq_, raises
from requests import HTTPError

recorder = siphon.testing.get_recorder(__file__)

Expand Down Expand Up @@ -120,3 +121,16 @@ def test_catalog_access(self):
ds = get_radarserver_datasets('http://thredds.ucar.edu/thredds/')
url = ds['NEXRAD Level III Radar from IDD'].follow().catalog_url
assert RadarServer(url)


class TestUnauthorizedErrors(object):
@recorder.use_cassette('radarserver_toplevel_denied')
@raises(HTTPError)
def test_get_rs_datasets_denied_throws(self):
get_radarserver_datasets('http://thredds-aws.unidata.ucar.edu/thredds/')

@raises(HTTPError)
@recorder.use_cassette('radarserver_ds_denied')
def test_rs_constructor_throws(self):
RadarServer('http://thredds-aws.unidata.ucar.edu/thredds/'
'radarServer/nexrad/level2/S3/')