22from fastapi import status
33from fastapi .testclient import TestClient
44
5- from .utils import find_link
6-
75
86def test_products_response (stapi_client : TestClient ):
97 res = stapi_client .get ("/products" )
@@ -21,17 +19,22 @@ def test_products_response(stapi_client: TestClient):
2119def test_product_response_self_link (
2220 product_id : str ,
2321 stapi_client : TestClient ,
24- url_for ,
22+ assert_link ,
2523):
2624 res = stapi_client .get (f"/products/{ product_id } " )
2725 assert res .status_code == status .HTTP_200_OK
2826 assert res .headers ["Content-Type" ] == "application/json"
2927
30- data = res .json ()
31- link = find_link (data ["links" ], "self" )
32- assert link , "GET /products Link[rel=self] should exist"
33- assert link ["type" ] == "application/json"
34- assert link ["href" ] == url_for (f"/products/{ product_id } " )
28+ body = res .json ()
29+
30+ url = "GET /products"
31+ assert_link (url , body , "self" , f"/products/{ product_id } " )
32+ assert_link (url , body , "constraints" , f"/products/{ product_id } /constraints" )
33+ assert_link (
34+ url , body , "order-parameters" , f"/products/{ product_id } /order-parameters"
35+ )
36+ assert_link (url , body , "opportunities" , f"/products/{ product_id } /opportunities" )
37+ assert_link (url , body , "create-order" , f"/products/{ product_id } /order" )
3538
3639
3740@pytest .mark .parametrize ("product_id" , ["test-spotlight" ])
@@ -43,7 +46,21 @@ def test_product_constraints_response(
4346 assert res .status_code == status .HTTP_200_OK
4447 assert res .headers ["Content-Type" ] == "application/json"
4548
46- data = res .json ()
47- assert "properties" in data
48- assert "datetime" in data ["properties" ]
49- assert "off_nadir" in data ["properties" ]
49+ json_schema = res .json ()
50+ assert "properties" in json_schema
51+ assert "datetime" in json_schema ["properties" ]
52+ assert "off_nadir" in json_schema ["properties" ]
53+
54+
55+ @pytest .mark .parametrize ("product_id" , ["test-spotlight" ])
56+ def test_product_order_parameters_response (
57+ product_id : str ,
58+ stapi_client : TestClient ,
59+ ):
60+ res = stapi_client .get (f"/products/{ product_id } /order-parameters" )
61+ assert res .status_code == status .HTTP_200_OK
62+ assert res .headers ["Content-Type" ] == "application/json"
63+
64+ json_schema = res .json ()
65+ assert "properties" in json_schema
66+ assert "delivery_mechanism" in json_schema ["properties" ]
0 commit comments