Skip to content

Commit 4ee5b3b

Browse files
authored
add method POST to create-order link (#145)
* add method POST to create-order link
1 parent 45fd13b commit 4ee5b3b

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## unreleased
99

10+
### Fixed
11+
12+
- Add parameter method as "POST" to create-order link
13+
1014
## Added
1115

1216
- Add constants for route names to be used in link href generation

src/stapi_fastapi/routers/product_router.py

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def get_product(self, request: Request) -> Product:
210210
),
211211
rel="create-order",
212212
type=TYPE_JSON,
213+
method="POST",
213214
),
214215
]
215216

tests/conftest.py

+3
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,14 @@ def _assert_link(
143143
rel: str,
144144
path: str,
145145
media_type: str = "application/json",
146+
method: str | None = None,
146147
):
147148
link = find_link(body["links"], rel)
148149
assert link, f"{req} Link[rel={rel}] should exist"
149150
assert link["type"] == media_type
150151
assert link["href"] == url_for(path)
152+
if method:
153+
assert link["method"] == method
151154

152155
return _assert_link
153156

tests/test_opportunity.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ def test_search_opportunities_response(
2727
except Exception as _:
2828
pytest.fail("response is not an opportunity collection")
2929

30-
assert_link(f"POST {url}", body, "create-order", f"/products/{product_id}/orders")
30+
assert_link(
31+
f"POST {url}",
32+
body,
33+
"create-order",
34+
f"/products/{product_id}/orders",
35+
method="POST",
36+
)
3137

3238

3339
@pytest.mark.parametrize("limit", [0, 1, 2, 4])

tests/test_opportunity_async.py

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def test_async_opportunity_search_to_completion(
205205
rel="create-order",
206206
href=url_for(f"/products/{product_id}/orders"),
207207
body=search_record.opportunity_request.model_dump(),
208+
method="POST",
208209
)
209210
)
210211
collection.links.append(

tests/test_product.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ def test_product_response_self_link(
3838
url, body, "order-parameters", f"/products/{product_id}/order-parameters"
3939
)
4040
assert_link(url, body, "opportunities", f"/products/{product_id}/opportunities")
41-
assert_link(url, body, "create-order", f"/products/{product_id}/orders")
41+
assert_link(
42+
url, body, "create-order", f"/products/{product_id}/orders", method="POST"
43+
)
4244

4345

4446
@pytest.mark.parametrize("product_id", ["test-spotlight"])
@@ -100,6 +102,7 @@ def test_get_products_pagination(
100102
"href": f"http://stapiserver/products/{product_id}/orders",
101103
"rel": "create-order",
102104
"type": "application/json",
105+
"method": "POST",
103106
},
104107
{
105108
"href": f"http://stapiserver/products/{product_id}/opportunities",

0 commit comments

Comments
 (0)