def test_fetch_astroquery(verbose=True, *args, **kwargs): ''' Test astroquery ''' fetch_astroquery('CO2', 1, 2200, 2400, verbose=verbose) if verbose: print('test_fetch_astroquery: no test defined') return
def test_fetch_astroquery_cache(verbose=True, *args, **kwargs): """Test astroquery cache file generation - Cache file is generated - Cache file is loaded. - Different metadata raises an error """ df = fetch_astroquery( "CO2", 1, 2200, 2400, verbose=verbose, cache="regen", # Delete existing cache file if needed ) # assert cache file was created assert exists( join( Hitran.cache_location, CACHE_FILE_NAME.format(**{ "molecule": "CO2", "isotope": 1, "wmin": 2200, "wmax": 2400 }), )) # Try to load with different metadata: expect a DeprecatedFileError with pytest.raises(DeprecatedFileWarning): df2 = fetch_astroquery( "CO2", 1, 2200, 2400, verbose=verbose, cache="force", # force load of cache file expected_metadata={"not_in_metadata": True}, ) # Try to load with correct metadata. Expect to work and return the dataframe df2 = fetch_astroquery( "CO2", 1, 2200, 2400, verbose=verbose, cache="force", # force load of cache file ) assert (df == df2).all().all() return
def test_fetch_astroquery_empty(verbose=True, *args, **kwargs): ''' Test astroquery: get a spectral range where there are no lines''' df = fetch_astroquery(2, 1, 25000, 50000, verbose=verbose) # 200-400 nm assert len(df) == 0 return
def test_fetch_astroquery(verbose=True, *args, **kwargs): """ Test astroquery """ df = fetch_astroquery("CO2", 1, 2200, 2400, verbose=verbose, cache=False) assert df.iloc[0].id == 2 assert df.iloc[0].iso == 1 return
def test_fetch_astroquery(verbose=True, *args, **kwargs): ''' Test astroquery ''' df = fetch_astroquery('CO2', 1, 2200, 2400, verbose=verbose, cache=False) assert df.iloc[0].id == 2 assert df.iloc[0].iso == 1 return
def test_fetch_astroquery_cache(verbose=True, *args, **kwargs): ''' Test astroquery cache file generation''' df = fetch_astroquery( 'CO2', 1, 2200, 2400, verbose=verbose, cache='regen', # Delete existing cache file if needed metadata={'_test': True}) # assert cache file was created assert exists( join( Hitran.cache_location, CACHE_FILE_NAME.format(**{ 'molecule': 'CO2', 'isotope': 1, 'wmin': 2200, 'wmax': 2400 }))) # Try to load with different metadata: expect a DeprecatedFileError with pytest.raises(DeprecatedFileError): df2 = fetch_astroquery( 'CO2', 1, 2200, 2400, verbose=verbose, cache='force', # force load of cache file metadata={}) # Try to load with correct metadata. Expect to work and return the dataframe df2 = fetch_astroquery( 'CO2', 1, 2200, 2400, verbose=verbose, cache='force', # force load of cache file metadata={'_test': True}) assert (df == df2).all().all() return