'Tests #1047: CachedReferenceField creates DBRefs on to_python,
but can\'t save them on to_mongo.'

def test_cached_reference_field_get_and_save(self):

    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()
