Skip to content

Commit e35d8b4

Browse files
snbiancobsipocz
authored andcommitted
test fixes
1 parent 454f66d commit e35d8b4

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

astroquery/mast/cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def get_cloud_uri(self, data_product, include_bucket=True, full_url=False):
112112
uri_list = self.get_cloud_uri_list(data_product, include_bucket=include_bucket, full_url=full_url)
113113

114114
# Making sure we got at least 1 URI from the query above.
115-
if uri_list[0] is None:
115+
if not uri_list or uri_list[0] is None:
116116
warnings.warn("Unable to locate file {}.".format(data_product), NoResultsWarning)
117117
else:
118118
# Output from ``get_cloud_uri_list`` is always a list even when it's only 1 URI

astroquery/mast/tests/test_mast_remote.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,13 @@ def test_get_cloud_uri(self, test_data_uri, expected_cloud_uri):
526526
assert len(uri) > 0, f'Product for dataURI {test_data_uri} was not found in the cloud.'
527527
assert uri == expected_cloud_uri, f'Cloud URI does not match expected. ({uri} != {expected_cloud_uri})'
528528

529-
def test_get_cloud_uris(self):
529+
@pytest.mark.parametrize("test_obs_id", ["25568122", "31411"])
530+
def test_get_cloud_uris(self, test_obs_id):
530531
pytest.importorskip("boto3")
531-
test_obs_id = '25568122'
532532

533533
# get a product list
534-
products = Observations.get_product_list(test_obs_id)[24:]
534+
index = 24 if test_obs_id == '25568122' else 0
535+
products = Observations.get_product_list(test_obs_id)[index:]
535536

536537
assert len(products) > 0, (f'No products found for OBSID {test_obs_id}. '
537538
'Unable to move forward with getting URIs from the cloud.')
@@ -556,17 +557,13 @@ def test_get_cloud_uris_query(self):
556557
Observations.enable_cloud_dataset()
557558

558559
# get uris with other functions
559-
obs = Observations.query_criteria(target_name=234295610,
560-
provenance_name="SPOC",
561-
sequence_number=[1, 2])
560+
obs = Observations.query_criteria(target_name=234295610)
562561
prod = Observations.get_product_list(obs)
563562
filt = Observations.filter_products(prod, calib_level=[2])
564563
s3_uris = Observations.get_cloud_uris(filt)
565564

566565
# get uris with streamlined function
567566
uris = Observations.get_cloud_uris(target_name=234295610,
568-
provenance_name="SPOC",
569-
sequence_number=[1, 2],
570567
filter_products={'calib_level': [2]})
571568
assert s3_uris == uris
572569

docs/mast/mast_catalog.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The returned fields vary by catalog, find the field documentation for specific c
2424
`here <https://mast.stsci.edu/api/v0/pages.html>`__.
2525
If no catalog is specified, the Hubble Source Catalog will be queried.
2626

27-
.. doctest-remote-data::
27+
.. doctest-skip::
2828

2929
>>> from astroquery.mast import Catalogs
3030
...
@@ -261,19 +261,17 @@ Given an HSC Match ID, return all catalog results.
261261
>>> catalog_data = Catalogs.query_object("M10", radius=.02, catalog="HSC")
262262
>>> matchid = catalog_data[0]["MatchID"]
263263
>>> print(matchid)
264-
63980492
264+
7542452
265265
>>> matches = Catalogs.query_hsc_matchid(matchid)
266266
>>> print(matches)
267-
CatID MatchID ... cd_matrix
268-
--------- -------- ... ------------------------------------------------------
269-
257195287 63980492 ... -1.38889e-005 -5.26157e-010 -5.26157e-010 1.38889e-005
270-
257440119 63980492 ... -1.38889e-005 -5.26157e-010 -5.26157e-010 1.38889e-005
271-
428373428 63980492 ... -1.10056e-005 5.65193e-010 5.65193e-010 1.10056e-005
272-
428373427 63980492 ... -1.10056e-005 5.65193e-010 5.65193e-010 1.10056e-005
273-
428373429 63980492 ... -1.10056e-005 5.65193e-010 5.65193e-010 1.10056e-005
274-
410574499 63980492 ... -1.10056e-005 1.56577e-009 1.56577e-009 1.10056e-005
275-
410574498 63980492 ... -1.10056e-005 1.56577e-009 1.56577e-009 1.10056e-005
276-
410574497 63980492 ... -1.10056e-005 1.56577e-009 1.56577e-009 1.10056e-005
267+
CatID MatchID ... cd_matrix
268+
--------- ------- ... ------------------------------------------------------
269+
419094794 7542452 ... -1.10056e-005 5.65193e-010 5.65193e-010 1.10056e-005
270+
419094795 7542452 ... -1.10056e-005 5.65193e-010 5.65193e-010 1.10056e-005
271+
401289578 7542452 ... -1.10056e-005 1.56577e-009 1.56577e-009 1.10056e-005
272+
401289577 7542452 ... -1.10056e-005 1.56577e-009 1.56577e-009 1.10056e-005
273+
257194049 7542452 ... -1.38889e-005 -5.26157e-010 -5.26157e-010 1.38889e-005
274+
257438887 7542452 ... -1.38889e-005 -5.26157e-010 -5.26157e-010 1.38889e-005
277275

278276

279277
HSC spectra accessed through this class as well. `~astroquery.mast.CatalogsClass.get_hsc_spectra`

docs/mast/mast_obsquery.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ with `~astroquery.mast.ObservationsClass.get_product_list`
284284
(see `here <https://mast.stsci.edu/api/v0/_c_a_o_mfields.html>`__ for more details).
285285
Using "obs_id" instead of "obsid" from the previous example will result in the following error:
286286

287-
.. doctest-remote-data::
287+
.. doctest-skip::
288288
>>> obs_ids = obs_table[0:2]['obs_id']
289289
>>> data_products_by_id = Observations.get_product_list(obs_ids)
290290
Traceback (most recent call last):
@@ -325,12 +325,12 @@ Product filtering can also be applied directly to a table of products without pr
325325
...
326326
>>> data_products = Observations.get_product_list('25588063')
327327
>>> print(len(data_products))
328-
27
328+
30
329329
>>> products = Observations.filter_products(data_products,
330330
... productType=["SCIENCE", "PREVIEW"],
331331
... extension="fits")
332332
>>> print(len(products))
333-
8
333+
10
334334

335335

336336
Downloading Data Products

0 commit comments

Comments
 (0)