Ejemplo n.º 1
0
 def test_purge_with_unroutable_page(self):
     PURGED_URLS[:] = []  # reset PURGED_URLS to the empty list
     root = Page.objects.get(url_path='/')
     page = EventIndex(title='new top-level page', slug='new-top-level-page')
     root.add_child(instance=page)
     page.save_revision().publish()
     self.assertEqual(PURGED_URLS, [])
Ejemplo n.º 2
0
    def setUp(self):
        self.root_page = Page.objects.get(id=1)

        # For simple tests
        self.home_page = self.root_page.add_child(instance=SimplePage(title="Homepage", slug="home"))
        self.about_page = self.home_page.add_child(instance=SimplePage(title="About us", slug="about"))
        self.contact_page = self.home_page.add_child(instance=SimplePage(title="Contact", slug="contact"))

        # For custom tests
        self.event_index = self.root_page.add_child(instance=EventIndex(title="Events", slug="events"))
        for i in range(20):
            self.event_index.add_child(instance=EventPage(title="Event " + str(i), slug="event" + str(i)))
Ejemplo n.º 3
0
    def test_get_urls_uses_specific(self):
        # Add an event page which has an extra url in the sitemap
        events_page = self.home_page.add_child(instance=EventIndex(
            title="Events",
            slug='events',
            live=True,
        ))

        sitemap = Sitemap(self.site)
        urls = [url['location'] for url in sitemap.get_urls()]

        self.assertIn('http://localhost/events/', urls) # Main view
        self.assertIn('http://localhost/events/past/', urls) # Sub view