'Make sure storing references as bson.dbref.DBRef works.'

def test_dbref_reference_fields(self):

    class Person(Document, ):
        name = StringField()
        parent = ReferenceField('self', dbref=True)
    Person.drop_collection()
    p1 = Person(name='John').save()
    Person(name='Ross', parent=p1).save()
    self.assertEqual(Person._get_collection().find_one({'name': 'Ross'})['parent'], DBRef('person', p1.pk))
    p = Person.objects.get(name='Ross')
    self.assertEqual(p.parent, p1)
