'Ensure that a chain of documents is also deleted upon
cascaded deletion.'

def test_reverse_delete_rule_cascade_recurs(self):

    class BlogPost(Document, ):
        content = StringField()
        author = ReferenceField(self.Person, reverse_delete_rule=CASCADE)
    class Comment(Document, ):
        text = StringField()
        post = ReferenceField(BlogPost, reverse_delete_rule=CASCADE)
    self.Person.drop_collection()
    BlogPost.drop_collection()
    Comment.drop_collection()
    author = self.Person(name='Test    User')
    author.save()
    post = BlogPost(content='Watched    some    TV')
    post.author = author
    post.save()
    comment = Comment(text='Kudos.')
    comment.post = post
    comment.save()
    author.delete()
    self.assertEqual(Comment.objects.count(), 0)
