@@ -16,29 +16,61 @@ def test_raster_api():
1616def test_mosaic_api ():
1717 """test mosaic."""
1818 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 )
2020 assert resp .headers ["content-type" ] == "application/json"
2121 assert resp .status_code == 200
22- assert resp .json ()["searchid " ]
22+ assert resp .json ()["id " ]
2323 assert resp .json ()["links" ]
2424
25- searchid = resp .json ()["searchid " ]
25+ searchid = resp .json ()["id " ]
2626
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" )
2828 assert resp .status_code == 200
2929 assert len (resp .json ()) == 1
3030 assert list (resp .json ()[0 ]) == ["id" , "bbox" , "assets" , "collection" ]
3131 assert resp .json ()[0 ]["id" ] == "20200307aC0853900w361030"
3232
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+ )
3436 assert resp .status_code == 200
3537 assert len (resp .json ()) == 1
3638 assert list (resp .json ()[0 ]) == ["id" , "bbox" , "assets" , "collection" ]
3739 assert resp .json ()[0 ]["id" ] == "20200307aC0853900w361030"
3840
3941 z , x , y = 15 , 8589 , 12849
4042 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 } " ,
4274 params = {"assets" : "cog" },
4375 headers = {"Accept-Encoding" : "br, gzip" },
4476 timeout = 10.0 ,
@@ -102,11 +134,11 @@ def test_mosaic_search():
102134 },
103135 ]
104136 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 )
106138 assert resp .status_code == 200
107- assert resp .json ()["searchid " ]
139+ assert resp .json ()["id " ]
108140
109- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" )
141+ resp = httpx .get (f"{ raster_endpoint } /searches /list" )
110142 assert resp .headers ["content-type" ] == "application/json"
111143 assert resp .status_code == 200
112144 assert (
@@ -122,9 +154,11 @@ def test_mosaic_search():
122154 assert len (links ) == 2
123155 assert links [0 ]["rel" ] == "self"
124156 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"
126158
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+ )
128162 assert resp .status_code == 200
129163 assert resp .json ()["context" ]["matched" ] > 10
130164 assert resp .json ()["context" ]["limit" ] == 1
@@ -133,33 +167,33 @@ def test_mosaic_search():
133167 links = resp .json ()["links" ]
134168 assert len (links ) == 3
135169 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"
137171 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"
139173 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"
141175
142176 # 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" })
144178 assert resp .status_code == 200
145179 assert resp .json ()["context" ]["matched" ] == 7
146180 assert resp .json ()["context" ]["limit" ] == 10
147181 assert resp .json ()["context" ]["returned" ] == 7
148182
149183 # 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" })
151185 assert resp .status_code == 200
152186
153- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" , params = {"sortby" : "usecount" })
187+ resp = httpx .get (f"{ raster_endpoint } /searches /list" , params = {"sortby" : "usecount" })
154188 assert resp .status_code == 200
155189
156- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" , params = {"sortby" : "-owner" })
190+ resp = httpx .get (f"{ raster_endpoint } /searches /list" , params = {"sortby" : "-owner" })
157191 assert resp .status_code == 200
158192 assert (
159193 "owner" not in resp .json ()["searches" ][0 ]["search" ]["metadata" ]
160194 ) # some mosaic don't have owners
161195
162- resp = httpx .get (f"{ raster_endpoint } /mosaic /list" , params = {"sortby" : "owner" })
196+ resp = httpx .get (f"{ raster_endpoint } /searches /list" , params = {"sortby" : "owner" })
163197 assert resp .status_code == 200
164198 assert "owner" in resp .json ()["searches" ][0 ]["search" ]["metadata" ]
165199
@@ -201,3 +235,15 @@ def test_collections():
201235 collections = resp .json ()
202236 assert len (collections ) == 1
203237 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