'Ensure nullification of references to deleted documents.'

def test_reverse_delete_rule_nullify(self):

    class Category(Document, ):
        name = StringField()
    class BlogPost(Document, ):
        content = StringField()
        category = ReferenceField(Category, reverse_delete_rule=NULLIFY)
    BlogPost.drop_collection()
    Category.drop_collection()
    lameness = Category(name='Lameness')
    lameness.save()
    post = BlogPost(content='Watching    TV', category=lameness)
    post.save()
    self.assertEqual(1, BlogPost.objects.count())
    self.assertEqual('Lameness', BlogPost.objects.first().category.name)
    Category.objects.delete()
    self.assertEqual(1, BlogPost.objects.count())
    self.assertEqual(None, BlogPost.objects.first().category)
