def test_query_region(): coords = SkyCoord(ra=330.79488 * u.deg, dec=18.8843 * u.deg) radius = 0.001 table1 = NasaExoplanetArchive.query_region("pscomppars", coords, radius * u.deg) assert len(table1) == 1 assert table1["hostname"] == "HD 209458" table2 = NasaExoplanetArchive.query_region("pscomppars", coords, radius) _compare_tables(table1, table2)
def test_request_to_sql(): payload_dict = NasaExoplanetArchive.query_region(table="ps", coordinates=SkyCoord( ra=172.56 * u.deg, dec=7.59 * u.deg), radius=1.0 * u.deg, get_query_payload=True) sql_str = NasaExoplanetArchive._request_to_sql(payload_dict) assert sql_str == "select * from ps where contains(point('icrs',ra,dec),circle('icrs',172.56,7.59,1.0 degree))=1" payload_dict = NasaExoplanetArchive.query_criteria( table="ps", where="hostname like 'Kepler%'", order="hostname", get_query_payload=True) assert "order by" in NasaExoplanetArchive._request_to_sql(payload_dict) payload_dict = NasaExoplanetArchive.query_criteria( table="cumulative", where="pl_hostname like 'Kepler%'", order="pl_hostname", get_query_payload=True) assert "pl_hostname or pl_name" in NasaExoplanetArchive._request_to_sql( payload_dict)