Skip to content

Commit dee882d

Browse files
jaymedinabsipocz
authored andcommitted
finished unit test fixes for observations and catalogs. adding some assertions, removing explicit table size assertions.
1 parent 2c0dfe7 commit dee882d

File tree

1 file changed

+72
-38
lines changed

1 file changed

+72
-38
lines changed

astroquery/mast/tests/test_mast_remote.py

Lines changed: 72 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -396,23 +396,24 @@ def test_catalogs_query_region(self):
396396
assert isinstance(result, Table)
397397
assert max(distances) <= in_radius_arcmin
398398

399-
result = mast.Catalogs.query_region("158.47924 -7.30962", radius=in_radius, catalog="tic")
400-
399+
result = mast.Catalogs.query_region("158.47924 -7.30962",
400+
radius=in_radius,
401+
catalog="tic")
401402
row = np.where(result['ID'] == '841736289')
402403
assert isinstance(result, Table)
403404
assert result[row]['RA_orig'] == 158.475246786483
404405
assert result[row]['gaiaqflag'] == 1
405406

406-
result = mast.Catalogs.query_region("158.47924 -7.30962", radius=in_radius, catalog="ctl")
407-
407+
result = mast.Catalogs.query_region("158.47924 -7.30962",
408+
radius=in_radius,
409+
catalog="ctl")
408410
row = np.where(result['ID'] == '56662064')
409411
assert isinstance(result, Table)
410412
assert result[row]['TYC'] == '4918-01335-1'
411413

412414
result = mast.Catalogs.query_region("210.80227 54.34895",
413415
radius=1*u.deg,
414416
catalog="diskdetective")
415-
416417
row = np.where(result['designation'] == 'J140544.95+535941.1')
417418
assert isinstance(result, Table)
418419
assert result[row]['ZooniverseID'] == 'AWI0000r57'
@@ -428,30 +429,46 @@ def test_catalogs_query_object(self):
428429
# clear columns config
429430
mast.Catalogs._column_configs = dict()
430431

431-
result = mast.Catalogs.query_object("M10", radius=".02 deg", catalog="TIC")
432+
result = mast.Catalogs.query_object("M10",
433+
radius=".02 deg",
434+
catalog="TIC")
432435
assert isinstance(result, Table)
433-
assert len(result) >= 300
434436
assert result[np.where(result['ID'] == '189844449')]
435437

436-
result = mast.Catalogs.query_object("M10", radius=.001, catalog="HSC", magtype=1)
438+
result = mast.Catalogs.query_object("M10",
439+
radius=.001,
440+
catalog="HSC",
441+
magtype=1)
437442
assert isinstance(result, Table)
438-
assert len(result) >= 50
443+
assert result[np.where(result['MatchID']) == '60112519']
439444

440-
result = mast.Catalogs.query_object("M10", radius=.001, catalog="panstarrs", table="mean")
445+
result = mast.Catalogs.query_object("M10",
446+
radius=.001,
447+
catalog="panstarrs",
448+
table="mean")
441449
assert isinstance(result, Table)
442-
assert len(result) >= 5
450+
assert result[np.where(result['objName'] == 'PSO J254.2872-04.0991')]
443451

444-
result = mast.Catalogs.query_object("M101", radius=1, catalog="diskdetective")
452+
result = mast.Catalogs.query_object("M101",
453+
radius=1,
454+
catalog="diskdetective")
445455
assert isinstance(result, Table)
446-
assert len(result) > 10
456+
assert result[np.where(result['designation'] == 'J140758.82+534902.4')]
447457

448-
result = mast.Catalogs.query_object("M10", radius=0.01, catalog="Gaia", version=1)
458+
result = mast.Catalogs.query_object("M10",
459+
radius=0.01,
460+
catalog="Gaia",
461+
version=1)
462+
distances = list(result['distance'])
463+
radius_arcmin = 0.01 * u.deg.to(u.arcmin)
449464
assert isinstance(result, Table)
450-
assert len(result) > 200
465+
assert max(distances) < radius_arcmin
451466

452-
result = mast.Catalogs.query_object("TIC 441662144", radius=0.01, catalog="ctl")
467+
result = mast.Catalogs.query_object("TIC 441662144",
468+
radius=0.01,
469+
catalog="ctl")
453470
assert isinstance(result, Table)
454-
assert len(result) == 1
471+
assert result[np.where(result['ID'] == '441662144')]
455472

456473
def test_catalogs_query_criteria_async(self):
457474
# without position
@@ -488,7 +505,8 @@ def test_catalogs_query_criteria_async(self):
488505
state="complete")
489506
assert isinstance(responses, list)
490507

