Skip to content

Commit

Permalink
test: implement empty model and default-only model mapper tests
Browse files Browse the repository at this point in the history
Concerns #181.
  • Loading branch information
lu-pl committed Jan 21, 2025
1 parent ffb937f commit 1935b09
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/tests_mapper/params/model_bindings_mapper_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
BasicNestedModel,
BasicSimpleModel,
)
from tests.tests_mapper.params.models.empty_default_only_model import DefaultOnly, Empty
from tests.tests_mapper.params.models.grouping_model import GroupingComplexModel
from tests.tests_mapper.params.models.nested_grouping_model import (
GroupingNestedComplexModel,
Expand Down Expand Up @@ -256,3 +257,16 @@
],
),
]

empty_default_only_model_parameters = [
ModelBindingsMapperParameter(
model=Empty,
bindings=[{} for _ in range(100)],
expected=[{} for _ in range(100)],
),
ModelBindingsMapperParameter(
model=DefaultOnly,
bindings=[{} for _ in range(100)],
expected=[{"x": 1} for _ in range(100)],
),
]
11 changes: 11 additions & 0 deletions tests/tests_mapper/params/models/empty_default_only_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Models for testing empty/defaul-only model cases."""

from pydantic import BaseModel


class Empty(BaseModel):
pass


class DefaultOnly(BaseModel):
x: int = 1
2 changes: 2 additions & 0 deletions tests/tests_mapper/test_model_bindings_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
author_array_collection_parameters,
author_work_title_parameters,
basic_parameters,
empty_default_only_model_parameters,
grouping_nested_model_parameters,
grouping_parameters,
nested_grouping_parameters,
Expand All @@ -23,6 +24,7 @@
*author_work_title_parameters,
*author_array_collection_parameters,
*grouping_nested_model_parameters,
*empty_default_only_model_parameters,
],
)
def test_basic_model_bindings_mapper(model, bindings, expected):
Expand Down

0 comments on commit 1935b09

Please sign in to comment.