def test_both_physobs(): params = walker.create(a.Physobs("intensity")) assert len(params) == 1 assert params[0]["hasAllStokes"] is False params = walker.create(a.Physobs("stokes_parameters")) assert len(params) == 1 assert params[0]["hasAllStokes"] is True params = walker.create(a.Physobs("spectral_axis")) assert len(params) == 1 assert params[0]["hasSpectralAxis"] is True params = walker.create(a.Physobs("temporal_axis")) assert len(params) == 1 assert params[0]["hasTemporalAxis"] is True
def test_and_simple(query_and_simple): out = walker.create(query_and_simple) assert len(out) == 1 assert isinstance(out, list) assert all([isinstance(a, dict) for a in out]) assert out == [{ "instrumentNames": "VBI", "startTimeMin": "2020-06-01T00:00:00.000", "endTimeMax": "2020-06-02T00:00:00.000", }]
def test_walker_single(all_attrs_classes, api_param_names): at = None if issubclass(all_attrs_classes, da.SpatialSampling): at = all_attrs_classes(spatialmin=1.3 * u.arcsec / u.pix, spatialmax=1.5 * u.arcsec / u.pix) elif issubclass(all_attrs_classes, da.SpectralSampling): at = all_attrs_classes(spectralmin=580 * u.nm, spectralmax=590 * u.nm) elif issubclass(all_attrs_classes, da.TemporalSampling): at = all_attrs_classes(temporalmin=1 * u.s, temporalmax=500 * u.s) elif issubclass(all_attrs_classes, attr.SimpleAttr): at = all_attrs_classes("stokes_parameters") elif issubclass(all_attrs_classes, a.Time): at = all_attrs_classes("2020/01/01", "2020/01/02") elif issubclass(all_attrs_classes, a.Wavelength): at = all_attrs_classes(10 * u.nm, 20 * u.nm) elif issubclass(all_attrs_classes, attr.Range): unit = list(all_attrs_classes.__init__.__annotations__.values()) unit = unit[0] if unit else u.one at = all_attrs_classes(10 * unit, 10 * unit) elif issubclass(all_attrs_classes, da.BrowseMovie): at = all_attrs_classes(movieurl="klsdjalkjd", movieobjectkey="lkajsd") api_param_names[all_attrs_classes] = ('browseMovieUrl', 'browseMovieObjectKey') elif issubclass(all_attrs_classes, da.BoundingBox): bottom_left = SkyCoord([ ICRS(ra=1 * u.deg, dec=2 * u.deg, distance=150000000 * u.km), ICRS(ra=3 * u.deg, dec=4 * u.deg, distance=150000000 * u.km) ], obstime='2021-01-02T12:34:56') at = all_attrs_classes(bottom_left=bottom_left) api_param_names[all_attrs_classes] = ( 'rectangleContainingBoundingBox', ) if not at: pytest.skip(f"Not testing {all_attrs_classes!r}") params = walker.create(at) assert isinstance(params, list) assert len(params) == 1 assert isinstance(params[0], dict) assert len(params[0]) == len(api_param_names[all_attrs_classes]) assert not set(api_param_names[all_attrs_classes]).difference( params[0].keys())
def test_boundingbox(search, search_type, boundingbox_param): bb_query = da.BoundingBox(bottom_left=boundingbox_param[0], top_right=boundingbox_param[1], width=boundingbox_param[2], height=boundingbox_param[3], search=search) out = walker.create(bb_query) assert len(out) == 1 assert all([isinstance(a, dict) for a in out]) # can't verify exact coordinates, they change a bit for key in out[0].keys(): assert key == search_type for value in out[0].values(): # want to make sure the value is of the format (flt, flt), (flt, flt) coordinate_regex = re.compile( r'^(\()(-?\d+)(\.\d+)?(,)(-?\d+)(\.\d+)?(\))(,)(\()(-?\d+)(\.\d+)?(,)(-?\d+)(\.\d+)?(\))$' ) assert coordinate_regex.search(value)