Skip to content

Commit 6c31181

Browse files
giancarloromeomrnicegyu11
authored andcommitted
🐛 Clean Pydantic's UserWarnings (ITISFoundation#7324)
1 parent cfa10c0 commit 6c31181

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

packages/pytest-simcore/src/pytest_simcore/services_api_mocks_for_aiohttp_clients.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def create_computation_cb(url, **kwargs) -> CallbackResult:
9393
"62237c33-8d6c-4709-aa92-c3cf693dd6d2",
9494
"0bdf824f-57cb-4e38-949e-fd12c184f000",
9595
]
96-
node_states[node_id] = {"state": {"modified": True, "dependencies": []}}
96+
node_states[node_id] = {"modified": True, "dependencies": []}
9797
node_states["62237c33-8d6c-4709-aa92-c3cf693dd6d2"] = {
9898
"modified": True,
9999
"dependencies": ["2f493631-30b4-4ad8-90f2-a74e4b46fe73"],
@@ -105,10 +105,15 @@ def create_computation_cb(url, **kwargs) -> CallbackResult:
105105
"62237c33-8d6c-4709-aa92-c3cf693dd6d2",
106106
],
107107
}
108-
returned_computation = ComputationTask.model_validate(
109-
ComputationTask.model_config["json_schema_extra"]["examples"][0]
110-
).model_copy(
111-
update={
108+
109+
json_schema = ComputationTask.model_json_schema()
110+
assert isinstance(json_schema["examples"], list)
111+
assert isinstance(
112+
json_schema["examples"][0], dict
113+
)
114+
computation: dict[str, Any] = json_schema["examples"][0].copy()
115+
computation.update(
116+
{
112117
"id": f"{kwargs['json']['project_id']}",
113118
"state": state,
114119
"pipeline_details": {
@@ -118,6 +123,10 @@ def create_computation_cb(url, **kwargs) -> CallbackResult:
118123
},
119124
}
120125
)
126+
returned_computation = ComputationTask.model_validate(
127+
computation
128+
)
129+
121130
return CallbackResult(
122131
status=201,
123132
# NOTE: aioresponses uses json.dump which does NOT encode serialization of UUIDs
@@ -129,15 +138,20 @@ def get_computation_cb(url, **kwargs) -> CallbackResult:
129138
state = RunningState.NOT_STARTED
130139
pipeline: dict[str, list[str]] = FULL_PROJECT_PIPELINE_ADJACENCY
131140
node_states = FULL_PROJECT_NODE_STATES
132-
assert "json_schema_extra" in ComputationGet.model_config
133-
assert isinstance(ComputationGet.model_config["json_schema_extra"], dict)
141+
142+
json_schema = ComputationGet.model_json_schema()
134143
assert isinstance(
135-
ComputationGet.model_config["json_schema_extra"]["examples"], list
144+
json_schema["examples"], list
136145
)
137-
returned_computation = ComputationGet.model_validate(
138-
ComputationGet.model_config["json_schema_extra"]["examples"][0]
139-
).model_copy(
140-
update={
146+
assert isinstance(
147+
json_schema["examples"][0], dict
148+
)
149+
150+
computation: dict[str, Any] = json_schema[
151+
"examples"
152+
][0].copy()
153+
computation.update(
154+
{
141155
"id": Path(url.path).name,
142156
"state": state,
143157
"pipeline_details": {
@@ -147,6 +161,7 @@ def get_computation_cb(url, **kwargs) -> CallbackResult:
147161
},
148162
}
149163
)
164+
returned_computation = ComputationGet.model_validate(computation)
150165

151166
return CallbackResult(
152167
status=200,

services/web/server/tests/unit/with_dbs/01/test_director_v2_handlers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ async def test_start_partial_computation(
5858
project_id: ProjectID,
5959
user_role: UserRole,
6060
expected: ExpectedResponse,
61+
faker: Faker,
6162
):
6263
assert client.app
6364

6465
url = client.app.router["start_computation"].url_for(project_id=f"{project_id}")
6566
rsp = await client.post(
66-
f"{url}", json={"subgraph": ["node_id1", "node_id2", "node_id498"]}
67+
f"{url}", json={"subgraph": [faker.uuid4(), faker.uuid4(), faker.uuid4()]}
6768
)
6869
data, error = await assert_status(
6970
rsp,

0 commit comments

Comments
 (0)