Fixes passed in Constructor data for complexfields

Fixes #355
This commit is contained in:
Ross Lawley
2011-11-28 08:09:17 -08:00
parent d00859ecfd
commit 083f00be84
2 changed files with 17 additions and 1 deletions

View File

@@ -516,6 +516,21 @@ class FieldTest(unittest.TestCase):
self.assertEquals(BlogPost.objects.filter(info__100__test__exact='test').count(), 0)
BlogPost.drop_collection()
def test_list_field_passed_in_value(self):
class Foo(Document):
bars = ListField(ReferenceField("Bar"))
class Bar(Document):
text = StringField()
bar = Bar(text="hi")
bar.save()
foo = Foo(bars=[])
foo.bars.append(bar)
self.assertEquals(repr(foo.bars), '[<Bar: Bar object>]')
def test_list_field_strict(self):
"""Ensure that list field handles validation if provided a strict field type."""