Skip to content

Commit 3c18f79

Browse files
committed
Added test for reloading of strict with special fields #1156
1 parent ed8174f commit 3c18f79

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/document/instance.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,28 @@ class Foo(Document):
557557
except Exception:
558558
self.assertFalse("Threw wrong exception")
559559

560+
def test_reload_of_non_strict_with_special_field_name(self):
561+
"""Ensures reloading works for documents with meta strict == False
562+
"""
563+
class Post(Document):
564+
meta = {
565+
'strict': False
566+
}
567+
title = StringField()
568+
items = ListField()
569+
570+
Post.drop_collection()
571+
572+
Post._get_collection().insert_one({
573+
"title": "Items eclipse",
574+
"items": ["more lorem", "even more ipsum"]
575+
})
576+
577+
post = Post.objects.first()
578+
post.reload()
579+
self.assertEqual(post.title, "Items eclipse")
580+
self.assertEqual(post.items, ["more lorem", "even more ipsum"])
581+
560582
def test_dictionary_access(self):
561583
"""Ensure that dictionary-style field access works properly.
562584
"""

0 commit comments

Comments
 (0)