Skip to content

Commit 968be95

Browse files
committed
pre-commit.
1 parent f93c04c commit 968be95

File tree

1 file changed

+60
-25
lines changed

1 file changed

+60
-25
lines changed

stac_fastapi/tests/api/test_api.py

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ async def test_get_search_content_type(app_client, ctx):
6464
@pytest.mark.asyncio
6565
async def test_api_headers(app_client):
6666
resp = await app_client.get("/api")
67-
assert resp.headers["Content-Type"] == "application/vnd.oai.openapi+json;version=3.0"
67+
assert (
68+
resp.headers["Content-Type"] == "application/vnd.oai.openapi+json;version=3.0"
69+
)
6870
assert resp.status_code == 200
6971

7072

@@ -107,7 +109,9 @@ async def test_app_context_results(app_client, txn_client, ctx, load_test_data):
107109
await create_collection(txn_client, test_collection)
108110
await create_item(txn_client, test_item)
109111

110-
resp = await app_client.get(f"/collections/{test_collection['id']}/items/{test_item['id']}")
112+
resp = await app_client.get(
113+
f"/collections/{test_collection['id']}/items/{test_item['id']}"
114+
)
111115
assert resp.status_code == 200
112116
resp_json = resp.json()
113117
assert resp_json["id"] == test_item["id"]
@@ -157,7 +161,9 @@ async def test_app_fields_extension_query(app_client, ctx, txn_client):
157161

158162
@pytest.mark.asyncio
159163
async def test_app_fields_extension_no_properties_get(app_client, ctx, txn_client):
160-
resp = await app_client.get("/search", params={"collections": ["test-collection"], "fields": "-properties"})
164+
resp = await app_client.get(
165+
"/search", params={"collections": ["test-collection"], "fields": "-properties"}
166+
)
161167
assert resp.status_code == 200
162168
resp_json = resp.json()
163169
assert "properties" not in resp_json["features"][0]
@@ -188,13 +194,20 @@ async def test_app_fields_extension_no_null_fields(app_client, ctx, txn_client):
188194
for link in feature["links"]:
189195
assert all(a not in link or link[a] is not None for a in ("title", "asset"))
190196
for asset in feature["assets"]:
191-
assert all(a not in asset or asset[a] is not None for a in ("start_datetime", "created"))
197+
assert all(
198+
a not in asset or asset[a] is not None
199+
for a in ("start_datetime", "created")
200+
)
192201

193202

194203
@pytest.mark.asyncio
195-
async def test_app_fields_extension_return_all_properties(app_client, ctx, txn_client, load_test_data):
204+
async def test_app_fields_extension_return_all_properties(
205+
app_client, ctx, txn_client, load_test_data
206+
):
196207
item = load_test_data("test_item.json")
197-
resp = await app_client.get("/search", params={"collections": ["test-collection"], "fields": "properties"})
208+
resp = await app_client.get(
209+
"/search", params={"collections": ["test-collection"], "fields": "properties"}
210+
)
198211
assert resp.status_code == 200
199212
resp_json = resp.json()
200213
feature = resp_json["features"][0]
@@ -232,7 +245,9 @@ async def test_app_query_extension_gte(app_client, ctx):
232245

233246
@pytest.mark.asyncio
234247
async def test_app_query_extension_limit_lt0(app_client):
235-
assert (await app_client.post("/search", json={"query": {}, "limit": -1})).status_code == 400
248+
assert (
249+
await app_client.post("/search", json={"query": {}, "limit": -1})
250+
).status_code == 400
236251

237252

238253
@pytest.mark.skip(reason="removal of context extension")
@@ -256,10 +271,12 @@ async def test_app_sort_extension_get_asc(app_client, txn_client, ctx):
256271

