Skip to content

Commit b412576

Browse files
committed
remove PatchOperation in tests.
1 parent ca64ba3 commit b412576

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,9 @@ async def get_search(
493493
"token": token,
494494
"query": orjson.loads(query) if query else query,
495495
"q": q,
496+
"datetime": datetime,
496497
}
497498

498-
if datetime:
499-
base_args["datetime"] = self._format_datetime_range(datetime)
500-
501499
if intersects:
502500
base_args["intersects"] = orjson.loads(unquote_plus(intersects))
503501

@@ -508,7 +506,6 @@ async def get_search(
508506
]
509507

510508
if filter_expr:
511-
print("GET FE", filter_expr)
512509
base_args["filter-lang"] = "cql2-json"
513510
base_args["filter"] = orjson.loads(
514511
unquote_plus(filter_expr)

stac_fastapi/core/stac_fastapi/core/extensions/aggregation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ async def aggregate(
369369
"geometry_geohash_grid_frequency_precision": geometry_geohash_grid_frequency_precision,
370370
"geometry_geotile_grid_frequency_precision": geometry_geotile_grid_frequency_precision,
371371
"datetime_frequency_interval": datetime_frequency_interval,
372+
"datetime": datetime,
372373
}
373374

374375
if collection_id:
@@ -377,9 +378,6 @@ async def aggregate(
377378
if intersects:
378379
base_args["intersects"] = orjson.loads(unquote_plus(intersects))
379380

380-
if datetime:
381-
base_args["datetime"] = self._format_datetime_range(datetime)
382-
383381
if filter_expr:
384382
base_args["filter"] = self.get_filter(filter_expr, filter_lang)
385383
aggregate_request = EsAggregationExtensionPostRequest(**base_args)

stac_fastapi/tests/clients/test_elasticsearch.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from stac_fastapi.extensions.third_party.bulk_transactions import Items
99
from stac_fastapi.types.errors import ConflictError, NotFoundError
10-
from stac_fastapi.types.stac import PatchOperation
10+
from stac_fastapi.types.stac import PatchAddReplaceTest, PatchMoveCopy, PatchRemove
1111

1212
from ..conftest import MockRequest, create_item
1313

@@ -282,7 +282,9 @@ async def test_json_patch_item_add(ctx, core_client, txn_client):
282282
collection_id = item["collection"]
283283
item_id = item["id"]
284284
operations = [
285-
PatchOperation(**{"op": "add", "path": "properties.foo", "value": "bar"}),
285+
PatchAddReplaceTest.model_validate(
286+
{"op": "add", "path": "properties.foo", "value": "bar"}
287+
),
286288
]
287289

288290
await txn_client.json_patch_item(
@@ -305,7 +307,9 @@ async def test_json_patch_item_replace(ctx, core_client, txn_client):
305307
collection_id = item["collection"]
306308
item_id = item["id"]
307309
operations = [
308-
PatchOperation(**{"op": "replace", "path": "properties.foo", "value": 100}),
310+
PatchAddReplaceTest.model_validate(
311+
{"op": "replace", "path": "properties.foo", "value": 100}
312+
),
309313
]
310314

311315
await txn_client.json_patch_item(
@@ -328,7 +332,9 @@ async def test_json_patch_item_test(ctx, core_client, txn_client):
328332
collection_id = item["collection"]
329333
item_id = item["id"]
330334
operations = [
331-
PatchOperation(**{"op": "test", "path": "properties.foo", "value": 100}),
335+
PatchAddReplaceTest.model_validate(
336+
{"op": "test", "path": "properties.foo", "value": 100}
337+
),
332338
]
333339

334340
await txn_client.json_patch_item(
@@ -351,8 +357,8 @@ async def test_json_patch_item_move(ctx, core_client, txn_client):
351357
collection_id = item["collection"]
352358
item_id = item["id"]
353359
operations = [
354-
PatchOperation(
355-
**{"op": "move", "path": "properties.bar", "from": "properties.foo"}
360+
PatchMoveCopy.model_validate(
361+
{"op": "move", "path": "properties.bar", "from": "properties.foo"}
356362
),
357363
]
358364

@@ -377,8 +383,8 @@ async def test_json_patch_item_copy(ctx, core_client, txn_client):
377383
collection_id = item["collection"]
378384
item_id = item["id"]
379385
operations = [
380-
PatchOperation(
381-
**{"op": "copy", "path": "properties.foo", "from": "properties.bar"}
386+
PatchMoveCopy.model_validate(
387+
{"op": "copy", "path": "properties.foo", "from": "properties.bar"}
382388
),
383389
]
384390

@@ -402,8 +408,8 @@ async def test_json_patch_item_remove(ctx, core_client, txn_client):
402408
collection_id = item["collection"]
403409
item_id = item["id"]
404410
operations = [
405-
PatchOperation(**{"op": "remove", "path": "properties.foo"}),
406-
PatchOperation(**{"op": "remove", "path": "properties.bar"}),
411+
PatchRemove.model_validate({"op": "remove", "path": "properties.foo"}),
412+
PatchRemove.model_validate({"op": "remove", "path": "properties.bar"}),
407413
]
408414

409415
await txn_client.json_patch_item(
@@ -427,8 +433,8 @@ async def test_json_patch_item_test_wrong_value(ctx, core_client, txn_client):
427433
collection_id = item["collection"]
428434
item_id = item["id"]
429435
operations = [
430-
PatchOperation(
431-
**{"op": "test", "path": "properties.platform", "value": "landsat-9"}
436+
PatchAddReplaceTest.model_validate(
437+
{"op": "test", "path": "properties.platform", "value": "landsat-9"}
432438
),
433439
]
434440

@@ -450,8 +456,8 @@ async def test_json_patch_item_replace_property_does_not_exists(
450456
collection_id = item["collection"]
451457
item_id = item["id"]
452458
operations = [
453-
PatchOperation(
454-
**{"op": "replace", "path": "properties.foo", "value": "landsat-9"}
459+
PatchAddReplaceTest.model_validate(
460+
{"op": "replace", "path": "properties.foo", "value": "landsat-9"}
455461
),
456462
]
457463

@@ -473,7 +479,7 @@ async def test_json_patch_item_remove_property_does_not_exists(
473479
collection_id = item["collection"]
474480
item_id = item["id"]
475481
operations = [
476-
PatchOperation(**{"op": "remove", "path": "properties.foo"}),
482+
PatchRemove.model_validate({"op": "remove", "path": "properties.foo"}),
477483
]
478484

479485
with pytest.raises(ConflictError):
@@ -494,8 +500,8 @@ async def test_json_patch_item_move_property_does_not_exists(
494500
collection_id = item["collection"]
495501
item_id = item["id"]
496502
operations = [
497-
PatchOperation(
498-
**{"op": "move", "path": "properties.bar", "from": "properties.foo"}
503+
PatchMoveCopy.model_validate(
504+
{"op": "move", "path": "properties.bar", "from": "properties.foo"}
499505
),
500506
]
501507

@@ -517,8 +523,8 @@ async def test_json_patch_item_copy_property_does_not_exists(
517523
collection_id = item["collection"]
518524
item_id = item["id"]
519525
operations = [
520-
PatchOperation(
521-
**{"op": "copy", "path": "properties.bar", "from": "properties.foo"}
526+
PatchMoveCopy.model_validate(
527+
{"op": "copy", "path": "properties.bar", "from": "properties.foo"}
522528
),
523529
]
524530

0 commit comments

Comments
 (0)