Skip to content

Commit 2a0ca68

Browse files
committed
fix tests
1 parent cf4d2e5 commit 2a0ca68

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

services/web/server/tests/unit/with_dbs/04/products/test_products_web.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import pytest
88
from aiohttp import web
99
from aiohttp.test_utils import TestClient, make_mocked_request
10-
from common_library.json_serialization import json_dumps
1110
from models_library.products import ProductName
1211
from pytest_mock import MockerFixture, MockType
1312
from 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

10097
async 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

Comments
 (0)