Skip to content

Commit 32bc8e5

Browse files
committed
Changelog, raise error if no dataset kwd found in MastMissions, coverage
1 parent a78ae5a commit 32bc8e5

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

astroquery/mast/missions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ def get_product_list_async(self, datasets, batch_size=1000):
434434
if isinstance(datasets, Table) or isinstance(datasets, Row):
435435
dataset_kwd = self.get_dataset_kwd()
436436
if not dataset_kwd:
437-
log.warning(f'Dataset keyword not found for mission {self.mission}. '
438-
'Please input dataset IDs as a string, list of strings, or `~astropy.table.Column`.')
439-
return None
437+
error_msg = (f'Dataset keyword not found for mission "{self.mission}". '
438+
'Please input dataset IDs as a string, list of strings, or `~astropy.table.Column`.')
439+
raise InvalidQueryError(error_msg)
440440

441441
# Extract dataset IDs based on input type and mission
442442
if isinstance(datasets, Table):

astroquery/mast/observations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ def get_product_list_async(self, observations, batch_size=500):
537537
observations = observations['obsid'].tolist()
538538

539539
# Clean and validate
540-
observations = [str(obs).strip() for obs in observations if str(obs).strip()]
540+
observations = [str(obs).strip() for obs in observations]
541+
observations = [obs for obs in observations if obs]
541542
if not observations:
542543
raise InvalidQueryError('Observation list is empty, no associated products.')
543544

astroquery/mast/tests/test_mast.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ def test_missions_get_product_list_async(patch_post):
331331
mast.MastMissions.get_product_list_async([' '])
332332
assert 'Dataset list is empty' in str(err_empty.value)
333333

334+
# No dataset keyword
335+
with pytest.raises(InvalidQueryError, match='Dataset keyword not found for mission "invalid"'):
336+
missions = mast.MastMissions(mission='invalid')
337+
missions.get_product_list_async(Table({'a': [1, 2, 3]}))
338+
334339

335340
def test_missions_get_product_list(patch_post):
336341
# String input

0 commit comments

Comments
 (0)