Refs #26015 -- Added regression test for an empty sitemap.

This commit is contained in:
Andrew Kuchev 2016-01-25 00:35:46 +05:00 committed by Tim Graham
parent f05722a08a
commit 5b2e11e574
2 changed files with 11 additions and 1 deletions

View File

@ -232,3 +232,11 @@ class HTTPSitemapTests(SitemapTestsBase):
</urlset>
""".format(self.base_url, self.i18n_model.pk)
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_sitemap_without_entries(self):
response = self.client.get('/sitemap-without-entries/sitemap.xml')
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
</urlset>"""
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)

View File

@ -168,7 +168,9 @@ urlpatterns = [
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),
{'sitemaps': simple_sitemaps}, name='cached_sitemap')
{'sitemaps': simple_sitemaps}, name='cached_sitemap'),
url(r'^sitemap-without-entries/sitemap\.xml$', views.sitemap,
{'sitemaps': {}}, name='django.contrib.sitemaps.views.sitemap'),
]
urlpatterns += i18n_patterns(