Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## unreleased

### Fixed

- Add parameter method as "POST" to create-order link

## [v0.6.0] - 2025-02-11

### Added
Expand Down
1 change: 1 addition & 0 deletions src/stapi_fastapi/routers/product_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def get_product(self, request: Request) -> Product:
),
rel="create-order",
type=TYPE_JSON,
method="POST",
),
]

Expand Down
3 changes: 3 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ def _assert_link(
rel: str,
path: str,
media_type: str = "application/json",
method: str | None = None,
):
link = find_link(body["links"], rel)
assert link, f"{req} Link[rel={rel}] should exist"
assert link["type"] == media_type
assert link["href"] == url_for(path)
if method:
assert link["method"] == method

return _assert_link

Expand Down
8 changes: 7 additions & 1 deletion tests/test_opportunity.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ def test_search_opportunities_response(
except Exception as _:
pytest.fail("response is not an opportunity collection")

assert_link(f"POST {url}", body, "create-order", f"/products/{product_id}/orders")
assert_link(
f"POST {url}",
body,
"create-order",
f"/products/{product_id}/orders",
method="POST",
)


@pytest.mark.parametrize("limit", [0, 1, 2, 4])
Expand Down
1 change: 1 addition & 0 deletions tests/test_opportunity_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def test_async_opportunity_search_to_completion(
rel="create-order",
href=url_for(f"/products/{product_id}/orders"),
body=search_record.opportunity_request.model_dump(),
method="POST",
)
)
collection.links.append(
Expand Down
5 changes: 4 additions & 1 deletion tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def test_product_response_self_link(
url, body, "order-parameters", f"/products/{product_id}/order-parameters"
)
assert_link(url, body, "opportunities", f"/products/{product_id}/opportunities")
assert_link(url, body, "create-order", f"/products/{product_id}/orders")
assert_link(
url, body, "create-order", f"/products/{product_id}/orders", method="POST"
)


@pytest.mark.parametrize("product_id", ["test-spotlight"])
Expand Down Expand Up @@ -100,6 +102,7 @@ def test_get_products_pagination(
"href": f"http://stapiserver/products/{product_id}/orders",
"rel": "create-order",
"type": "application/json",
"method": "POST",
},
{
"href": f"http://stapiserver/products/{product_id}/opportunities",
Expand Down