77import pytest
88from aiohttp import web
99from aiohttp .test_utils import TestClient , make_mocked_request
10- from common_library .json_serialization import json_dumps
1110from models_library .products import ProductName
1211from pytest_mock import MockerFixture , MockType
1312from servicelib .rest_constants import X_PRODUCT_NAME_HEADER
@@ -74,13 +73,11 @@ async def _test_helpers_handler(request: web.Request):
7473 assert credit_price_info is None
7574
7675 return web .json_response (
77- json_dumps (
78- {
79- "current_product" : current_product ,
80- "get_producproduct_namet_name" : product_name ,
81- "credit_price_info" : credit_price_info ,
82- }
83- )
76+ {
77+ "current_product" : current_product .model_dump (mode = "json" ),
78+ "product_name" : product_name ,
79+ "credit_price_info" : credit_price_info ,
80+ }
8481 )
8582
8683
@@ -94,7 +91,7 @@ async def test_request_helpers(client: TestClient, default_product_name: Product
9491 assert resp .ok , f"Got { await resp .text ()} "
9592
9693 got = await resp .json ()
97- assert got ["current_product " ] == default_product_name
94+ assert got ["product_name " ] == default_product_name
9895
9996
10097async def _test_product_template_handler (request : web .Request ):
@@ -128,10 +125,11 @@ async def _test_product_template_handler(request: web.Request):
128125 )
129126 assert got == template_path
130127
131- path = await products_web .get_product_template_path (
132- request , filename = "invalid-template-name.jinja"
133- )
134- assert path
128+ with pytest .raises (ValueError , match = "not part of the templates/common" ):
129+ await products_web .get_product_template_path (
130+ request , filename = "invalid-template-name.jinja"
131+ )
132+
135133 return web .json_response ()
136134
137135
0 commit comments