def test_parse_filter_arg(self): """ No filter given and filter required. """ filt = autils.parse_filter_arg({'filter': 'XXX'}, required=True) assert filt is not None assert filt == 'XXX' filt = autils.parse_filter_arg({'filter': 'shhh'}, required=True) assert filt is not None assert filt == 'shhh'
def query_coordinates (args): """ Return some metadata for images which contain the given point. """ co_args = au.parse_cutout_args(args) # get coordinates collection = au.parse_collection_arg(args) # optional collection restriction filt = au.parse_filter_arg(args) # optional filter restriction return jsonify(imgr.query_coordinates(co_args, collection=collection, filt=filt))
def fetch_cutout_by_filter (args): """ Make and return an image cutout for a filtered image. The band is specified by the required 'filter' argument. """ # parse the parameters for the cutout co_args = au.parse_cutout_args(args) filt = au.parse_filter_arg(args, required=True) # test for required filter collection = au.parse_collection_arg(args) return imgr.get_image_or_cutout(co_args, filt=filt, collection=collection)
def fetch_cutout (args): """ Return an image cutout. if cutout size is not specified, return the entire image. """ # parse the parameters for the cutout co_args = au.parse_cutout_args(args) collection = au.parse_collection_arg(args) filt = au.parse_filter_arg(args) return imgr.get_image_or_cutout(co_args, filt=filt, collection=collection)
def fetch_image_by_filter (args): """ Fetch a specific image by filter/collection. """ filt = au.parse_filter_arg(args, required=True) # get required filter or error collection = au.parse_collection_arg(args) istream = imgr.fetch_image_by_filter(filt, collection=collection) if (istream is not None): return istream else: coll = f"and collection '{collection}'" if (collection) else '' errMsg = f"Image with filter '{filt}' {coll} not found in database" current_app.logger.error(errMsg) raise exceptions.ImageNotFound(errMsg)
def image_metadata_by_filter (args): """ Return image metadata for all images with a specific filter/collection. """ filt = au.parse_filter_arg(args, required=True) # get required filter or error collection = au.parse_collection_arg(args) # optional collection restriction return jsonify(imgr.image_metadata_by_filter(filt, collection=collection))
def query_image (args): """ List images which meet the given filter and collection criteria. """ collection = au.parse_collection_arg(args) # optional collection restriction filt = au.parse_filter_arg(args) # optional filter restriction return jsonify(imgr.query_image(collection=collection, filt=filt))
def test_parse_filter_arg_empty_req(self): """ Empty filter given and filter required. """ with pytest.raises(RequestException, match=self.filt_emsg) as reqex: autils.parse_filter_arg({'filter': ' '}, required=True)
def test_parse_filter_arg_none(self): """ None given, but filter not required. """ filt = autils.parse_filter_arg({'filter': None}) assert filt is None
def test_parse_filter_arg_empty(self): """ Empty filter given, but not required. """ filt = autils.parse_filter_arg({'filter': ' '}) assert filt is None
def test_parse_filter_arg_nofilt(self): """ No filter given, but not required. """ filt = autils.parse_filter_arg({}) assert filt is None