Adding a test case for #1047.
This commit is contained in:
parent
9ce605221a
commit
d7a2ccf5ac
@ -1618,6 +1618,27 @@ class FieldTest(unittest.TestCase):
|
|||||||
mongoed = p1.to_mongo()
|
mongoed = p1.to_mongo()
|
||||||
self.assertTrue(isinstance(mongoed['parent'], ObjectId))
|
self.assertTrue(isinstance(mongoed['parent'], ObjectId))
|
||||||
|
|
||||||
|
def test_cached_reference_field_get_and_save(self):
|
||||||
|
"""
|
||||||
|
Tests #1047: CachedReferenceField creates DBRefs on to_python, but can't save them on to_mongo
|
||||||
|
"""
|
||||||
|
class Animal(Document):
|
||||||
|
name = StringField()
|
||||||
|
tag = StringField()
|
||||||
|
|
||||||
|
class Ocorrence(Document):
|
||||||
|
person = StringField()
|
||||||
|
animal = CachedReferenceField(Animal)
|
||||||
|
|
||||||
|
Animal.drop_collection()
|
||||||
|
Ocorrence.drop_collection()
|
||||||
|
|
||||||
|
Ocorrence(person="testte",
|
||||||
|
animal=Animal(name="Leopard", tag="heavy").save()).save()
|
||||||
|
p = Ocorrence.objects.get()
|
||||||
|
p.person = 'new_testte'
|
||||||
|
p.save()
|
||||||
|
|
||||||
def test_cached_reference_fields(self):
|
def test_cached_reference_fields(self):
|
||||||
class Animal(Document):
|
class Animal(Document):
|
||||||
name = StringField()
|
name = StringField()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user