2
2
import uuid
3
3
from datetime import datetime , timedelta
4
4
5
+ import pytest
6
+
5
7
from ..conftest import create_collection , create_item
6
8
7
9
ROUTES = {
31
33
}
32
34
33
35
36
+ @pytest .mark .asyncio
34
37
async def test_post_search_content_type (app_client , ctx ):
35
38
params = {"limit" : 1 }
36
39
resp = await app_client .post ("/search" , json = params )
37
40
assert resp .headers ["content-type" ] == "application/geo+json"
38
41
39
42
43
+ @pytest .mark .asyncio
40
44
async def test_get_search_content_type (app_client , ctx ):
41
45
resp = await app_client .get ("/search" )
42
46
assert resp .headers ["content-type" ] == "application/geo+json"
43
47
44
48
49
+ @pytest .mark .asyncio
45
50
async def test_api_headers (app_client ):
46
51
resp = await app_client .get ("/api" )
47
52
assert (
@@ -50,11 +55,13 @@ async def test_api_headers(app_client):
50
55
assert resp .status_code == 200
51
56
52
57
58
+ @pytest .mark .asyncio
53
59
async def test_router (app ):
54
60
api_routes = set ([f"{ list (route .methods )[0 ]} { route .path } " for route in app .routes ])
55
61
assert len (api_routes - ROUTES ) == 0
56
62
57
63
64
+ @pytest .mark .asyncio
58
65
async def test_app_transaction_extension (app_client , ctx ):
59
66
item = copy .deepcopy (ctx .item )
60
67
item ["id" ] = str (uuid .uuid4 ())
@@ -64,6 +71,7 @@ async def test_app_transaction_extension(app_client, ctx):
64
71
await app_client .delete (f"/collections/{ item ['collection' ]} /items/{ item ['id' ]} " )
65
72
66
73
74
+ @pytest .mark .asyncio
67
75
async def test_app_search_response (app_client , ctx ):
68
76
resp = await app_client .get ("/search" , params = {"ids" : ["test-item" ]})
69
77
assert resp .status_code == 200
@@ -75,6 +83,7 @@ async def test_app_search_response(app_client, ctx):
75
83
assert resp_json .get ("stac_extensions" ) is None
76
84
77
85
86
+ @pytest .mark .asyncio
78
87
async def test_app_context_extension (app_client , ctx , txn_client ):
79
88
test_item = ctx .item
80
89
test_item ["id" ] = "test-item-2"
@@ -108,13 +117,15 @@ async def test_app_context_extension(app_client, ctx, txn_client):
108
117
assert matched == 1
109
118
110
119
120
+ @pytest .mark .asyncio
111
121
async def test_app_fields_extension (app_client , ctx , txn_client ):
112
122
resp = await app_client .get ("/search" , params = {"collections" : ["test-collection" ]})
113
123
assert resp .status_code == 200
114
124
resp_json = resp .json ()
115
125
assert list (resp_json ["features" ][0 ]["properties" ]) == ["datetime" ]
116
126
117
127
128
+ @pytest .mark .asyncio
118
129
async def test_app_fields_extension_query (app_client , ctx , txn_client ):
119
130
resp = await app_client .post (
120
131
"/search" ,
@@ -128,6 +139,7 @@ async def test_app_fields_extension_query(app_client, ctx, txn_client):
128
139
assert list (resp_json ["features" ][0 ]["properties" ]) == ["datetime" , "proj:epsg" ]
129
140
130
141
142
+ @pytest .mark .asyncio
131
143
async def test_app_fields_extension_no_properties_get (app_client , ctx , txn_client ):
132
144
resp = await app_client .get (
133
145
"/search" , params = {"collections" : ["test-collection" ], "fields" : "-properties" }
@@ -137,6 +149,7 @@ async def test_app_fields_extension_no_properties_get(app_client, ctx, txn_clien
137
149
assert "properties" not in resp_json ["features" ][0 ]
138
150
139
151
152
+ @pytest .mark .asyncio
140
153
async def test_app_fields_extension_no_properties_post (app_client , ctx , txn_client ):
141
154
resp = await app_client .post (
142
155
"/search" ,
@@ -150,6 +163,7 @@ async def test_app_fields_extension_no_properties_post(app_client, ctx, txn_clie
150
163
assert "properties" not in resp_json ["features" ][0 ]
151
164
152
165
166
+ @pytest .mark .asyncio
153
167
async def test_app_fields_extension_return_all_properties (app_client , ctx , txn_client ):
154
168
item = ctx .item
155
169
resp = await app_client .get (
@@ -166,6 +180,7 @@ async def test_app_fields_extension_return_all_properties(app_client, ctx, txn_c
166
180
assert feature ["properties" ][expected_prop ] == expected_value
167
181
168
182
183
+ @pytest .mark .asyncio
169
184
async def test_app_query_extension_gt (app_client , ctx ):
170
185
params = {"query" : {"proj:epsg" : {"gt" : ctx .item ["properties" ]["proj:epsg" ]}}}
171
186
resp = await app_client .post ("/search" , json = params )
@@ -174,6 +189,7 @@ async def test_app_query_extension_gt(app_client, ctx):
174
189
assert len (resp_json ["features" ]) == 0
175
190
176
191
192
+ @pytest .mark .asyncio
177
193
async def test_app_query_extension_gte (app_client , ctx ):
178
194
params = {"query" : {"proj:epsg" : {"gte" : ctx .item ["properties" ]["proj:epsg" ]}}}
179
195
resp = await app_client .post ("/search" , json = params )
@@ -182,22 +198,26 @@ async def test_app_query_extension_gte(app_client, ctx):
182
198
assert len (resp .json ()["features" ]) == 1
183
199
184
200
201
+ @pytest .mark .asyncio
185
202
async def test_app_query_extension_limit_lt0 (app_client ):
186
203
assert (await app_client .post ("/search" , json = {"limit" : - 1 })).status_code == 400
187
204
188
205
206
+ @pytest .mark .asyncio
189
207
async def test_app_query_extension_limit_gt10000 (app_client ):
190
208
resp = await app_client .post ("/search" , json = {"limit" : 10001 })
191
209
assert resp .status_code == 200
192
210
assert resp .json ()["context" ]["limit" ] == 10000
193
211
194
212
213
+ @pytest .mark .asyncio
195
214
async def test_app_query_extension_limit_10000 (app_client ):
196
215
params = {"limit" : 10000 }
197
216
resp = await app_client .post ("/search" , json = params )
198
217
assert resp .status_code == 200
199
218
200
219
220
+ @pytest .mark .asyncio
201
221
async def test_app_sort_extension (app_client , txn_client , ctx ):
202
222
first_item = ctx .item
203
223
item_date = datetime .strptime (
@@ -223,6 +243,7 @@ async def test_app_sort_extension(app_client, txn_client, ctx):
223
243
assert resp_json ["features" ][1 ]["id" ] == second_item ["id" ]
224
244
225
245
246
+ @pytest .mark .asyncio
226
247
async def test_search_invalid_date (app_client , ctx ):
227
248
params = {
228
249
"datetime" : "2020-XX-01/2020-10-30" ,
@@ -233,6 +254,7 @@ async def test_search_invalid_date(app_client, ctx):
233
254
assert resp .status_code == 400
234
255
235
256
257
+ @pytest .mark .asyncio
236
258
async def test_search_point_intersects (app_client , ctx ):
237
259
point = [150.04 , - 33.14 ]
238
260
intersects = {"type" : "Point" , "coordinates" : point }
@@ -248,6 +270,7 @@ async def test_search_point_intersects(app_client, ctx):
248
270
assert len (resp_json ["features" ]) == 1
249
271
250
272
273
+ @pytest .mark .asyncio
251
274
async def test_search_point_does_not_intersect (app_client , ctx ):
252
275
point = [15.04 , - 3.14 ]
253
276
intersects = {"type" : "Point" , "coordinates" : point }
@@ -263,6 +286,7 @@ async def test_search_point_does_not_intersect(app_client, ctx):
263
286
assert len (resp_json ["features" ]) == 0
264
287
265
288
289
+ @pytest .mark .asyncio
266
290
async def test_datetime_non_interval (app_client , ctx ):
267
291
dt_formats = [
268
292
"2020-02-12T12:30:22+00:00" ,
@@ -284,6 +308,7 @@ async def test_datetime_non_interval(app_client, ctx):
284
308
assert resp_json ["features" ][0 ]["properties" ]["datetime" ][0 :19 ] == dt [0 :19 ]
285
309
286
310
311
+ @pytest .mark .asyncio
287
312
async def test_bbox_3d (app_client , ctx ):
288
313
australia_bbox = [106.343365 , - 47.199523 , 0.1 , 168.218365 , - 19.437288 , 0.1 ]
289
314
params = {
@@ -296,6 +321,7 @@ async def test_bbox_3d(app_client, ctx):
296
321
assert len (resp_json ["features" ]) == 1
297
322
298
323
324
+ @pytest .mark .asyncio
299
325
async def test_search_line_string_intersects (app_client , ctx ):
300
326
line = [[150.04 , - 33.14 ], [150.22 , - 33.89 ]]
301
327
intersects = {"type" : "LineString" , "coordinates" : line }
0 commit comments