Skip to content

Commit 36f0355

Browse files
committed
@pcrespov review: use pydantic examples
1 parent fab15fc commit 36f0355

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

services/clusters-keeper/tests/unit/test_utils_clusters.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# pylint: disable=unused-argument
33
# pylint: disable=unused-variable
44

5+
import random
56
import re
67
import subprocess
78
from collections.abc import Callable
@@ -16,15 +17,14 @@
1617
EC2InstanceData,
1718
)
1819
from common_library.json_serialization import json_dumps
19-
from common_library.serialization import model_dump_with_secrets
2020
from faker import Faker
2121
from models_library.api_schemas_clusters_keeper.clusters import ClusterState
2222
from models_library.clusters import (
2323
ClusterAuthentication,
2424
NoAuthentication,
2525
TLSAuthentication,
2626
)
27-
from pydantic import ByteSize, SecretStr, TypeAdapter
27+
from pydantic import ByteSize, TypeAdapter
2828
from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict
2929
from settings_library.rabbit import RabbitSettings
3030
from simcore_service_clusters_keeper.core.settings import ApplicationSettings
@@ -207,20 +207,14 @@ def rabbitmq_settings_fixture(
207207
) -> RabbitSettings | None:
208208
if request.param == "custom":
209209
# Create random RabbitMQ settings using faker
210-
custom_rabbit_settings = RabbitSettings(
211-
RABBIT_HOST=faker.hostname(),
212-
RABBIT_PORT=faker.port_number(),
213-
RABBIT_SECURE=faker.boolean(),
214-
RABBIT_USER=faker.user_name(),
215-
RABBIT_PASSWORD=SecretStr(faker.password()),
210+
custom_rabbit_settings = random.choice( # noqa: S311
211+
RabbitSettings.model_json_schema()["examples"]
216212
)
217213
monkeypatch.setenv(
218-
"PRIMARY_EC2_INSTANCES_RABBIT",
219-
json_dumps(
220-
model_dump_with_secrets(custom_rabbit_settings, show_secrets=True)
221-
),
214+
"PRIMARY_EC2_INSTANCES_RABBIT", json_dumps(custom_rabbit_settings)
222215
)
223-
return custom_rabbit_settings
216+
return RabbitSettings.model_validate(custom_rabbit_settings)
217+
assert request.param == "default"
224218
return enabled_rabbitmq
225219

226220

0 commit comments

Comments
 (0)