1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Improved test coverage for django.contrib.sitemaps.

This commit is contained in:
Anton Samarchyan
2017-03-17 15:25:50 -04:00
committed by Tim Graham
parent 5bb9b9a388
commit 0eefda493b
4 changed files with 72 additions and 3 deletions

View File

@@ -21,6 +21,11 @@ class SimpleSitemap(Sitemap):
return [object()]
class SimplePagedSitemap(Sitemap):
def items(self):
return [object() for x in range(Sitemap.limit + 1)]
class SimpleI18nSitemap(Sitemap):
changefreq = "never"
priority = 0.5
@@ -35,9 +40,6 @@ class EmptySitemap(Sitemap):
priority = 0.5
location = '/location/'
def items(self):
return []
class FixedLastmodSitemap(SimpleSitemap):
lastmod = datetime(2013, 3, 13, 10, 0, 0)
@@ -80,6 +82,14 @@ simple_i18nsitemaps = {
'simple': SimpleI18nSitemap,
}
simple_sitemaps_not_callable = {
'simple': SimpleSitemap(),
}
simple_sitemaps_paged = {
'simple': SimplePagedSitemap,
}
empty_sitemaps = {
'empty': EmptySitemap,
}
@@ -118,9 +128,17 @@ generic_sitemaps = {
'generic': GenericSitemap({'queryset': TestModel.objects.order_by('pk').all()}),
}
generic_sitemaps_lastmod = {
'generic': GenericSitemap({
'queryset': TestModel.objects.order_by('pk').all(),
'date_field': 'lastmod',
}),
}
urlpatterns = [
url(r'^simple/index\.xml$', views.index, {'sitemaps': simple_sitemaps}),
url(r'^simple-paged/index\.xml$', views.index, {'sitemaps': simple_sitemaps_paged}),
url(r'^simple-not-callable/index\.xml$', views.index, {'sitemaps': simple_sitemaps_not_callable}),
url(r'^simple/custom-index\.xml$', views.index,
{'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap_index.xml'}),
url(r'^simple/sitemap-(?P<section>.+)\.xml$', views.sitemap,
@@ -165,6 +183,9 @@ urlpatterns = [
url(r'^generic/sitemap\.xml$', views.sitemap,
{'sitemaps': generic_sitemaps},
name='django.contrib.sitemaps.views.sitemap'),
url(r'^generic-lastmod/sitemap\.xml$', views.sitemap,
{'sitemaps': generic_sitemaps_lastmod},
name='django.contrib.sitemaps.views.sitemap'),
url(r'^cached/index\.xml$', cache_page(1)(views.index),
{'sitemaps': simple_sitemaps, 'sitemap_url_name': 'cached_sitemap'}),
url(r'^cached/sitemap-(?P<section>.+)\.xml', cache_page(1)(views.sitemap),