From 2f7c545ad571977cc85ec05bc3a922b0bff91b05 Mon Sep 17 00:00:00 2001 From: Sean Arms Date: Fri, 30 Mar 2018 15:54:32 -0600 Subject: [PATCH] BUG: Fix check for latest on CompoundService Fixes issue Unidata/siphon#170 --- siphon/catalog.py | 4 ++ .../latest_resolver_on_latest_dataset | 58 +++++++++++++++++++ siphon/tests/test_catalog.py | 14 +++++ 3 files changed, 76 insertions(+) create mode 100644 siphon/tests/fixtures/latest_resolver_on_latest_dataset diff --git a/siphon/catalog.py b/siphon/catalog.py index 1873f3d81..d5b89c28a 100644 --- a/siphon/catalog.py +++ b/siphon/catalog.py @@ -668,6 +668,10 @@ def __init__(self, service_node): self.services = services self.number_of_subservices = subservices + def is_resolver(self): + """For a compound service, always False because it will never be a resolver.""" + return False + def _find_base_tds_url(catalog_url): """Identify the base URL of the THREDDS server from the catalog URL. diff --git a/siphon/tests/fixtures/latest_resolver_on_latest_dataset b/siphon/tests/fixtures/latest_resolver_on_latest_dataset new file mode 100644 index 000000000..b0d49de85 --- /dev/null +++ b/siphon/tests/fixtures/latest_resolver_on_latest_dataset @@ -0,0 +1,58 @@ +interactions: +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Connection: [keep-alive] + User-Agent: [Siphon (0.4.0+264.g0d72c80.dirty)] + method: GET + uri: http://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/Global_0p25deg_ana/latest.xml + response: + body: + string: !!binary | + H4sIAAAAAAAAA+xZUW/iOBB+P+n+wyj30ko0DnR3b7cH7HHQdpEWigrdSvuCTGLAd4kd2Q5d9tff + OAkhBMrSu5VuH05qVRKPP3/+Zjwzps33X6IQVkxpLkXLqbueA0z4MuBi0XIeJjcXb5337Z9/avrU + 0FAuAM2FbjlLY+IrQp6entxE8AAH3cSnymVBQgSNmI6pzzQxS8WCQJO+WHUzALJK10hhrr6EXPy1 + A/Z06Uq1IPV3796RdNQBC9dybm/G09tQzmg49eLG64AtplTQacOrv/UuL70p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ZRgAAA== + headers: + Access-Control-Allow-Origin: ['*'] + Connection: [Keep-Alive] + Content-Encoding: [gzip] + Content-Language: [en] + Content-Type: [application/xml;charset=UTF-8] + Date: ['Fri, 30 Mar 2018 21:51:29 GMT'] + Keep-Alive: ['timeout=5, max=100'] + Server: [Apache] + Vary: [Accept-Encoding] + X-Frame-Options: [SAMEORIGIN] + status: {code: 200, message: '200'} +version: 1 diff --git a/siphon/tests/test_catalog.py b/siphon/tests/test_catalog.py index f564514dd..4cf4891c9 100644 --- a/siphon/tests/test_catalog.py +++ b/siphon/tests/test_catalog.py @@ -311,3 +311,17 @@ def test_catalog_with_embedded_metadata_elements(): md = cat.metadata assert 'external_metadata' in md assert 'serviceName' in md + + +@recorder.use_cassette('latest_resolver_on_latest_dataset') +def test_latest_resolver_fail(): + """Test getting latest on catalog that does not have a resolver""" + cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/' + 'Global_0p25deg_ana/latest.xml') + + latest = '' + with pytest.raises(AttributeError) as excinfo: + latest = cat.latest + + assert latest == '' + assert '"latest" not available for this catalog' in str(excinfo.value)