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

Bug Fix: Populate Dataset access_urls #736

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Steve Nesbitt
Warren Pettee
Zachary Bruick
Scott Havens
James Polly
4 changes: 1 addition & 3 deletions src/siphon/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,13 @@ def make_access_urls(self, catalog_url, all_services, metadata=None):
for subservice in service.services:
all_service_dict[subservice.name] = subservice

service_name = metadata.get('serviceName', None)

access_urls = CaseInsensitiveDict({})
server_url = _find_base_tds_url(catalog_url)

# process access urls for datasets that reference top
# level catalog services (individual or compound service
# types).
if service_name in all_service_dict:
for service_name in all_service_dict:
service = all_service_dict[service_name]
if service.service_type != 'Resolver':
# if service is a CompoundService, create access url
Expand Down
27 changes: 24 additions & 3 deletions tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,30 @@ def test_simple_service_within_compound():
'tropical/atlantic/hdob/catalog.xml')
cat = TDSCatalog(url)
assert (cat.datasets[0].access_urls
== {'HTTPServer': 'http://thredds-test.unidata.ucar.edu/thredds/'
'fileServer/noaaport/text/tropical/atlantic/hdob/'
'High_density_obs_20170824.txt'})
== {'CdmRemote': 'http://thredds-test.unidata.ucar.edu/thredds/'
'cdmremote/noaaport/text/tropical/atlantic/'
'hdob/High_density_obs_20170824.txt',
'CdmrFeature': 'http://thredds-test.unidata.ucar.edu/thredds/'
'cdmrfeature/grid/noaaport/text/tropical/atlantic/'
'hdob/High_density_obs_20170824.txt',
'HTTPServer': 'http://thredds-test.unidata.ucar.edu/thredds/'
'fileServer/noaaport/text/tropical/atlantic/'
'hdob/High_density_obs_20170824.txt',
'ISO': 'http://thredds-test.unidata.ucar.edu/thredds/iso/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt',
'NCML': 'http://thredds-test.unidata.ucar.edu/thredds/ncml/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt',
'NetcdfSubset': 'http://thredds-test.unidata.ucar.edu/thredds/ncss/'
'noaaport/text/tropical/atlantic/hdob/'
'High_density_obs_20170824.txt',
'OPENDAP': 'http://thredds-test.unidata.ucar.edu/thredds/dodsC/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt',
'UDDC': 'http://thredds-test.unidata.ucar.edu/thredds/uddc/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt',
'WCS': 'http://thredds-test.unidata.ucar.edu/thredds/wcs/noaaport/text/'
'tropical/atlantic/hdob/High_density_obs_20170824.txt',
'WMS': 'http://thredds-test.unidata.ucar.edu/thredds/wms/noaaport/text/'
'tropical/atlantic/hdob/High_density_obs_20170824.txt'})


@recorder.use_cassette('rsmas_ramadda')
Expand Down
32 changes: 29 additions & 3 deletions tests/test_catalog_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def test_case_insensitive_access(caplog):
'tropical/atlantic/hdob/catalog.xml')
cat = TDSCatalog(url)
access_name = list(cat.datasets[0].access_urls.keys())[0]
assert access_name == 'HTTPSERVER' # test __eq__
assert not access_name != 'HTTPSERVER' # test __eq__
assert access_name == 'OPENDAP' # test __eq__
assert not access_name != 'OPENDAP' # test __eq__
assert access_name > 'a' # test __gt__
assert access_name >= 'a' # test __ge__
assert access_name < 'Z' # test __lt__
Expand All @@ -194,7 +194,33 @@ def test_manage_access_types_case_insensitive(caplog):
test_string = 'test'
http_url = ('http://thredds-test.unidata.ucar.edu/thredds/fileServer/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt')
assert ds.access_urls == {'HTTPSERVER': http_url} # test __eq__
test_access_urls = {
'CdmRemote': ('http://thredds-test.unidata.ucar.edu/thredds/'
'cdmremote/noaaport/text/tropical/atlantic/'
'hdob/High_density_obs_20170824.txt'),
'CdmrFeature': ('http://thredds-test.unidata.ucar.edu/thredds/'
'cdmrfeature/grid/noaaport/text/tropical/atlantic/'
'hdob/High_density_obs_20170824.txt'),
'HTTPServer': ('http://thredds-test.unidata.ucar.edu/thredds/'
'fileServer/noaaport/text/tropical/atlantic/'
'hdob/High_density_obs_20170824.txt'),
'ISO': ('http://thredds-test.unidata.ucar.edu/thredds/iso/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt'),
'NCML': ('http://thredds-test.unidata.ucar.edu/thredds/ncml/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt'),
'NetcdfSubset': ('http://thredds-test.unidata.ucar.edu/thredds/ncss/'
'noaaport/text/tropical/atlantic/hdob/'
'High_density_obs_20170824.txt'),
'OPENDAP': ('http://thredds-test.unidata.ucar.edu/thredds/dodsC/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt'),
'UDDC': ('http://thredds-test.unidata.ucar.edu/thredds/uddc/noaaport/'
'text/tropical/atlantic/hdob/High_density_obs_20170824.txt'),
'WCS': ('http://thredds-test.unidata.ucar.edu/thredds/wcs/noaaport/text/'
'tropical/atlantic/hdob/High_density_obs_20170824.txt'),
'WMS': ('http://thredds-test.unidata.ucar.edu/thredds/wms/noaaport/text/'
'tropical/atlantic/hdob/High_density_obs_20170824.txt')
}
assert ds.access_urls == test_access_urls # test __eq__
assert ds.access_urls[wrong_case_key] == http_url # test __getitem___
assert wrong_case_key in ds.access_urls # test __contains__
ds.access_urls[wrong_case_key] = test_string
Expand Down
Loading