|
1 | 1 | # Copyright 2023 ACSONE SA/NV |
2 | 2 | # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
| 3 | +from fastapi.exceptions import ResponseValidationError |
3 | 4 | from requests import Response |
4 | 5 |
|
5 | 6 | from odoo.tests.common import tagged |
6 | 7 |
|
7 | | -from fastapi.exceptions import ResponseValidationError |
8 | | - |
9 | 8 | from .common import FastAPITransactionCase |
10 | 9 | from .routers import demo_pydantic_router |
11 | 10 | from .schemas import PrivateCustomer, PrivateUser, User |
@@ -87,7 +86,7 @@ def test_post_user(self): |
87 | 86 |
|
88 | 87 | with self._create_test_client(router=demo_pydantic_router) as test_client: |
89 | 88 | response: Response = test_client.post( |
90 | | - "/post_user", content=pydantic_data.model_dump_json() |
| 89 | + "/post_user", json=pydantic_data.model_dump() |
91 | 90 | ) |
92 | 91 | self.assertEqual(response.status_code, 200) |
93 | 92 | res = response.json() |
@@ -115,7 +114,7 @@ def test_post_private_user(self): |
115 | 114 |
|
116 | 115 | with self._create_test_client(router=demo_pydantic_router) as test_client: |
117 | 116 | response: Response = test_client.post( |
118 | | - "/post_private_user", content=pydantic_data.model_dump_json() |
| 117 | + "/post_private_user", json=pydantic_data.model_dump() |
119 | 118 | ) |
120 | 119 | self.assertEqual(response.status_code, 200) |
121 | 120 | user = response.json() |
@@ -143,7 +142,7 @@ def test_post_private_user_generic(self): |
143 | 142 |
|
144 | 143 | with self._create_test_client(router=demo_pydantic_router) as test_client: |
145 | 144 | response: Response = test_client.post( |
146 | | - "/post_private_user_generic", content=pydantic_data.model_dump_json() |
| 145 | + "/post_private_user_generic", json=pydantic_data.model_dump() |
147 | 146 | ) |
148 | 147 | self.assertEqual(response.status_code, 200) |
149 | 148 | res = response.json() |
@@ -206,5 +205,6 @@ def test_extra_forbid_response_fails(self): |
206 | 205 | self._create_test_client(router=demo_pydantic_router) as test_client, |
207 | 206 | ): |
208 | 207 | test_client.post( |
209 | | - "/post_private_customer", content=pydantic_data.model_dump_json() |
| 208 | + "/post_private_customer", |
| 209 | + json=pydantic_data.model_dump(), |
210 | 210 | ) |
0 commit comments