Skip to content

Commit 62bad66

Browse files
jsignellgadomski
andauthored
Fix --matched and add tests (#588)
* Fix walrus operator that broke --matched * Add tests for matched * fix(tests): remove subprocess to use vcr --------- Co-authored-by: Pete Gadomski <[email protected]>
1 parent 79826e3 commit 62bad66

File tree

4 files changed

+414
-1
lines changed

4 files changed

+414
-1
lines changed

pystac_client/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def search(
4040
result = client.search(method=method, **kwargs) # type: ignore[arg-type]
4141

4242
if matched:
43-
if nmatched := result.matched() is not None:
43+
if (nmatched := result.matched()) is not None:
4444
print(f"{nmatched} items matched")
4545
else:
4646
raise KeyError("'matched' is not supported for this catalog")
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
User-Agent:
12+
- python-requests/2.31.0
13+
method: GET
14+
uri: https://earth-search.aws.element84.com/v1
15+
response:
16+
body:
17+
string: '{"stac_version":"1.0.0","type":"Catalog","id":"earth-search-aws","title":"Earth
18+
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"]}'
19+
headers:
20+
Connection:
21+
- keep-alive
22+
Content-Length:
23+
- '3141'
24+
Content-Type:
25+
- application/json; charset=utf-8
26+
Date:
27+
- Tue, 05 Sep 2023 20:18:59 GMT
28+
Via:
29+
- 1.1 95ab38d462185df6df78ba1102868640.cloudfront.net (CloudFront)
30+
X-Amz-Cf-Id:
31+
- uZFEQcSwDnDGMweA1wbOhdhSqV6DiNuSzXbK5emzDp2p76WSTs6OuA==
32+
X-Amz-Cf-Pop:
33+
- DEN52-C1
34+
X-Amzn-Trace-Id:
35+
- Root=1-64f78d32-22a5391c108519676b6fb34c;Sampled=0;lineage=9e2884e9:0
36+
X-Cache:
37+
- Miss from cloudfront
38+
access-control-allow-origin:
39+
- '*'
40+
etag:
41+
- W/"c45-vX16rVW/Oi5D8pNBcBaw295oyu0"
42+
x-amz-apigw-id:
43+
- KzMAAGhYvHcFYvA=
44+
x-amzn-Remapped-content-length:
45+
- '3141'
46+
x-amzn-RequestId:
47+
- a1c3ff14-3455-4505-8990-09213f62aa6f
48+
x-powered-by:
49+
- Express
50+
status:
51+
code: 200
52+
message: OK
53+
- request:
54+
body: '{"collections": ["cop-dem-glo-30"], "limit": 1}'
55+
headers:
56+
Accept:
57+
- '*/*'
58+
Accept-Encoding:
59+
- gzip, deflate
60+
Connection:
61+
- keep-alive
62+
Content-Length:
63+
- '47'
64+
Content-Type:
65+
- application/json
66+
User-Agent:
67+
- python-requests/2.31.0
68+
method: POST
69+
uri: https://earth-search.aws.element84.com/v1/search
70+
response:
71+
body:
72+
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
73+
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;
74+
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
75+
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"}]}'
76+
headers:
77+
Connection:
78+
- keep-alive
79+
Content-Length:
80+
- '3410'
81+
Content-Type:
82+
- application/geo+json; charset=utf-8
83+
Date:
84+
- Tue, 05 Sep 2023 20:18:59 GMT
85+
Via:
86+
- 1.1 95ab38d462185df6df78ba1102868640.cloudfront.net (CloudFront)
87+
X-Amz-Cf-Id:
88+
- v9LI1M3wj_k8TnXvcztFv1L4SaODopM_gUaUulR5lrY_2XTmjRf6JA==
89+
X-Amz-Cf-Pop:
90+
- DEN52-C1
91+
X-Amzn-Trace-Id:
92+
- Root=1-64f78d33-366f96787c5c319959201dbc;Sampled=0;lineage=9e2884e9:0
93+
X-Cache:
94+
- Miss from cloudfront
95+
access-control-allow-origin:
96+
- '*'
97+
etag:
98+
- W/"d52-kZRavcSAvRPx0vigsOjB/Kx7RWY"
99+
x-amz-apigw-id:
100+
- KzMACFBQvHcFd1Q=
101+
x-amzn-Remapped-content-length:
102+
- '3410'
103+
x-amzn-RequestId:
104+
- f9b52b49-73d4-4e9a-a30a-5cb08600689e
105+
x-powered-by:
106+
- Express
107+
status:
108+
code: 200
109+
message: OK
110+
version: 1

0 commit comments

Comments
 (0)