def test_publish_works_with_descendants(self):
        """
        For help understanding what this tests for, see:
        http://articles.sitepoint.com/print/hierarchical-data-database

        Creates this published structure:
                            home
                          /      \
                       item1   item2
                              /     \
                         subitem1 subitem2
        """
        home_page = create_page("home", "nav_playground.html", "en",
                                published=True, in_navigation=False)

        create_page("item1", "nav_playground.html", "en", parent=home_page,
                    published=True)
        item2 = create_page("item2", "nav_playground.html", "en", parent=home_page,
                            published=True)

        create_page("subitem1", "nav_playground.html", "en", parent=item2,
                    published=True)
        create_page("subitem2", "nav_playground.html", "en", parent=item2,
                    published=True)
        item2 = item2.reload()
        not_drafts = list(Page.objects.filter(publisher_is_draft=False).order_by('path'))
        drafts = list(Page.objects.filter(publisher_is_draft=True).order_by('path'))

        self.assertEqual(len(not_drafts), 5)
        self.assertEqual(len(drafts), 5)

        for idx, draft in enumerate(drafts):
            public = not_drafts[idx]
            # Check that a node doesn't become a root node magically
            self.assertEqual(bool(public.parent_id), bool(draft.parent_id))
            if public.parent:
                self.assertEqual(public.path[0:4], public.parent.path[0:4])
                self.assertTrue(public.parent in public.get_ancestors())
                self.assertTrue(public in public.parent.get_descendants())
                self.assertTrue(public in public.parent.get_children())
            if draft.parent:
                # Same principle for the draft tree
                self.assertEqual(draft.path[0:4], draft.parent.path[0:4])
                self.assertTrue(draft.parent in draft.get_ancestors())
                self.assertTrue(draft in draft.parent.get_descendants())
                self.assertTrue(draft in draft.parent.get_children())

        # Now call publish again. The structure should not change.
        item2.publish('en')

        not_drafts = list(Page.objects.filter(publisher_is_draft=False).order_by('path'))
        drafts = list(Page.objects.filter(publisher_is_draft=True).order_by('path'))

        self.assertEqual(len(not_drafts), 5)
        self.assertEqual(len(drafts), 5)

        for idx, draft in enumerate(drafts):
            public = not_drafts[idx]
            # Check that a node doesn't become a root node magically
            self.assertEqual(bool(public.parent_id), bool(draft.parent_id))
            self.assertEqual(public.numchild, draft.numchild)
            if public.parent:
                self.assertEqual(public.path[0:4], public.parent.path[0:4])
                self.assertTrue(public.get_ancestors() in public.parent)
                self.assertTrue(public in public.parent.get_descendants())
                self.assertTrue(public in public.parent.get_children())
            if draft.parent:
                self.assertEqual(draft.path[0:4], draft.parent.path[0:4])
                self.assertTrue(draft.parent in draft.get_ancestors())
                self.assertTrue(draft in draft.parent.get_descendants())
                self.assertTrue(draft in draft.parent.get_children())
dataset/ETHPy150Open divio/django-cms/cms/tests/test_publisher.py/PublishingTests.test_publish_works_with_descendants/swapped operands of `in`