Skip to content

Commit 9b3fa3f

Browse files
committed
run pre-commit
1 parent 854d182 commit 9b3fa3f

File tree

5 files changed

+54
-21
lines changed

5 files changed

+54
-21
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from urllib.parse import urljoin
88

99
import attr
10-
import stac_pydantic.api
1110
from fastapi import HTTPException
1211
from overrides import overrides
1312
from pydantic import ValidationError
@@ -33,8 +32,8 @@
3332
AsyncBaseTransactionsClient,
3433
)
3534
from stac_fastapi.types.links import CollectionLinks
36-
from stac_fastapi.types.stac import Collection, Collections, Item, ItemCollection
3735
from stac_fastapi.types.search import BaseSearchPostRequest
36+
from stac_fastapi.types.stac import Collection, Collections, Item, ItemCollection
3837

3938
logger = logging.getLogger(__name__)
4039

@@ -92,13 +91,13 @@ async def get_collection(self, collection_id: str, **kwargs) -> Collection:
9291

9392
@overrides
9493
async def item_collection(
95-
self,
94+
self,
9695
collection_id: str,
9796
bbox: Optional[List[NumType]] = None,
9897
datetime: Union[str, datetime_type, None] = None,
99-
limit: int = 10,
100-
token: str = None,
101-
**kwargs
98+
limit: int = 10,
99+
token: str = None,
100+
**kwargs,
102101
) -> ItemCollection:
103102
"""Read an item collection from the database."""
104103
request: Request = kwargs["request"]
@@ -294,7 +293,7 @@ async def post_search(
294293
if filter_lang in [None, FilterLang.cql2_json]:
295294
search = self.database.apply_cql2_filter(search, cql2_filter)
296295
# else:
297-
# raise Exception("CQL2-Text is not supported with POST")
296+
# raise Exception("CQL2-Text is not supported with POST")
298297

299298
sort = None
300299
if search_request.sortby:
@@ -365,7 +364,9 @@ class TransactionsClient(AsyncBaseTransactionsClient):
365364
database = DatabaseLogic()
366365

367366
@overrides
368-
async def create_item(self, collection_id: str, item: stac_types.Item, **kwargs) -> stac_types.Item:
367+
async def create_item(
368+
self, collection_id: str, item: stac_types.Item, **kwargs
369+
) -> stac_types.Item:
369370
"""Create item."""
370371
base_url = str(kwargs["request"].base_url)
371372

@@ -375,7 +376,7 @@ async def create_item(self, collection_id: str, item: stac_types.Item, **kwargs)
375376
processed_items = [
376377
bulk_client.preprocess_item(item, base_url) for item in item["features"] # type: ignore
377378
]
378-
379+
379380
await self.database.bulk_async(
380381
collection_id, processed_items, refresh=kwargs.get("refresh", False)
381382
)
@@ -387,7 +388,9 @@ async def create_item(self, collection_id: str, item: stac_types.Item, **kwargs)
387388
return item
388389

389390
@overrides
390-
async def update_item(self, collection_id: str, item_id: str, item: stac_types.Item, **kwargs) -> stac_types.Item:
391+
async def update_item(
392+
self, collection_id: str, item_id: str, item: stac_types.Item, **kwargs
393+
) -> stac_types.Item:
391394
"""Update item."""
392395
base_url = str(kwargs["request"].base_url)
393396

stac_fastapi/elasticsearch/tests/clients/test_elasticsearch.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ async def test_get_collection_items(app_client, ctx, core_client, txn_client):
9292
for _ in range(num_of_items_to_create):
9393
item = deepcopy(ctx.item)
9494
item["id"] = str(uuid.uuid4())
95-
await txn_client.create_item(collection_id=item["collection"],item=item, request=MockRequest, refresh=True)
95+
await txn_client.create_item(
96+
collection_id=item["collection"],
97+
item=item,
98+
request=MockRequest,
99+
refresh=True,
100+
)
96101

97102
fc = await core_client.item_collection(coll["id"], request=MockRequest())
98103
assert len(fc["features"]) == num_of_items_to_create + 1 # ctx.item
@@ -112,14 +117,21 @@ async def test_create_item(ctx, core_client, txn_client):
112117

113118
async def test_create_item_already_exists(ctx, txn_client):
114119
with pytest.raises(ConflictError):
115-
await txn_client.create_item(collection_id=ctx.item["collection"], item=ctx.item, request=MockRequest, refresh=True)
120+
await txn_client.create_item(
121+
collection_id=ctx.item["collection"],
122+
item=ctx.item,
123+
request=MockRequest,
124+
refresh=True,
125+
)
116126

117127

118128
async def test_update_item(ctx, core_client, txn_client):
119129
ctx.item["properties"]["foo"] = "bar"
120130
collection_id = ctx.item["collection"]
121131
item_id = ctx.item["id"]
122-
await txn_client.update_item(collection_id=collection_id, item_id=item_id, item=ctx.item, request=MockRequest)
132+
await txn_client.update_item(
133+
collection_id=collection_id, item_id=item_id, item=ctx.item, request=MockRequest
134+
)
123135

124136
updated_item = await core_client.get_item(
125137
item_id, collection_id, request=MockRequest
@@ -141,7 +153,9 @@ async def test_update_geometry(ctx, core_client, txn_client):
141153
ctx.item["geometry"]["coordinates"] = new_coordinates
142154
collection_id = ctx.item["collection"]
143155
item_id = ctx.item["id"]
144-
await txn_client.update_item(collection_id=collection_id, item_id=item_id, item=ctx.item, request=MockRequest)
156+
await txn_client.update_item(
157+
collection_id=collection_id, item_id=item_id, item=ctx.item, request=MockRequest
158+
)
145159

146160
updated_item = await core_client.get_item(
147161
item_id, collection_id, request=MockRequest

stac_fastapi/elasticsearch/tests/conftest.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,21 @@ async def create_collection(txn_client: TransactionsClient, collection: Dict) ->
9494

9595

9696
async def create_item(txn_client: TransactionsClient, item: Dict) -> None:
97-
if 'collection' in item:
98-
await txn_client.create_item(collection_id=item["collection"], item=item, request=MockRequest, refresh=True)
97+
if "collection" in item:
98+
await txn_client.create_item(
99+
collection_id=item["collection"],
100+
item=item,
101+
request=MockRequest,
102+
refresh=True,
103+
)
99104
else:
100-
await txn_client.create_item(collection_id=item['features'][0]["collection"], item=item, request=MockRequest, refresh=True)
105+
await txn_client.create_item(
106+
collection_id=item["features"][0]["collection"],
107+
item=item,
108+
request=MockRequest,
109+
refresh=True,
110+
)
111+
101112

102113
async def delete_collections_and_items(txn_client: TransactionsClient) -> None:
103114
await refresh_indices(txn_client)

stac_fastapi/elasticsearch/tests/extensions/test_filter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import json
22
import os
3-
import pytest
43
from os import listdir
54
from os.path import isfile, join
65

6+
import pytest
7+
78
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
89

910

stac_fastapi/elasticsearch/tests/resources/test_item.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ async def test_update_item_already_exists(app_client, ctx):
8080

8181
assert ctx.item["properties"]["gsd"] != 16
8282
ctx.item["properties"]["gsd"] = 16
83-
await app_client.put(f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}", json=ctx.item)
83+
await app_client.put(
84+
f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}", json=ctx.item
85+
)
8486
resp = await app_client.get(
8587
f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}"
8688
)
@@ -99,7 +101,8 @@ async def test_update_new_item(app_client, ctx):
99101

100102
# note: this endpoint is wrong in stac-fastapi -- should be /collections/{c_id}/items/{item_id}
101103
resp = await app_client.put(
102-
f"/collections/{test_item['collection']}/items/{test_item['id']}", json=test_item
104+
f"/collections/{test_item['collection']}/items/{test_item['id']}",
105+
json=test_item,
103106
)
104107
assert resp.status_code == 404
105108

@@ -229,7 +232,8 @@ async def test_item_timestamps(app_client, ctx, load_test_data):
229232
# Confirm `updated` timestamp
230233
ctx.item["properties"]["proj:epsg"] = 4326
231234
resp = await app_client.put(
232-
f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}", json=dict(ctx.item)
235+
f"/collections/{ctx.item['collection']}/items/{ctx.item['id']}",
236+
json=dict(ctx.item),
233237
)
234238
assert resp.status_code == 200
235239
updated_item = resp.json()

0 commit comments

Comments
 (0)