|
7 | 7 | from typing import Any, AsyncIterator, Callable, get_args |
8 | 8 | from unittest import mock |
9 | 9 |
|
| 10 | +from common_library.json_serialization import json_dumps |
| 11 | +from common_library.serialization import model_dump_with_secrets |
10 | 12 | import pytest |
11 | 13 | from _dask_helpers import DaskGatewayServer |
12 | 14 | from distributed.deploy.spec import SpecCluster |
@@ -126,10 +128,14 @@ def creator(): |
126 | 128 | ) |
127 | 129 | monkeypatch.setenv( |
128 | 130 | "COMPUTATIONAL_BACKEND_DEFAULT_CLUSTER_AUTH", |
129 | | - SimpleAuthentication( |
130 | | - username=faker.user_name(), |
131 | | - password=SecretStr(local_dask_gateway_server.password), |
132 | | - ).json(encoder=create_json_encoder_wo_secrets(SimpleAuthentication)), |
| 131 | + json_dumps( |
| 132 | + model_dump_with_secrets( |
| 133 | + SimpleAuthentication( |
| 134 | + username=faker.user_name(), |
| 135 | + password=SecretStr(local_dask_gateway_server.password), |
| 136 | + ), show_secrets=True |
| 137 | + ) |
| 138 | + ) |
133 | 139 | ) |
134 | 140 |
|
135 | 141 | return creator |
@@ -194,11 +200,11 @@ async def test_dask_clients_pool_acquisition_creates_client_on_demand( |
194 | 200 | cluster_type=ClusterTypeInModel.ON_PREMISE, |
195 | 201 | ) |
196 | 202 | ) |
197 | | - async with clients_pool.acquire(cluster) as dask_client: |
| 203 | + async with clients_pool.acquire(cluster): |
198 | 204 | # on start it is created |
199 | 205 | mocked_dask_client.create.assert_has_calls(mocked_creation_calls) |
200 | 206 |
|
201 | | - async with clients_pool.acquire(cluster) as dask_client: |
| 207 | + async with clients_pool.acquire(cluster): |
202 | 208 | # the connection already exists, so there is no new call to create |
203 | 209 | mocked_dask_client.create.assert_has_calls(mocked_creation_calls) |
204 | 210 |
|
@@ -278,5 +284,5 @@ def just_a_quick_fct(x, y): |
278 | 284 | ) |
279 | 285 | future = dask_client.backend.client.submit(just_a_quick_fct, 12, 23) |
280 | 286 | assert future |
281 | | - result = await future.result(timeout=10) # type: ignore |
| 287 | + result = await future.result(timeout=10) |
282 | 288 | assert result == 35 |
0 commit comments