def test_format(): table1 = NasaExoplanetArchive.query_object("HAT-P-11 b") table2 = NasaExoplanetArchive.query_object("HAT-P-11 b", format="votable") _compare_tables(table1, table2) table1 = NasaExoplanetArchive.query_object("HAT-P-11 b", format="csv") table2 = NasaExoplanetArchive.query_object("HAT-P-11 b", format="bar") _compare_tables(table1, table2) table1 = NasaExoplanetArchive.query_object("HAT-P-11 b", format="xml") table2 = NasaExoplanetArchive.query_object("HAT-P-11 b", format="table") _compare_tables(table1, table2) with pytest.raises(InvalidQueryError) as error: NasaExoplanetArchive.query_object("HAT-P-11 b", format="json") assert "json" in str(error)
def test_table_errors(): with pytest.raises(InvalidTableError) as error: NasaExoplanetArchive.query_object("K2-18 b", table="exoplanets") assert "exoplanets" in str(error) with pytest.raises(InvalidTableError) as error: NasaExoplanetArchive.query_object("K2-18 b", table="exomultpars") assert "exomultpars" in str(error) with pytest.raises(InvalidTableError) as error: NasaExoplanetArchive.query_object("K2-18 b", table="compositepars") assert "compositepars" in str(error)
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)