Skip to content

Commit

Permalink
test modeling
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Nov 19, 2024
1 parent 295832a commit b482877
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/models-library/src/models_library/rest_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/models-library/tests/test_rest_ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit b482877

Please sign in to comment.