Exemple #1
0
def test_missing_criterion_super_wasp():
    with pytest.raises(InvalidQueryError) as error:
        NasaExoplanetArchive.query_criteria("superwasptimeseries")
    assert "Queries against the SuperWASP Time Series table require" in str(
        error)
    NasaExoplanetArchive.query_criteria("superwasptimeseries",
                                        sourceid="1SWASP J191645.46+474912.3")
Exemple #2
0
def test_missing_criterion_kepler():
    with pytest.raises(InvalidQueryError) as error:
        NasaExoplanetArchive.query_criteria("keplertimeseries",
                                            where="kepid=8561063")
    assert "Queries against the Kepler Time Series table require" in str(error)
    NasaExoplanetArchive.query_criteria("keplertimeseries",
                                        kepid=8561063,
                                        quarter=14)
Exemple #3
0
def test_missing_criterion_kelt():
    with pytest.raises(InvalidQueryError) as error:
        NasaExoplanetArchive.query_criteria("kelttimeseries")
    assert "Queries against the KELT Time Series table require" in str(error)
    NasaExoplanetArchive.query_criteria(
        "kelttimeseries",
        where="kelt_sourceid='KELT_N02_lc_012738_V01_east'",
        kelt_field="N02")
Exemple #4
0
def test_select():
    payload = NasaExoplanetArchive.query_criteria(
        "ps",
        select=["hostname", "pl_name"],
        where="hostname='Kepler-11'",
        get_query_payload=True,
    )
    assert payload["select"] == "hostname,pl_name"

    table1 = NasaExoplanetArchive.query_criteria(
        "ps", select=["hostname", "pl_name"], where="hostname='Kepler-11'")
    table2 = NasaExoplanetArchive.query_criteria("ps",
                                                 select="hostname,pl_name",
                                                 where="hostname='Kepler-11'")
    _compare_tables(table1, table2)
Exemple #5
0
def test_warnings():
    with pytest.warns(NoResultsWarning):
        NasaExoplanetArchive.query_criteria("ps",
                                            where="hostname='not a host'")

    with pytest.warns(InputWarning):
        NasaExoplanetArchive.query_object("HAT-P-11 b", where="nothing")

    with pytest.warns(InputWarning):
        NasaExoplanetArchive.query_object(object_name="K2-18 b",
                                          table="pscomppars",
                                          where="nothing")

    with pytest.raises(InvalidQueryError) as error:
        NasaExoplanetArchive.query_object("HAT-P-11 b", table="cumulative")
    assert "Invalid table 'cumulative'" in str(error)
Exemple #6
0
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)
Exemple #7
0
def test_invalid_query_exoplanets():
    with pytest.raises(InvalidQueryError) as error:
        NasaExoplanetArchive.query_criteria("ps", where="hostname=Kepler-11")
    assert "kepler" in str(error).lower()
Exemple #8
0
def test_invalid_column():
    with pytest.raises(InvalidQueryError) as error:
        NasaExoplanetArchive.query_criteria("ps", select="not_a_column")
    assert "not_a_column" in str(error).lower()
Exemple #9
0
def test_invalid_table():
    with pytest.raises(InvalidTableError) as error:
        NasaExoplanetArchive.query_criteria("not_a_table")
    assert "not_a_table" in str(error)