Skip to content

Commit

Permalink
BUG: Fix check for latest on CompoundService
Browse files Browse the repository at this point in the history
Fixes issue #170
  • Loading branch information
lesserwhirls committed Mar 30, 2018
1 parent 0d72c80 commit 2f7c545
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
4 changes: 4 additions & 0 deletions siphon/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
58 changes: 58 additions & 0 deletions siphon/tests/fixtures/latest_resolver_on_latest_dataset
Original file line number Diff line number Diff line change
@@ -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/vHcheKzhrOzHbfu
IH2ApmZqxX2Ww33iyiQ0HGcvtQP58GQd42hXRrFMRODAjGp8ziD2QGTMREDjyuS70fWw1xlt5hYa
BDLQXeIAOQz25FdZPHbHeyBodQQi2oMYHICIjkAIX1cxhsz4wXyczDQze2DW/nk0P4gUi6RhVX2D
6D5/X8ErZhyjGIVVit3BxwPUov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9OktCzE0tp9e/cdq9uy4Z3nU6Vra0pDfTe2l5om8ztm9s+a+4qOwevA9HGMpH
LOzwNOQUex/h6uxMlTQgVc4nbaLTG2KWTXePKfbOZ1RwP3V4x0RSx7bk+9AJIsxPGPeZwGd2x+ek
mPaI66Ah5HUfxx/H59tVAQrLLrNnCeZSwbVYcSVFKn4II+zruJ+jo4znP5COeGZiLJbrvKW8wxTE
Be4Iz7FU0wUTTGVP2e4cWNEwsdE7huckqu1KgrXyFE12eJ7MCu8Z/i4x7xiQbaGmxqbUaf4FRzGv
Uasfm2m7sqmcl9fOU16BsGmzjsFsbOw25nnWOYA55QHuis85U9OAzblgwXS2xklbHfxU2r3FYa5k
lLZoZ4dbi6NC25un5YW9ZYGctZ3HZnWlWFm6UmzF6N5c1N03x2Yt8cxhH1bMSOtFYitIWjL6d+NR
Wje2ZQNWl0fJYxhiU2Y9VSbf252TzEKuMVq/nf4eup178jDs9zqTzukndq8WFIdWJ3Eslfm9arF7
QvcJnsg5zXZYVNLARlG6UuFyWVKz56+c8+6ZZlT5SzizmzwnD5sryn+4ywVDekiXhl3stRWWwZ3t
IuZSS7xBtcvJt6kNVaZ98c5zPbyRpQ+74/wra+OVMh22n3dGt3eK9oW9VDRJ6c2OJW7H6HZ259DT
lE2TZC9LLMlBmk2Gx+8Jb9+HqB8lfvnm28RfwtsSOUT7AME0wNqLNIdU4qJJjviqaa/fhzyY7fFw
p1Ldf5OJ4BlTO7IlcnCx5ooqbpP8gMY7LVvxFcvm3k++47cV7zegrdLylZ5vM1KqEc2CTP6FT/4d
j/2HAcn/Y4Cf/wYAAP//AwAyhIXgZRgAAA==
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
14 changes: 14 additions & 0 deletions siphon/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 2f7c545

Please sign in to comment.