@@ -1197,3 +1197,37 @@ def test_zcut_get_cutouts(patch_post, tmpdir):
11971197 assert isinstance (cutout_list , list )
11981198 assert len (cutout_list ) == 1
11991199 assert isinstance (cutout_list [0 ], fits .HDUList )
1200+
1201+
1202+ ################
1203+ # Utils tests #
1204+ ################
1205+
1206+
1207+ def test_parse_input_location (patch_post ):
1208+ # Test with coordinates
1209+ coord = SkyCoord (23.34086 , 60.658 , unit = "deg" )
1210+ loc = mast .utils .parse_input_location (coordinates = coord )
1211+ assert isinstance (loc , SkyCoord )
1212+ assert loc .ra == coord .ra
1213+ assert loc .dec == coord .dec
1214+
1215+ # Test with object name
1216+ obj_coord = SkyCoord (124.531756290083 , - 68.3129998725044 , unit = "deg" )
1217+ loc = mast .utils .parse_input_location (objectname = "TIC 307210830" )
1218+ assert isinstance (loc , SkyCoord )
1219+ assert loc .ra == obj_coord .ra
1220+ assert loc .dec == obj_coord .dec
1221+
1222+ # Error if both coordinates and object name are provided
1223+ with pytest .raises (InvalidQueryError , match = "Only one of objectname and coordinates may be specified" ):
1224+ mast .utils .parse_input_location (coordinates = coord , objectname = "M101" )
1225+
1226+ # Error if neither coordinates nor object name is provided
1227+ with pytest .raises (InvalidQueryError , match = "One of objectname and coordinates must be specified" ):
1228+ mast .utils .parse_input_location ()
1229+
1230+ # Warn if resolver is specified without an object name
1231+ with pytest .warns (InputWarning , match = "Resolver is only used when resolving object names" ):
1232+ loc = mast .utils .parse_input_location (coordinates = coord , resolver = "SIMBAD" )
1233+ assert isinstance (loc , SkyCoord )
0 commit comments