stac-fastapi.extensions 2.5.2__tar.gz → 2.5.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/PKG-INFO +1 -1
  2. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/transaction.py +8 -1
  3. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/version.py +1 -1
  4. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi.extensions.egg-info/PKG-INFO +1 -1
  5. stac_fastapi_extensions-2.5.4/tests/test_transaction.py +180 -0
  6. stac_fastapi_extensions-2.5.2/tests/test_transaction.py +0 -121
  7. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/README.md +0 -0
  8. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/setup.cfg +0 -0
  9. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/setup.py +0 -0
  10. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/__init__.py +0 -0
  11. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/__init__.py +0 -0
  12. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/context.py +0 -0
  13. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/fields/__init__.py +0 -0
  14. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/fields/fields.py +0 -0
  15. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/fields/request.py +0 -0
  16. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/filter/__init__.py +0 -0
  17. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/filter/filter.py +0 -0
  18. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/filter/request.py +0 -0
  19. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/pagination/__init__.py +0 -0
  20. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/pagination/pagination.py +0 -0
  21. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/pagination/token_pagination.py +0 -0
  22. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/query/__init__.py +0 -0
  23. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/query/query.py +0 -0
  24. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/query/request.py +0 -0
  25. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/sort/__init__.py +0 -0
  26. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/sort/request.py +0 -0
  27. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/core/sort/sort.py +0 -0
  28. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/third_party/__init__.py +0 -0
  29. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi/extensions/third_party/bulk_transactions.py +0 -0
  30. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi.extensions.egg-info/SOURCES.txt +0 -0
  31. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi.extensions.egg-info/dependency_links.txt +0 -0
  32. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi.extensions.egg-info/not-zip-safe +0 -0
  33. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi.extensions.egg-info/requires.txt +0 -0
  34. {stac_fastapi_extensions-2.5.2 → stac_fastapi_extensions-2.5.4}/stac_fastapi.extensions.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stac-fastapi.extensions
3
- Version: 2.5.2
3
+ Version: 2.5.4
4
4
  Summary: An implementation of STAC API based on the FastAPI framework.
5
5
  Home-page: https://github.com/stac-utils/stac-fastapi
6
6
  Author: Arturo Engineering
@@ -31,6 +31,13 @@ class PutItem(ItemUri):
31
31
  item: stac_types.Item = attr.ib(default=Body(None))
32
32
 
33
33
 
34
+ @attr.s
35
+ class PutCollection(CollectionUri):
36
+ """Update Collection."""
37
+
38
+ collection: stac_types.Collection = attr.ib(default=Body(None))
39
+
40
+
34
41
  @attr.s
35
42
  class TransactionExtension(ApiExtension):
