From b482877d0a34740313a383049c2aad1b477f916e Mon Sep 17 00:00:00 2001 From: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:35:47 +0100 Subject: [PATCH] test modeling --- .../models-library/src/models_library/rest_ordering.py | 7 ++++--- packages/models-library/tests/test_rest_ordering.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/models-library/src/models_library/rest_ordering.py b/packages/models-library/src/models_library/rest_ordering.py index 3b355ae51ef..b042950c352 100644 --- a/packages/models-library/src/models_library/rest_ordering.py +++ b/packages/models-library/src/models_library/rest_ordering.py @@ -72,7 +72,8 @@ class _OrderBy(OrderBy): } ] }, - validate_assignment=True, # Necessary to run _check_ordering_field_and_map in defaults and assignments + # Necessary to run _check_ordering_field_and_map in defaults and assignments + validate_assignment=True, validate_default=True, ) @@ -91,9 +92,9 @@ def _check_ordering_field_and_map(cls, v): assert "json_schema_extra" in _OrderBy.model_config # nosec assert isinstance(_OrderBy.model_config["json_schema_extra"], dict) # nosec - assert isinstance( + assert isinstance( # nosec _OrderBy.model_config["json_schema_extra"]["examples"], list - ) # nosec + ) order_by_example = _OrderBy.model_config["json_schema_extra"]["examples"][0] order_by_example_json = json_dumps(order_by_example) assert _OrderBy.model_validate(order_by_example), "Example is invalid" # nosec diff --git a/packages/models-library/tests/test_rest_ordering.py b/packages/models-library/tests/test_rest_ordering.py index a495dc55721..a3f84bf0d2c 100644 --- a/packages/models-library/tests/test_rest_ordering.py +++ b/packages/models-library/tests/test_rest_ordering.py @@ -106,7 +106,7 @@ def test_ordering_query_model_class__fails_with_invalid_direction(): error = err_info.value.errors()[0] - assert error["type"] == "type_error.enum" + assert error["type"] == "enum" assert error["loc"] == ("order_by", "direction") @@ -137,7 +137,7 @@ def test_ordering_query_model_class__defaults(): error = err_info.value.errors()[0] assert error["loc"] == ("order_by", "field") - assert error["type"] == "value_error.missing" + assert error["type"] == "missing" def test_ordering_query_model_with_map():