Skip to content

Commit 6b231e0

Browse files
committed
migrations
1 parent 9c60a8b commit 6b231e0

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

services/autoscaling/tests/unit/conftest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def app_with_docker_join_drained(
173173

174174
@pytest.fixture(scope="session")
175175
def fake_ssm_settings() -> SSMSettings:
176-
return SSMSettings(**SSMSettings.Config.schema_extra["examples"][0])
176+
return SSMSettings(**SSMSettings.model_config["json_schema_extra"]["examples"][0])
177177

178178

179179
@pytest.fixture
@@ -236,7 +236,9 @@ def app_environment(
236236
"EC2_INSTANCES_ALLOWED_TYPES": json.dumps(
237237
{
238238
ec2_type_name: random.choice( # noqa: S311
239-
EC2InstanceBootSpecific.Config.schema_extra["examples"]
239+
EC2InstanceBootSpecific.model_config["json_schema_extra"][
240+
"examples"
241+
]
240242
)
241243
for ec2_type_name in aws_allowed_ec2_instance_type_names
242244
}
@@ -267,7 +269,9 @@ def mocked_ec2_instances_envs(
267269
"EC2_INSTANCES_ALLOWED_TYPES": json.dumps(
268270
{
269271
ec2_type_name: random.choice( # noqa: S311
270-
EC2InstanceBootSpecific.Config.schema_extra["examples"]
272+
EC2InstanceBootSpecific.model_config["json_schema_extra"][
273+
"examples"
274+
]
271275
)
272276
| {"ami_id": aws_ami_id}
273277
for ec2_type_name in aws_allowed_ec2_instance_type_names
@@ -762,7 +766,7 @@ def host_memory_total() -> ByteSize:
762766
def osparc_docker_label_keys(
763767
faker: Faker,
764768
) -> StandardSimcoreDockerLabels:
765-
return StandardSimcoreDockerLabels.parse_obj(
769+
return StandardSimcoreDockerLabels.model_validate(
766770
{
767771
"user_id": faker.pyint(),
768772
"project_id": faker.uuid4(),

services/autoscaling/tests/unit/test_api_health.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def test_status_no_rabbit(
4242
response = await async_client.get("/status")
4343
response.raise_for_status()
4444
assert response.status_code == status.HTTP_200_OK
45-
status_response = _StatusGet.parse_obj(response.json())
45+
status_response = _StatusGet.model_validate(response.json())
4646
assert status_response
4747

4848
assert status_response.rabbitmq.is_enabled is False
@@ -66,7 +66,7 @@ async def test_status_no_ssm(
6666
response = await async_client.get("/status")
6767
response.raise_for_status()
6868
assert response.status_code == status.HTTP_200_OK
69-
status_response = _StatusGet.parse_obj(response.json())
69+
status_response = _StatusGet.model_validate(response.json())
7070
assert status_response
7171

7272
assert status_response.rabbitmq.is_enabled is False
@@ -94,7 +94,7 @@ async def test_status(
9494
response = await async_client.get("/status")
9595
response.raise_for_status()
9696
assert response.status_code == status.HTTP_200_OK
97-
status_response = _StatusGet.parse_obj(response.json())
97+
status_response = _StatusGet.model_validate(response.json())
9898
assert status_response
9999

100100
assert status_response.rabbitmq.is_enabled is True
@@ -114,7 +114,7 @@ async def test_status(
114114
response = await async_client.get("/status")
115115
response.raise_for_status()
116116
assert response.status_code == status.HTTP_200_OK
117-
status_response = _StatusGet.parse_obj(response.json())
117+
status_response = _StatusGet.model_validate(response.json())
118118
assert status_response
119119

120120
assert status_response.rabbitmq.is_enabled is True

services/autoscaling/tests/unit/test_modules_dask.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242

4343
_authentication_types = [
4444
NoAuthentication(),
45-
TLSAuthentication.construct(**TLSAuthentication.Config.schema_extra["examples"][0]),
45+
TLSAuthentication.construct(
46+
**TLSAuthentication.model_config["json_schema_extra"]["examples"][0]
47+
),
4648
]
4749

4850

services/autoscaling/tests/unit/test_utils_docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ async def test_get_docker_swarm_join_script_returning_unexpected_command_raises(
872872

873873
def test_get_docker_login_on_start_bash_command():
874874
registry_settings = RegistrySettings(
875-
**RegistrySettings.Config.schema_extra["examples"][0]
875+
**RegistrySettings.model_config["json_schema_extra"]["examples"][0]
876876
)
877877
returned_command = get_docker_login_on_start_bash_command(registry_settings)
878878
assert (

services/autoscaling/tests/unit/test_utils_rabbitmq.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
ProgressRabbitMessageNode,
2020
ProgressType,
2121
)
22-
from pydantic import parse_obj_as
22+
from pydantic import TypeAdapter
2323
from pytest_mock.plugin import MockerFixture
2424
from servicelib.rabbitmq import BIND_TO_ALL_TOPICS, RabbitMQClient
2525
from settings_library.rabbit import RabbitSettings
@@ -79,8 +79,7 @@ async def test_post_task_log_message(
7979
"running",
8080
)
8181
assert service_with_labels.Spec
82-
service_tasks = parse_obj_as(
83-
list[Task],
82+
service_tasks = TypeAdapter(list[Task]).validate_python(
8483
await async_docker_client.tasks.list(
8584
filters={"service": service_with_labels.Spec.Name}
8685
),
@@ -104,7 +103,7 @@ async def test_post_task_log_message(
104103
messages=[f"[cluster] {log_message}"],
105104
log_level=0,
106105
)
107-
.json()
106+
.model_dump_json()
108107
.encode()
109108
)
110109
print("... message received")
@@ -126,8 +125,7 @@ async def test_post_task_log_message_does_not_raise_if_service_has_no_labels(
126125
):
127126
service_without_labels = await create_service(task_template, {}, "running")
128127
assert service_without_labels.Spec
129-
service_tasks = parse_obj_as(
130-
list[Task],
128+
service_tasks = TypeAdapter(list[Task]).validate_python(
131129
await async_docker_client.tasks.list(
132130
filters={"service": service_without_labels.Spec.Name}
133131
),
@@ -171,8 +169,7 @@ async def test_post_task_progress_message(
171169
"running",
172170
)
173171
assert service_with_labels.Spec
174-
service_tasks = parse_obj_as(
175-
list[Task],
172+
service_tasks = TypeAdapter(list[Task]).validate_python(
176173
await async_docker_client.tasks.list(
177174
filters={"service": service_with_labels.Spec.Name}
178175
),
@@ -196,7 +193,7 @@ async def test_post_task_progress_message(
196193
progress_type=ProgressType.CLUSTER_UP_SCALING,
197194
report=ProgressReport(actual_value=progress_value, total=1),
198195
)
199-
.json()
196+
.model_dump_json()
200197
.encode()
201198
)
202199
print("... message received")
@@ -218,8 +215,7 @@ async def test_post_task_progress_does_not_raise_if_service_has_no_labels(
218215
):
219216
service_without_labels = await create_service(task_template, {}, "running")
220217
assert service_without_labels.Spec
221-
service_tasks = parse_obj_as(
222-
list[Task],
218+
service_tasks = TypeAdapter(list[Task]).validate_python(
223219
await async_docker_client.tasks.list(
224220
filters={"service": service_without_labels.Spec.Name}
225221
),

0 commit comments

Comments
 (0)