491-
responses = mast.Catalogs.query_criteria_async(catalog="panstarrs", table="mean",
508+
responses = mast.Catalogs.query_criteria_async(catalog="panstarrs",
509+
table="mean",
492510
objectname="M10",
493511
radius=.02,
494512
qualityFlag=48)
@@ -500,47 +518,58 @@ def test_catalogs_query_criteria(self):
500518
mast.Catalogs._column_configs = dict()
501519

502520
# without position
503-
result = mast.Catalogs.query_criteria(catalog="Tic", Bmag=[30, 50], objType="STAR")
521+
result = mast.Catalogs.query_criteria(catalog="Tic",
522+
Bmag=[30, 50],
523+
objType="STAR")
504524
assert isinstance(result, Table)
505-
assert len(result) >= 10
506525
assert result[np.where(result['ID'] == '81609218')]
507526

508-
result = mast.Catalogs.query_criteria(catalog="ctl", Tmag=[10.5, 11], POSflag="2mass")
527+
result = mast.Catalogs.query_criteria(catalog="ctl",
528+
Tmag=[10.5, 11],
529+
POSflag="2mass")
509530
assert isinstance(result, Table)
510-
assert len(result) >= 400
511531
assert result[np.where(result['ID'] == '291067184')]
512532

513533
result = mast.Catalogs.query_criteria(catalog="DiskDetective",
514534
state=["inactive", "disabled"],
515-
oval=[8, 10], multi=[3, 7])
535+
oval=[8, 10],
536+
multi=[3, 7])
516537
assert isinstance(result, Table)
517-
assert len(result) >= 30
518538
assert result[np.where(result['designation'] == 'J003920.04-300132.4')]
519539

520540
# with position
521-
result = mast.Catalogs.query_criteria(catalog="Tic", objectname="M10", objType="EXTENDED")
541+
result = mast.Catalogs.query_criteria(catalog="Tic",
542+
objectname="M10", objType="EXTENDED")
522543
assert isinstance(result, Table)
523-
assert len(result) >= 7
524544
assert result[np.where(result['ID'] == '10000732589')]
525545

526-
result = mast.Catalogs.query_criteria(objectname='TIC 291067184', catalog="ctl",
527-
Tmag=[10.5, 11], POSflag="2mass")
546+
result = mast.Catalogs.query_criteria(objectname='TIC 291067184',
547+
catalog="ctl",
548+
Tmag=[10.5, 11],
549+
POSflag="2mass")
528550
assert isinstance(result, Table)
529-
assert len(result) == 1
551+
assert result[np.where(result['Tmag']) == 10.893]
530552

531-
result = mast.Catalogs.query_criteria(catalog="DiskDetective", objectname="M10", radius=2,
553+
result = mast.Catalogs.query_criteria(catalog="DiskDetective",
554+
objectname="M10",
555+
radius=2,
532556
state="complete")
533557
assert isinstance(result, Table)
534-
assert len(result) >= 5
535558
assert result[np.where(result['designation'] == 'J165628.40-054630.8')]
536559

537-
result = mast.Catalogs.query_criteria(catalog="panstarrs", objectname="M10", radius=.01,
538-
qualityFlag=32, zoneID=10306)
560+
result = mast.Catalogs.query_criteria(catalog="panstarrs",
561+
objectname="M10",
562+
radius=.01,
563+
qualityFlag=32,
564+
zoneID=10306)
539565
assert isinstance(result, Table)
540-
assert len(result) >= 5
566+
assert result[np.where(result['objName'] == 'PSO J254.2861-04.1091')]
541567

542568
def test_catalogs_query_hsc_matchid_async(self):
543-
catalogData = mast.Catalogs.query_object("M10", radius=.001, catalog="HSC", magtype=1)
569+
catalogData = mast.Catalogs.query_object("M10",
570+
radius=.001,
571+
catalog="HSC",
572+
magtype=1)
544573

545574
responses = mast.Catalogs.query_hsc_matchid_async(catalogData[0])
546575
assert isinstance(responses, list)
@@ -553,7 +582,10 @@ def test_catalogs_query_hsc_matchid(self):
553582
# clear columns config
554583
mast.Catalogs._column_configs = dict()
555584

556-
catalogData = mast.Catalogs.query_object("M10", radius=.001, catalog="HSC", magtype=1)
585+
catalogData = mast.Catalogs.query_object("M10",
586+
radius=.001,
587+
catalog="HSC",
588+
magtype=1)
557589
matchid = catalogData[0]["MatchID"]
558590

559591
result = mast.Catalogs.query_hsc_matchid(catalogData[0])
@@ -576,15 +608,17 @@ def test_catalogs_get_hsc_spectra(self):
576608

577609
result = mast.Catalogs.get_hsc_spectra()
578610
assert isinstance(result, Table)
579-
assert len(result) >= 45762
580611
assert result[np.where(result['MatchID'] == '19657846')]
612+
assert result[np.where(result['DatasetName'] == 'HAG_J072657.06+691415.5_J8HPAXAEQ_V01.SPEC1D')]
581613

582614
def test_catalogs_download_hsc_spectra(self, tmpdir):
583615
allSpectra = mast.Catalogs.get_hsc_spectra()
584616

585617
# actually download the products
586-
result = mast.Catalogs.download_hsc_spectra(allSpectra[10], download_dir=str(tmpdir))
618+
result = mast.Catalogs.download_hsc_spectra(allSpectra[10],
619+
download_dir=str(tmpdir))
587620
assert isinstance(result, Table)
621+
588622
for row in result:
589623
if row['Status'] == 'COMPLETE':
590624
assert os.path.isfile(row['Local Path'])

0 commit comments

Comments
 (0)