36
43
  """Transaction Extension.
@@ -128,7 +135,7 @@ class TransactionExtension(ApiExtension):
128
135
  response_model_exclude_none=True,
129
136
  methods=["PUT"],
130
137
  endpoint=create_async_endpoint(
131
- self.client.update_collection, stac_types.Collection
138
+ self.client.update_collection, PutCollection
132
139
  ),
133
140
  )
134
141
 
@@ -1,2 +1,2 @@
1
1
  """Library version."""
2
- __version__ = "2.5.2"
2
+ __version__ = "2.5.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stac-fastapi.extensions
3
- Version: 2.5.2
3
+ Version: 2.5.4
4
4
  Summary: An implementation of STAC API based on the FastAPI framework.
5
5
  Home-page: https://github.com/stac-utils/stac-fastapi
6
6
  Author: Arturo Engineering
@@ -0,0 +1,180 @@
1
+ import json
2
+ from typing import Iterator, Union
3
+
4
+ import pytest
5
+ from starlette.testclient import TestClient
6
+
7
+ from stac_fastapi.api.app import StacApi
8
+ from stac_fastapi.extensions.core import TransactionExtension
9
+ from stac_fastapi.types.config import ApiSettings
10
+ from stac_fastapi.types.core import BaseCoreClient, BaseTransactionsClient
11
+ from stac_fastapi.types.stac import Collection, Item, ItemCollection
12
+
13
+
14
+ class DummyCoreClient(BaseCoreClient):
15
+ def all_collections(self, *args, **kwargs):
16
+ raise NotImplementedError
17
+
18
+ def get_collection(self, *args, **kwargs):
19
+ raise NotImplementedError
20
+
21
+ def get_item(self, *args, **kwargs):
22
+ raise NotImplementedError
23
+
24
+ def get_search(self, *args, **kwargs):
25
+ raise NotImplementedError
26
+
27
+ def post_search(self, *args, **kwargs):
28
+ raise NotImplementedError
29
+
30
+ def item_collection(self, *args, **kwargs):
31
+ raise NotImplementedError
32
+
33
+
34
+ class DummyTransactionsClient(BaseTransactionsClient):
35
+ """Dummy client returning parts of the request, rather than proper STAC items."""
36
+
37
+ def create_item(self, item: Union[Item, ItemCollection], **kwargs):
38
+ return {"type": item["type"]}
39
+
40
+ def update_item(self, collection_id: str, item_id: str, item: Item, **kwargs):
41
+ return {
42
+ "path_collection_id": collection_id,
43
+ "path_item_id": item_id,
44
+ "type": item["type"],
45
+ }
46
+
47
+ def delete_item(self, item_id: str, collection_id: str, **kwargs):
48
+ return {
49
+ "path_collection_id": collection_id,
50
+ "path_item_id": item_id,
51
+ }
52
+
53
+ def create_collection(self, collection: Collection, **kwargs):
54
+ return {"type": collection["type"]}
55
+
56
+ def update_collection(self, collection_id: str, collection: Collection, **kwargs):
57
+ return {"path_collection_id": collection_id, "type": collection["type"]}
58
+
59
+ def delete_collection(self, collection_id: str, **kwargs):
60
+ return {"path_collection_id": collection_id}
61
+
62
+
63
+ def test_create_item(client: TestClient, item: Item) -> None:
64
+ response = client.post("/collections/a-collection/items", content=json.dumps(item))
65
+ assert response.is_success, response.text
66
+ assert response.json()["type"] == "Feature"
67
+
68
+
69
+ def test_create_item_collection(
70
+ client: TestClient, item_collection: ItemCollection
71
+ ) -> None:
72
+ response = client.post(
73
+ "/collections/a-collection/items", content=json.dumps(item_collection)
74
+ )
75
+ assert response.is_success, response.text
76
+ assert response.json()["type"] == "FeatureCollection"
77
+
78
+
79
+ def test_update_item(client: TestClient, item: Item) -> None:
80
+ response = client.put(
81
+ "/collections/a-collection/items/an-item", content=json.dumps(item)
82
+ )
83
+ assert response.is_success, response.text
84
+ assert response.json()["path_collection_id"] == "a-collection"
85
+ assert response.json()["path_item_id"] == "an-item"
86
+ assert response.json()["type"] == "Feature"
87
+
88
+
89
+ def test_delete_item(client: TestClient) -> None:
90
+ response = client.delete("/collections/a-collection/items/an-item")
91
+ assert response.is_success, response.text
92
+ assert response.json()["path_collection_id"] == "a-collection"
93
+ assert response.json()["path_item_id"] == "an-item"
94
+
95
+
96
+ def test_create_collection(client: TestClient, collection: Collection) -> None:
97
+ response = client.post("/collections", content=json.dumps(collection))
98
+ assert response.is_success, response.text
99
+ assert response.json()["type"] == "Collection"
100
+
101
+
102
+ def test_update_collection(client: TestClient, collection: Collection) -> None:
103
+ response = client.put("/collections/a-collection", content=json.dumps(collection))
104
+ assert response.is_success, response.text
105
+ assert response.json()["path_collection_id"] == "a-collection"
106
+ assert response.json()["type"] == "Collection"
107
+
108
+
109
+ def test_delete_collection(client: TestClient, collection: Collection) -> None:
110
+ response = client.delete("/collections/a-collection")
111
+ assert response.is_success, response.text
112
+ assert response.json()["path_collection_id"] == "a-collection"
113
+
114
+
115
+ @pytest.fixture
116
+ def client(
117
+ core_client: DummyCoreClient, transactions_client: DummyTransactionsClient
118
+ ) -> Iterator[TestClient]:
119
+ settings = ApiSettings()
120
+ api = StacApi(
121
+ settings=settings,
122
+ client=core_client,
123
+ extensions=[
124
+ TransactionExtension(client=transactions_client, settings=settings),
125
+ ],
126
+ )
127
+ with TestClient(api.app) as client:
128
+ yield client
129
+
130
+
131
+ @pytest.fixture
132
+ def core_client() -> DummyCoreClient:
133
+ return DummyCoreClient()
134
+
135
+
136
+ @pytest.fixture
137
+ def transactions_client() -> DummyTransactionsClient:
138
+ return DummyTransactionsClient()
139
+
140
+
141
+ @pytest.fixture
142
+ def item_collection(item: Item) -> ItemCollection:
143
+ return {
144
+ "type": "FeatureCollection",
145
+ "features": [item],
146
+ "links": [],
147
+ "context": None,
148
+ }
149
+
150
+
151
+ @pytest.fixture
152
+ def item() -> Item:
153
+ return {
154
+ "type": "Feature",
155
+ "stac_version": "1.0.0",
156
+ "stac_extensions": [],
157
+ "id": "test_item",
158
+ "geometry": {"type": "Point", "coordinates": [-105, 40]},
159
+ "bbox": [-105, 40, -105, 40],
160
+ "properties": {},
161
+ "links": [],
162
+ "assets": {},
163
+ "collection": "test_collection",
164
+ }
165
+
166
+
167
+ @pytest.fixture
168
+ def collection() -> Collection:
169
+ return {
170
+ "type": "Collection",
171
+ "stac_version": "1.0.0",
172
+ "stac_extensions": [],
173
+ "id": "test_collection",
174
+ "extent": {
175
+ "spatial": {"bbox": [[-180, -90, 180, 90]]},
176
+ "temporal": {
177
+ "interval": [["2000-01-01T00:00:00Z", "2024-01-01T00:00:00Z"]]
178
+ },
179
+ },
180
+ }
@@ -1,121 +0,0 @@
1
- import json
2
- from typing import Iterator, Union
3
-
4
- import pytest
5
- from starlette.testclient import TestClient
6
-
7
- from stac_fastapi.api.app import StacApi
8
- from stac_fastapi.extensions.core import TransactionExtension
9
- from stac_fastapi.types.config import ApiSettings
10
- from stac_fastapi.types.core import BaseCoreClient, BaseTransactionsClient
11
- from stac_fastapi.types.stac import Item, ItemCollection
12
-
13
-
14
- class DummyCoreClient(BaseCoreClient):
15
- def all_collections(self, *args, **kwargs):
16
- raise NotImplementedError
17
-
18
- def get_collection(self, *args, **kwargs):
19
- raise NotImplementedError
20
-
21
- def get_item(self, *args, **kwargs):
22
- raise NotImplementedError
23
-
24
- def get_search(self, *args, **kwargs):
25
- raise NotImplementedError
26
-
27
- def post_search(self, *args, **kwargs):
28
- raise NotImplementedError
29
-
30
- def item_collection(self, *args, **kwargs):
31
- raise NotImplementedError
32
-
33
-
34
- class DummyTransactionsClient(BaseTransactionsClient):
35
- """Defines a pattern for implementing the STAC transaction extension."""
36
-
37
- def create_item(self, item: Union[Item, ItemCollection], *args, **kwargs):
38
- return {"created": True, "type": item["type"]}
39
-
40
- def update_item(self, *args, **kwargs):
41
- raise NotImplementedError
42
-
43
- def delete_item(self, *args, **kwargs):
44
- raise NotImplementedError
45
-
46
- def create_collection(self, *args, **kwargs):
47
- raise NotImplementedError
48
-
49
- def update_collection(self, *args, **kwargs):
50
- raise NotImplementedError
51
-
52
- def delete_collection(self, *args, **kwargs):
53
- raise NotImplementedError
54
-
55
-
56
- def test_create_item(client: TestClient, item: Item) -> None:
57
- response = client.post("/collections/a-collection/items", content=json.dumps(item))
58
- assert response.is_success, response.text
59
- assert response.json()["type"] == "Feature"
60
-
61
-
62
- def test_create_item_collection(
63
- client: TestClient, item_collection: ItemCollection
64
- ) -> None:
65
- response = client.post(
66
- "/collections/a-collection/items", content=json.dumps(item_collection)
67
- )
68
- assert response.is_success, response.text
69
- assert response.json()["type"] == "FeatureCollection"
70
-
71
-
72
- @pytest.fixture
73
- def client(
74
- core_client: DummyCoreClient, transactions_client: DummyTransactionsClient
75
- ) -> Iterator[TestClient]:
76
- settings = ApiSettings()
77
- api = StacApi(
78
- settings=settings,
79
- client=core_client,
80
- extensions=[
81
- TransactionExtension(client=transactions_client, settings=settings),
82
- ],
83
- )
84
- with TestClient(api.app) as client:
85
- yield client
86
-
87
-
88
- @pytest.fixture
89
- def core_client() -> DummyCoreClient:
90
- return DummyCoreClient()
91
-
92
-
93
- @pytest.fixture
94
- def transactions_client() -> DummyTransactionsClient:
95
- return DummyTransactionsClient()
96
-
97
-
98
- @pytest.fixture
99
- def item_collection(item: Item) -> ItemCollection:
100
- return {
101
- "type": "FeatureCollection",
102
- "features": [item],
103
- "links": [],
104
- "context": None,
105
- }
106
-
107
-
108
- @pytest.fixture
109
- def item() -> Item:
110
- return {
111
- "type": "Feature",
112
- "stac_version": "1.0.0",
113
- "stac_extensions": [],
114
- "id": "test_item",
115
- "geometry": {"type": "Point", "coordinates": [-105, 40]},
116
- "bbox": [-105, 40, -105, 40],
117
- "properties": {},
118
- "links": [],
119
- "assets": {},
120
- "collection": "test_collection",
121
- }