예제 #1
0
 def test_page_methods(self):
     """Test that some methods run properly."""
     page1 = self.new_page(content={'slug': 'page1', 'title': 'hello'})
     page2 = self.new_page(content={'slug': 'page2'})
     page1.save()
     page2.save()
     page2.parent = page1
     page2.save()
     self.assertEqual(page1.expose_content(), u"hello")
     self.assertEqual(page2.slug_with_level(), u"   page2")
     p = Page(author=page1.author)
     self.assertEqual(str(p), u"Page without id")
     p.save()
     self.assertEqual(str(p), u"Page %d" % p.id)
예제 #2
0
 def test_page_methods(self):
     """Test that some methods run properly."""
     page1 = self.new_page(content={'slug': 'page1', 'title': 'hello'})
     page2 = self.new_page(content={'slug': 'page2'})
     page1.save()
     page2.save()
     page2.parent = page1
     page2.save()
     self.assertEqual(
         page1.expose_content(),
         u"hello"
     )
     self.assertEqual(
         page2.slug_with_level(),
         u"   page2"
     )
     p = Page(author=page1.author)
     self.assertEqual(str(p), u"Page without id")
     p.save()
     self.assertEqual(str(p), u"Page %d" % p.id)
예제 #3
0
    def test_date_ordering(self):
        """Test page date ordering feature."""
        self.set_setting("PAGE_USE_SITE_ID", False)
        author = User.objects.all()[0]
        yesterday = now_utc() - datetime.timedelta(days=1)
        now = now_utc()
        p1 = Page(author=author, status=Page.PUBLISHED, publication_date=now)
        p1.save()
        p2 = Page(author=author, publication_date=now, status=Page.PUBLISHED)
        p2.save()
        p3 = Page(author=author,
                  publication_date=yesterday,
                  status=Page.PUBLISHED)
        p3.save()

        p2.move_to(p1, position='first-child')
        p3.move_to(p1, position='first-child')

        p1 = Page.objects.get(pk=p1.id)
        p2 = Page.objects.get(pk=p2.id)
        p3 = Page.objects.get(pk=p3.id)
        self.assertEqual([p.id for p in p1.get_children_for_frontend()],
                         [p3.id, p2.id])

        self.assertEqual(
            [p.id for p in p1.get_date_ordered_children_for_frontend()],
            [p2.id, p3.id])
예제 #4
0
    def test_date_ordering(self):
        """Test page date ordering feature."""
        self.set_setting("PAGE_USE_SITE_ID", False)
        author = User.objects.all()[0]
        yesterday = now_utc() - datetime.timedelta(days=1)
        now = now_utc()
        p1 = Page(author=author, status=Page.PUBLISHED, publication_date=now)
        p1.save()
        p2 = Page(
            author=author,
            publication_date=now,
            status=Page.PUBLISHED
        )
        p2.save()
        p3 = Page(
            author=author,
            publication_date=yesterday,
            status=Page.PUBLISHED
        )
        p3.save()

        p2.move_to(p1, position='first-child')
        p3.move_to(p1, position='first-child')

        p1 = Page.objects.get(pk=p1.id)
        p2 = Page.objects.get(pk=p2.id)
        p3 = Page.objects.get(pk=p3.id)
        self.assertEqual(
            [p.id for p in p1.get_children_for_frontend()],
            [p3.id, p2.id]
        )

        self.assertEqual(
            [p.id for p in p1.get_date_ordered_children_for_frontend()],
            [p2.id, p3.id]
        )