Skip to content

Commit 858d5ef

Browse files
committed
New test for the method serialize_model
1 parent 0711a46 commit 858d5ef

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pytest
2+
3+
from tests.models import FlatModel, NestedModel
4+
5+
6+
@pytest.fixture
7+
def test_model(get_instance):
8+
model = get_instance(NestedModel)
9+
model.model = get_instance(FlatModel)
10+
return model
11+
12+
13+
# TODO: Add more checks of model fields
14+
@pytest.mark.parametrize(
15+
"only, expected",
16+
[
17+
# FIXME: last `key` ignored and all the rist is returned is it expected?
18+
# (("model.list.key",), {"model": {"list": [{"key": 123}]}}),
19+
(("dict.key",), {"dict": {"key": 123}}),
20+
(("bool",), {"bool": False}),
21+
(("null",), {"null": None}), # FIXME: Invalid JSON
22+
],
23+
)
24+
def test_serializer_serialize_model__fork_success(
25+
get_serializer, test_model, only, expected
26+
):
27+
serializer = get_serializer()
28+
serializer.schema.update(only=only)
29+
result = serializer.serialize_model(test_model)
30+
assert result == expected

0 commit comments

Comments
 (0)