mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-18 22:10:59 +00:00
Added test for #854
This commit is contained in:
parent
347158cb41
commit
cc0d982bbb
2 changed files with 24 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ from django.test import TestCase
|
|||
from django.core.cache import cache
|
||||
|
||||
from wagtail.wagtailcore.models import Page, PageViewRestriction, Site
|
||||
from wagtail.tests.models import SimplePage
|
||||
from wagtail.tests.models import SimplePage, EventIndex
|
||||
|
||||
from .sitemap_generator import Sitemap
|
||||
|
||||
|
|
@ -47,6 +47,20 @@ class TestSitemapGenerator(TestCase):
|
|||
self.assertIn('http://localhost/', urls) # Homepage
|
||||
self.assertIn('http://localhost/hello-world/', urls) # Child page
|
||||
|
||||
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
|
||||
|
||||
def test_render(self):
|
||||
sitemap = Sitemap(self.site)
|
||||
xml = sitemap.render()
|
||||
|
|
|
|||
|
|
@ -306,6 +306,15 @@ class EventIndex(Page):
|
|||
for path in super(EventIndex, self).get_static_site_paths():
|
||||
yield path
|
||||
|
||||
def get_sitemap_urls(self):
|
||||
# Add past events url to sitemap
|
||||
return super(EventIndex, self).get_sitemap_urls() + [
|
||||
{
|
||||
'location': self.full_url + 'past/',
|
||||
'lastmod': self.latest_revision_created_at
|
||||
}
|
||||
]
|
||||
|
||||
EventIndex.content_panels = [
|
||||
FieldPanel('title', classname="full title"),
|
||||
FieldPanel('intro', classname="full"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue