Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit db815d1

Browse files
committed
adds test for get_constraints
1 parent 1adf323 commit db815d1

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/stapi_fastapi/routers/product_router.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ async def get_product_constraints(self: Self, request: Request) -> JsonSchemaMod
105105
"""
106106
Return supported constraints of a specific product
107107
"""
108-
return {
109-
"product.id": self.product.product.id,
110-
"constraints": self.product.constraints,
111-
}
108+
return self.product.constraints
112109

113110
async def create_order(
114111
self, payload: OpportunityRequest, request: Request

tests/product_test.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
from warnings import warn
32

43
import pytest
@@ -28,7 +27,6 @@ def test_product_response_self_link(
2827
url_for,
2928
):
3029
res = stapi_client.get(f"/products/{product_id}")
31-
print(json.dumps(res.json(), indent=4))
3230
assert res.status_code == status.HTTP_200_OK
3331
assert res.headers["Content-Type"] == "application/json"
3432

@@ -39,3 +37,18 @@ def test_product_response_self_link(
3937
else:
4038
assert link["type"] == "application/json"
4139
assert link["href"] == url_for(f"/products/{product_id}")
40+
41+
42+
@pytest.mark.parametrize("product_id", ["test-spotlight"])
43+
def test_product_constraints_response(
44+
product_id: str,
45+
stapi_client: TestClient,
46+
):
47+
res = stapi_client.get(f"/products/{product_id}/constraints")
48+
assert res.status_code == status.HTTP_200_OK
49+
assert res.headers["Content-Type"] == "application/json"
50+
51+
data = res.json()
52+
assert "properties" in data
53+
assert "datetime" in data["properties"]
54+
assert "off_nadir" in data["properties"]

0 commit comments

Comments
 (0)