@@ -16,29 +16,61 @@ def test_raster_api():
16
16
def test_mosaic_api ():
17
17
"""test mosaic."""
18
18
query = {"collections" : ["noaa-emergency-response" ], "filter-lang" : "cql-json" }
19
- resp = httpx .post (f"{ raster_endpoint } /mosaic /register" , json = query )
19
+ resp = httpx .post (f"{ raster_endpoint } /searches /register" , json = query )
20
20
assert resp .headers ["content-type" ] == "application/json"
21
21
assert resp .status_code == 200
22
- assert resp .json ()["searchid " ]
22
+ assert resp .json ()["id " ]
23
23
assert resp .json ()["links" ]
24
24
25
- searchid = resp .json ()["searchid " ]
25
+ searchid = resp .json ()["id " ]
26
26
27
- resp = httpx .get (f"{ raster_endpoint } /mosaic /{ searchid } /-85.6358,36.1624/assets" )
27
+ resp = httpx .get (f"{ raster_endpoint } /searches /{ searchid } /-85.6358,36.1624/assets" )
28
28
assert resp .status_code == 200
29
29
assert len (resp .json ()) == 1
30
30
assert list (resp .json ()[0 ]) == ["id" , "bbox" , "assets" , "collection" ]
31
31
assert resp .json ()[0 ]["id" ] == "20200307aC0853900w361030"
32
32
33
- resp = httpx .get (f"{ raster_endpoint } /mosaic/{ searchid } /tiles/15/8589/12849/assets" )
33
+ resp = httpx .get (
34
+ f"{ raster_endpoint } /searches/{ searchid } /tiles/15/8589/12849/assets"
35
+ )
34
36
assert resp .status_code == 200
35
37
assert len (resp .json ()) == 1
36
38
assert list (resp .json ()[0 ]) == ["id" , "bbox" , "assets" , "collection" ]
37
39
assert resp .json ()[0 ]["id" ] == "20200307aC0853900w361030"
38
40
39
41
z , x , y = 15 , 8589 , 12849
40
42
resp = httpx .get (
41
- f"{ raster_endpoint } /mosaic/{ searchid } /tiles/{ z } /{ x } /{ y } " ,
43
+ f"{ raster_endpoint } /searches/{ searchid } /tiles/{ z } /{ x } /{ y } " ,
44
+ params = {"assets" : "cog" },
45
+ headers = {"Accept-Encoding" : "br, gzip" },
46
+ timeout = 10.0 ,
47
+ )
48
+ assert resp .status_code == 200
49
+ assert resp .headers ["content-type" ] == "image/jpeg"
50
+ assert "content-encoding" not in resp .headers
51
+
52
+
53
+ def test_mosaic_collection_api ():
54
+ """test mosaic collection."""
55
+ resp = httpx .get (
56
+ f"{ raster_endpoint } /collections/noaa-emergency-response/-85.6358,36.1624/assets"
57
+ )
58
+ assert resp .status_code == 200
59
+ assert len (resp .json ()) == 1
60
+ assert list (resp .json ()[0 ]) == ["id" , "bbox" , "assets" , "collection" ]
61
+ assert resp .json ()[0 ]["id" ] == "20200307aC0853900w361030"
62
+
63
+ resp = httpx .get (
64
+ f"{ raster_endpoint } /collections/noaa-emergency-response/tiles/15/8589/12849/assets"
65
+ )
66
+ assert resp .status_code == 200
67
+ assert len (resp .json ()) == 1
68
+ assert list (resp .json ()[0 ]) == ["id" , "bbox" , "assets" , "collection" ]
69
+ assert resp .json ()[0 ]["id" ] == "20200307aC0853900w361030"
70
+
71
+ z , x , y = 15 , 8589 , 12849
72
+ resp = httpx .get (
73
+ f"{ raster_endpoint } /collections/noaa-emergency-response/tiles/{ z } /{ x } /{ y } " ,
42
74
params = {"assets" : "cog" },
43
75
headers = {"Accept-Encoding" : "br, gzip" },
44
76
timeout = 10.0 ,
@@ -102,11 +134,11 @@ def test_mosaic_search():
102
134
},
103
135
]
104
136
for search in searches :
105
- resp = httpx .post (f"{ raster_endpoint } /mosaic /register" , json = search )
137
+ resp = httpx .post (f"{ raster_endpoint } /searches /register" , json = search )
106
138
assert resp .status_code == 200
107
- assert resp .json ()["searchid " ]
139
+ assert resp .json ()["id " ]
108
140
109
- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" )
141
+ resp = httpx .get (f"{ raster_endpoint } /searches /list" )
110
142
assert resp .headers ["content-type" ] == "application/json"
111
143
assert resp .status_code == 200
112
144
assert (
@@ -122,9 +154,11 @@ def test_mosaic_search():
122
154
assert len (links ) == 2
123
155
assert links [0 ]["rel" ] == "self"
124
156
assert links [1 ]["rel" ] == "next"
125
- assert links [1 ]["href" ] == f"{ raster_endpoint } /mosaic /list?limit=10&offset=10"
157
+ assert links [1 ]["href" ] == f"{ raster_endpoint } /searches /list?limit=10&offset=10"
126
158
127
- resp = httpx .get (f"{ raster_endpoint } /mosaic/list" , params = {"limit" : 1 , "offset" : 1 })
159
+ resp = httpx .get (
160
+ f"{ raster_endpoint } /searches/list" , params = {"limit" : 1 , "offset" : 1 }
161
+ )
128
162
assert resp .status_code == 200
129
163
assert resp .json ()["context" ]["matched" ] > 10
130
164
assert resp .json ()["context" ]["limit" ] == 1
@@ -133,33 +167,33 @@ def test_mosaic_search():
133
167
links = resp .json ()["links" ]
134
168
assert len (links ) == 3
135
169
assert links [0 ]["rel" ] == "self"
136
- assert links [0 ]["href" ] == f"{ raster_endpoint } /mosaic /list?limit=1&offset=1"
170
+ assert links [0 ]["href" ] == f"{ raster_endpoint } /searches /list?limit=1&offset=1"
137
171
assert links [1 ]["rel" ] == "next"
138
- assert links [1 ]["href" ] == f"{ raster_endpoint } /mosaic /list?limit=1&offset=2"
172
+ assert links [1 ]["href" ] == f"{ raster_endpoint } /searches /list?limit=1&offset=2"
139
173
assert links [2 ]["rel" ] == "prev"
140
- assert links [2 ]["href" ] == f"{ raster_endpoint } /mosaic /list?limit=1&offset=0"
174
+ assert links [2 ]["href" ] == f"{ raster_endpoint } /searches /list?limit=1&offset=0"
141
175
142
176
# Filter on mosaic metadata
143
- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" , params = {"owner" : "vincent" })
177
+ resp = httpx .get (f"{ raster_endpoint } /searches /list" , params = {"owner" : "vincent" })
144
178
assert resp .status_code == 200
145
179
assert resp .json ()["context" ]["matched" ] == 7
146
180
assert resp .json ()["context" ]["limit" ] == 10
147
181
assert resp .json ()["context" ]["returned" ] == 7
148
182
149
183
# sortBy
150
- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" , params = {"sortby" : "lastused" })
184
+ resp = httpx .get (f"{ raster_endpoint } /searches /list" , params = {"sortby" : "lastused" })
151
185
assert resp .status_code == 200
152
186
153
- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" , params = {"sortby" : "usecount" })
187
+ resp = httpx .get (f"{ raster_endpoint } /searches /list" , params = {"sortby" : "usecount" })
154
188
assert resp .status_code == 200
155
189
156
- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" , params = {"sortby" : "-owner" })
190
+ resp = httpx .get (f"{ raster_endpoint } /searches /list" , params = {"sortby" : "-owner" })
157
191
assert resp .status_code == 200
158
192
assert (
159
193
"owner" not in resp .json ()["searches" ][0 ]["search" ]["metadata" ]
160
194
) # some mosaic don't have owners
161
195
162
- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" , params = {"sortby" : "owner" })
196
+ resp = httpx .get (f"{ raster_endpoint } /searches /list" , params = {"sortby" : "owner" })
163
197
assert resp .status_code == 200
164
198
assert "owner" in resp .json ()["searches" ][0 ]["search" ]["metadata" ]
165
199
@@ -201,3 +235,15 @@ def test_collections():
201
235
collections = resp .json ()
202
236
assert len (collections ) == 1
203
237
assert collections [0 ]["id" ] == "noaa-emergency-response"
238
+
239
+
240
+ def test_cog_endpoints ():
241
+ """test /cog endpoints"""
242
+ resp = httpx .get (
243
+ f"{ raster_endpoint } /cog/info" ,
244
+ params = {
245
+ "url" : "https://noaa-eri-pds.s3.us-east-1.amazonaws.com/2020_Nashville_Tornado/20200307a_RGB/20200307aC0854500w361030n.tif" ,
246
+ },
247
+ )
248
+ assert resp .status_code == 200
249
+ assert resp .headers ["content-type" ] == "application/json"
0 commit comments