257272
second_item = dict(first_item)
258273
second_item["id"] = "another-item"
259-
another_item_date = datetime.strptime(first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ") - timedelta(
260-
days=1
274+
another_item_date = datetime.strptime(
275+
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
276+
) - timedelta(days=1)
277+
second_item["properties"]["datetime"] = another_item_date.strftime(
278+
"%Y-%m-%dT%H:%M:%SZ"
261279
)
262-
second_item["properties"]["datetime"] = another_item_date.strftime("%Y-%m-%dT%H:%M:%SZ")
263280

264281
await create_item(txn_client, second_item)
265282

@@ -276,10 +293,12 @@ async def test_app_sort_extension_get_desc(app_client, txn_client, ctx):
276293

277294
second_item = dict(first_item)
278295
second_item["id"] = "another-item"
279-
another_item_date = datetime.strptime(first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ") - timedelta(
280-
days=1
296+
another_item_date = datetime.strptime(
297+
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
298+
) - timedelta(days=1)
299+
second_item["properties"]["datetime"] = another_item_date.strftime(
300+
"%Y-%m-%dT%H:%M:%SZ"
281301
)
282-
second_item["properties"]["datetime"] = another_item_date.strftime("%Y-%m-%dT%H:%M:%SZ")
283302

284303
await create_item(txn_client, second_item)
285304

@@ -296,10 +315,12 @@ async def test_app_sort_extension_post_asc(app_client, txn_client, ctx):
296315

297316
second_item = dict(first_item)
298317
second_item["id"] = "another-item"
299-
another_item_date = datetime.strptime(first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ") - timedelta(
300-
days=1
318+
another_item_date = datetime.strptime(
319+
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
320+
) - timedelta(days=1)
321+
second_item["properties"]["datetime"] = another_item_date.strftime(
322+
"%Y-%m-%dT%H:%M:%SZ"
301323
)
302-
second_item["properties"]["datetime"] = another_item_date.strftime("%Y-%m-%dT%H:%M:%SZ")
303324

304325
await create_item(txn_client, second_item)
305326

@@ -320,10 +341,12 @@ async def test_app_sort_extension_post_desc(app_client, txn_client, ctx):
320341

321342
second_item = dict(first_item)
322343
second_item["id"] = "another-item"
323-
another_item_date = datetime.strptime(first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ") - timedelta(
324-
days=1
344+
another_item_date = datetime.strptime(
345+
first_item["properties"]["datetime"], "%Y-%m-%dT%H:%M:%SZ"
346+
) - timedelta(days=1)
347+
second_item["properties"]["datetime"] = another_item_date.strftime(
348+
"%Y-%m-%dT%H:%M:%SZ"
325349
)
326-
second_item["properties"]["datetime"] = another_item_date.strftime("%Y-%m-%dT%H:%M:%SZ")
327350
await create_item(txn_client, second_item)
328351

329352
params = {
@@ -350,7 +373,9 @@ async def test_search_invalid_date(app_client, ctx):
350373

351374
@pytest.mark.asyncio
352375
async def test_search_point_intersects_get(app_client, ctx):
353-
resp = await app_client.get('/search?intersects={"type":"Point","coordinates":[150.04,-33.14]}')
376+
resp = await app_client.get(
377+
'/search?intersects={"type":"Point","coordinates":[150.04,-33.14]}'
378+
)
354379

355380
assert resp.status_code == 200
356381
resp_json = resp.json()
@@ -659,11 +684,15 @@ async def test_patch_json_item(app_client, ctx):
659684
"properties": {"hello": "world", "proj:epsg": 1000, "landsat:column": None},
660685
}
661686

662-
resp = await app_client.patch(f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}", json=data)
687+
resp = await app_client.patch(
688+
f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}", json=data
689+
)
663690

664691
assert resp.status_code == 200
665692

666-
new_resp = await app_client.get(f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}")
693+
new_resp = await app_client.get(
694+
f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}"
695+
)
667696

668697
assert new_resp.status_code == 200
669698

@@ -693,7 +722,9 @@ async def test_patch_operations_item(app_client, ctx):
693722

694723
assert resp.status_code == 200
695724

696-
new_resp = await app_client.get(f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}")
725+
new_resp = await app_client.get(
726+
f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}"
727+
)
697728

698729
assert new_resp.status_code == 200
699730

@@ -736,12 +767,16 @@ async def test_search_line_string_intersects(app_client, ctx):
736767
(21474836470, 1), # Above Int Limit
737768
],
738769
)
739-
async def test_big_int_eo_search(app_client, txn_client, test_item, test_collection, value, expected):
770+
async def test_big_int_eo_search(
771+
app_client, txn_client, test_item, test_collection, value, expected
772+
):
740773
random_str = "".join(random.choice("abcdef") for _ in range(5))
741774
collection_id = f"test-collection-eo-{random_str}"
742775

743776
test_collection["id"] = collection_id
744-
test_collection["stac_extensions"] = ["https://stac-extensions.github.io/eo/v2.0.0/schema.json"]
777+
test_collection["stac_extensions"] = [
778+
"https://stac-extensions.github.io/eo/v2.0.0/schema.json"
779+
]
745780

746781
test_item["collection"] = collection_id
747782
test_item["stac_extensions"] = test_collection["stac_extensions"]

0 commit comments

Comments
 (0)