Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --matched and add tests #588

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pystac_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def search(
result = client.search(method=method, **kwargs) # type: ignore[arg-type]

if matched:
if nmatched := result.matched() is not None:
if (nmatched := result.matched()) is not None:
print(f"{nmatched} items matched")
else:
raise KeyError("'matched' is not supported for this catalog")
Expand Down
110 changes: 110 additions & 0 deletions tests/cassettes/test_cli/TestCLI.test_matched[inprocess].yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-requests/2.31.0
method: GET
uri: https://earth-search.aws.element84.com/v1
response:
body:
string: '{"stac_version":"1.0.0","type":"Catalog","id":"earth-search-aws","title":"Earth
Search by Element 84","description":"A STAC API of public datasets on AWS","links":[{"rel":"self","type":"application/json","href":"https://earth-search.aws.element84.com/v1"},{"rel":"root","type":"application/json","href":"https://earth-search.aws.element84.com/v1"},{"rel":"conformance","type":"application/json","href":"https://earth-search.aws.element84.com/v1/conformance"},{"rel":"data","type":"application/json","href":"https://earth-search.aws.element84.com/v1/collections"},{"rel":"search","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/search","method":"GET"},{"rel":"search","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/search","method":"POST"},{"rel":"aggregate","type":"application/json","href":"https://earth-search.aws.element84.com/v1/aggregate","method":"GET"},{"rel":"aggregations","type":"application/json","href":"https://earth-search.aws.element84.com/v1/aggregations"},{"rel":"service-desc","type":"application/vnd.oai.openapi","href":"https://earth-search.aws.element84.com/v1/api"},{"rel":"service-doc","type":"text/html","href":"https://earth-search.aws.element84.com/v1/api.html"},{"rel":"http://www.opengis.net/def/rel/ogc/1.0/queryables","type":"application/schema+json","href":"https://earth-search.aws.element84.com/v1/queryables"},{"rel":"server","type":"text/html","href":"https://stac-utils.github.io/stac-server/"},{"rel":"child","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/collections/cop-dem-glo-30"},{"rel":"child","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/collections/naip"},{"rel":"child","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a"},{"rel":"child","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/collections/sentinel-2-l1c"},{"rel":"child","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/collections/landsat-c2-l2"},{"rel":"child","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/collections/cop-dem-glo-90"},{"rel":"child","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/collections/sentinel-1-grd"}],"conformsTo":["https://api.stacspec.org/v1.0.0/core","https://api.stacspec.org/v1.0.0/collections","https://api.stacspec.org/v1.0.0/ogcapi-features","https://api.stacspec.org/v1.0.0/item-search","https://api.stacspec.org/v1.0.0-rc.3/ogcapi-features#fields","https://api.stacspec.org/v1.0.0-rc.2/ogcapi-features#sort","https://api.stacspec.org/v1.0.0-rc.2/ogcapi-features#query","https://api.stacspec.org/v1.0.0-rc.3/item-search#fields","https://api.stacspec.org/v1.0.0-rc.2/item-search#sort","https://api.stacspec.org/v1.0.0-rc.2/item-search#query","https://api.stacspec.org/v0.3.0/aggregation","http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core","http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30","http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson"]}'
headers:
Connection:
- keep-alive
Content-Length:
- '3141'
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 05 Sep 2023 20:18:59 GMT
Via:
- 1.1 95ab38d462185df6df78ba1102868640.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- uZFEQcSwDnDGMweA1wbOhdhSqV6DiNuSzXbK5emzDp2p76WSTs6OuA==
X-Amz-Cf-Pop:
- DEN52-C1
X-Amzn-Trace-Id:
- Root=1-64f78d32-22a5391c108519676b6fb34c;Sampled=0;lineage=9e2884e9:0
X-Cache:
- Miss from cloudfront
access-control-allow-origin:
- '*'
etag:
- W/"c45-vX16rVW/Oi5D8pNBcBaw295oyu0"
x-amz-apigw-id:
- KzMAAGhYvHcFYvA=
x-amzn-Remapped-content-length:
- '3141'
x-amzn-RequestId:
- a1c3ff14-3455-4505-8990-09213f62aa6f
x-powered-by:
- Express
status:
code: 200
message: OK
- request:
body: '{"collections": ["cop-dem-glo-30"], "limit": 1}'
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '47'
Content-Type:
- application/json
User-Agent:
- python-requests/2.31.0
method: POST
uri: https://earth-search.aws.element84.com/v1/search
response:
body:
string: '{"type":"FeatureCollection","stac_version":"1.0.0","stac_extensions":[],"context":{"limit":1,"matched":26450,"returned":1},"numberMatched":26450,"numberReturned":1,"features":[{"type":"Feature","stac_version":"1.0.0","id":"Copernicus_DSM_COG_10_S90_00_W180_00_DEM","properties":{"platform":"tandem-x","gsd":30,"proj:epsg":4326,"proj:transform":[0.002777777777777778,0,-180.0013888888889,0,-0.0002777777777777778,-88.99986111111112],"proj:shape":[3600,360],"proj:centroid":{"lat":-89.5,"lon":-179.5},"grid:code":"CDEM-S90W180","storage:platform":"AWS","storage:region":"eu-central-1","storage:requester_pays":false,"earthsearch:payload_id":"cop-dem-glo/workflow-cop-dem-glo-to-stac/c535d071376a7c60ed297e65c490d41a","datetime":"2021-04-22T00:00:00Z","processing:software":{"cop-dem-glo-to-stac":"2023.03.28"},"created":"2023-03-28T15:22:58.882Z","updated":"2023-04-20T18:14:07.025Z"},"geometry":{"type":"Polygon","coordinates":[[[-179.0013888888889,-89.99986111111112],[-179.0013888888889,-88.99986111111112],[-180.0013888888889,-88.99986111111112],[-180.0013888888889,-89.99986111111112],[-179.0013888888889,-89.99986111111112]]]},"links":[{"rel":"self","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/collections/cop-dem-glo-30/items/Copernicus_DSM_COG_10_S90_00_W180_00_DEM"},{"rel":"canonical","href":"s3://earthsearch-data/cop-dem-glo-30/Copernicus_DSM_COG_10_S90_00_W180_00_DEM/Copernicus_DSM_COG_10_S90_00_W180_00_DEM.json","type":"application/json"},{"rel":"handbook","href":"https://object.cloud.sdsc.edu/v1/AUTH_opentopography/www/metadata/Copernicus_metadata.pdf","type":"application/pdf","title":"Copernicus
DEM User handbook","description":"Also includes data usage information"},{"rel":"parent","type":"application/json","href":"https://earth-search.aws.element84.com/v1/collections/cop-dem-glo-30"},{"rel":"collection","type":"application/json","href":"https://earth-search.aws.element84.com/v1/collections/cop-dem-glo-30"},{"rel":"root","type":"application/json","href":"https://earth-search.aws.element84.com/v1"},{"rel":"thumbnail","href":"https://earth-search.aws.element84.com/v1/collections/cop-dem-glo-30/items/Copernicus_DSM_COG_10_S90_00_W180_00_DEM/thumbnail"}],"assets":{"data":{"href":"s3://copernicus-dem-30m/Copernicus_DSM_COG_10_S90_00_W180_00_DEM/Copernicus_DSM_COG_10_S90_00_W180_00_DEM.tif","type":"image/tiff;
application=geotiff; profile=cloud-optimized","title":"Data","raster:bands":[{"sampling":"point","data_type":"float32","spatial_resolution":30,"unit":"meter"}],"roles":["data"]}},"bbox":[-180.0013888888889,-89.99986111111112,-179.0013888888889,-88.99986111111112],"stac_extensions":["https://stac-extensions.github.io/storage/v1.0.0/schema.json","https://stac-extensions.github.io/processing/v1.1.0/schema.json","https://stac-extensions.github.io/raster/v1.1.0/schema.json","https://stac-extensions.github.io/grid/v1.1.0/schema.json","https://stac-extensions.github.io/projection/v1.1.0/schema.json"],"collection":"cop-dem-glo-30"}],"links":[{"rel":"next","title":"Next
page of Items","method":"POST","type":"application/geo+json","href":"https://earth-search.aws.element84.com/v1/search","merge":false,"body":{"collections":["cop-dem-glo-30"],"limit":1,"next":"2021-04-22T00:00:00Z,Copernicus_DSM_COG_10_S90_00_W180_00_DEM,cop-dem-glo-30"}},{"rel":"root","type":"application/json","href":"https://earth-search.aws.element84.com/v1"}]}'
headers:
Connection:
- keep-alive
Content-Length:
- '3410'
Content-Type:
- application/geo+json; charset=utf-8
Date:
- Tue, 05 Sep 2023 20:18:59 GMT
Via:
- 1.1 95ab38d462185df6df78ba1102868640.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- v9LI1M3wj_k8TnXvcztFv1L4SaODopM_gUaUulR5lrY_2XTmjRf6JA==
X-Amz-Cf-Pop:
- DEN52-C1
X-Amzn-Trace-Id:
- Root=1-64f78d33-366f96787c5c319959201dbc;Sampled=0;lineage=9e2884e9:0
X-Cache:
- Miss from cloudfront
access-control-allow-origin:
- '*'
etag:
- W/"d52-kZRavcSAvRPx0vigsOjB/Kx7RWY"
x-amz-apigw-id:
- KzMACFBQvHcFd1Q=
x-amzn-Remapped-content-length:
- '3410'
x-amzn-RequestId:
- f9b52b49-73d4-4e9a-a30a-5cb08600689e
x-powered-by:
- Express
status:
code: 200
message: OK
version: 1
Loading
Loading