<s> from __future__ import unicode_literals <EOL> from django . test import TestCase <EOL> from mongoengine import Document , EmbeddedDocument , fields <EOL> from rest_framework import fields as drf_fields <EOL> from rest_framework_mongoengine . serializers import ( DocumentSerializer , <EOL> EmbeddedDocumentSerializer ) <EOL> class EmbeddedThing ( EmbeddedDocument ) : <EOL> test_field = fields . StringField ( min_length = <NUM_LIT:3> ) <EOL> class EmbeddingThing ( Document ) : <EOL> embedded = fields . EmbeddedDocumentListField ( EmbeddedThing ) <EOL> class EmbeddedThingSerializer ( EmbeddedDocumentSerializer ) : <EOL> class Meta : <EOL> model = EmbeddedThing <EOL> class ExplicitSerializer ( DocumentSerializer ) : <EOL> class Meta : <EOL> model = EmbeddingThing <EOL> embedded = drf_fields . ListField ( child = EmbeddedThingSerializer ( ) ) <EOL> class ExplicitManySerializer ( DocumentSerializer ) : <EOL> class Meta : <EOL> model = EmbeddingThing <EOL> embedded = EmbeddedThingSerializer ( many = True ) <EOL> class ImplicitSerializer ( DocumentSerializer ) : <EOL> class Meta : <EOL> model = EmbeddingThing <EOL> depth = <NUM_LIT:1> <EOL> class Issue147Test ( TestCase ) : <EOL> def test_explicit_pass ( self ) : <EOL> serializer = ExplicitSerializer ( data = { '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } ] } ) <EOL> assert serializer . is_valid ( ) , serializer . errors <EOL> def test_explicit_fail ( self ) : <EOL> serializer = ExplicitSerializer ( data = { '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } ] } ) <EOL> assert not serializer . is_valid ( ) <EOL> def test_explicitmany_pass ( self ) : <EOL> serializer = ExplicitManySerializer ( data = { '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } ] } ) <EOL> assert serializer . is_valid ( ) , serializer . errors <EOL> def test_explicitmany_fail ( self ) : <EOL> serializer = ExplicitManySerializer ( data = { '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } ] } ) <EOL> assert not serializer . is_valid ( ) <EOL> def test_implicit_pass ( self ) : <EOL> serializer = ImplicitSerializer ( data = { '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } ] } ) <EOL> assert serializer . is_valid ( ) , serializer . errors <EOL> def test_implicit_fail ( self ) : <EOL> serializer = ImplicitSerializer ( data = { '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' } ] } ) <EOL> assert not serializer . is_valid ( ) </s>
