Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
46 changes: 30 additions & 16 deletions astroquery/mast/tests/test_mast_remote.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

import json
import logging
import os
from pathlib import Path

import astropy.units as u
import numpy as np
import os
import pytest
import json

from requests.models import Response

from astropy.table import Table, unique
from astropy.coordinates import SkyCoord
from astropy.io import fits
import astropy.units as u

from astroquery.mast import Observations, utils, Mast, Catalogs, Hapcut, Tesscut, Zcut, MastMissions
from astropy.table import Table, unique
from requests.models import Response

from astroquery.mast import (
Catalogs,
Hapcut,
Mast,
MastMissions,
Observations,
Tesscut,
Zcut,
utils,
)

from ...exceptions import (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit of bikeshedding, but I wonder if you could fine tune your linter's setting for astroquery and not do these reformats for shorter lines.

InputWarning,
InvalidQueryError,
MaxResultsWarning,
NoResultsWarning,
)
from ..utils import ResolverError
from ...exceptions import (InputWarning, InvalidQueryError, MaxResultsWarning,
NoResultsWarning)


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -66,8 +78,10 @@ def test_resolve_object(self):

# Try the same object with different resolvers
# The position of objects can change with different resolvers
ned_loc = utils.resolve_object("jw100", resolver="NED")
assert round(ned_loc.separation(SkyCoord("354.10436 21.15083", unit='deg')).value, 4) == 0
# TODO: Commenting out NED resolver test for now since we've been having issues with NED service availability.
# Re-enable this test once the service is stable.
# ned_loc = utils.resolve_object("jw100", resolver="NED")
# assert round(ned_loc.separation(SkyCoord("354.10436 21.15083", unit='deg')).value, 4) == 0

simbad_loc = utils.resolve_object("jw100", resolver="simbad")
assert round(simbad_loc.separation(SkyCoord("83.70341477 -5.55918309", unit="deg")).value, 4) == 0
Expand All @@ -79,16 +93,16 @@ def test_resolve_object(self):
# Use resolve_all to get all resolvers
loc_dict = utils.resolve_object("jw100", resolve_all=True)
assert isinstance(loc_dict, dict)
assert loc_dict['NED'] == ned_loc
# assert loc_dict['NED'] == ned_loc
assert loc_dict['SIMBAD'] == simbad_loc

# Error if coordinates cannot be resolved
with pytest.raises(ResolverError, match='Could not resolve "invalid" to a sky position.'):
utils.resolve_object("invalid")

# Error if coordinates cannot be resolved with a specific resolver
with pytest.raises(ResolverError, match='Could not resolve "invalid" to a sky position using resolver "NED"'):
utils.resolve_object("invalid", resolver="NED")
with pytest.raises(ResolverError, match='not resolve "invalid" to a sky position using resolver "SIMBAD"'):
utils.resolve_object("invalid", resolver="SIMBAD")

###########################
# MissionSearchClass Test #
Expand Down
19 changes: 11 additions & 8 deletions astroquery/mast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@
Miscellaneous functions used throughout the MAST module.
"""

import platform
import re
import warnings

import numpy as np
import requests
import platform
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.table import Table
from astropy.utils import deprecated
from astropy.utils.console import ProgressBarOrSpinner
from astropy.utils.decorators import deprecated_renamed_argument
from astropy import units as u

from .. import log
from ..version import version
from ..exceptions import InputWarning, NoResultsWarning, ResolverError, InvalidQueryError
from ..exceptions import (
InputWarning,
InvalidQueryError,
NoResultsWarning,
ResolverError,
)
from ..utils import commons

from ..version import version

__all__ = []

Expand Down Expand Up @@ -227,10 +231,9 @@ def resolve_object(object_name, *, resolver=None, resolve_all=False, batch_size=
break

# Send request to STScI Archive Name Translation Application (SANTA)
params = {'outputFormat': 'json',
'resolveAll': resolve_all or is_catalog} # Always set resolveAll to True for MAST catalogs
params = {'outputFormat': 'json', 'resolveAll': resolve_all} # Always set resolveAll to True for MAST catalogs
if resolver and not params['resolveAll']:
params['resolver'] = resolver
params['resolver'] = [resolver, catalog] if is_catalog else [resolver]

# Fetch results (batching if necessary)
results = _batched_request(
Expand Down
Loading