Loading django/contrib/sitemaps/tests/test_http.py +29 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ from __future__ import unicode_literals import os from datetime import date from unittest import skipUnless import warnings from django.apps import apps from django.conf import settings Loading @@ -10,6 +11,7 @@ from django.contrib.sitemaps import Sitemap, GenericSitemap from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.test import modify_settings, override_settings from django.utils.deprecation import RemovedInDjango20Warning from django.utils.formats import localize from django.utils._os import upath from django.utils.translation import activate, deactivate Loading @@ -21,6 +23,14 @@ class HTTPSitemapTests(SitemapTestsBase): def test_simple_sitemap_index(self): "A simple sitemap index can be rendered" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence # the erroneous warning until reversing by dotted path is removed. # The test will work without modification when it's removed. response = self.client.get('/simple/index.xml') expected_content = """<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> Loading @@ -34,6 +44,14 @@ class HTTPSitemapTests(SitemapTestsBase): ) def test_simple_sitemap_custom_index(self): "A simple sitemap index can be rendered with a custom template" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence # the erroneous warning until reversing by dotted path is removed. # The test will work without modification when it's removed. response = self.client.get('/simple/custom-index.xml') expected_content = """<?xml version="1.0" encoding="UTF-8"?> <!-- This is a customised template --> Loading Loading @@ -177,6 +195,14 @@ class HTTPSitemapTests(SitemapTestsBase): self.assertXMLEqual(response.content.decode('utf-8'), expected_content) def test_x_robots_sitemap(self): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence # the erroneous warning until reversing by dotted path is removed. # The test will work without modification when it's removed. response = self.client.get('/simple/index.xml') self.assertEqual(response['X-Robots-Tag'], 'noindex, noodp, noarchive') Loading django/contrib/sitemaps/tests/test_https.py +10 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,14 @@ class HTTPSSitemapTests(SitemapTestsBase): def test_secure_sitemap_index(self): "A secure sitemap index can be rendered" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/https.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence # the erroneous warning until reversing by dotted path is removed. # The test will work without modification when it's removed. response = self.client.get('/secure/index.xml') expected_content = """<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> Loading Loading @@ -42,7 +50,7 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase): "A sitemap index requested in HTTPS is rendered with HTTPS links" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # The URL for views.sitemap in tests/urls/https.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence Loading django/contrib/sitemaps/tests/urls/http.py +29 −11 Original line number Diff line number Diff line Loading @@ -100,20 +100,38 @@ urlpatterns = [ 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, {'sitemaps': simple_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^simple/sitemap\.xml$', views.sitemap, {'sitemaps': simple_sitemaps}), url(r'^simple/i18n\.xml$', views.sitemap, {'sitemaps': simple_i18nsitemaps}), {'sitemaps': simple_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^simple/sitemap\.xml$', views.sitemap, {'sitemaps': simple_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^simple/i18n\.xml$', views.sitemap, {'sitemaps': simple_i18nsitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^simple/custom-sitemap\.xml$', views.sitemap, {'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'}), url(r'^empty/sitemap\.xml$', views.sitemap, {'sitemaps': empty_sitemaps}), url(r'^lastmod/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod_sitemaps}), url(r'^lastmod-mixed/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod__mixed_sitemaps}), {'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'}, name='django.contrib.sitemaps.views.sitemap'), url(r'^empty/sitemap\.xml$', views.sitemap, {'sitemaps': empty_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^lastmod/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^lastmod-mixed/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod__mixed_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^lastmod/date-sitemap.xml$', views.sitemap, {'sitemaps': {'date-sitemap': DateSiteMap}}), {'sitemaps': {'date-sitemap': DateSiteMap}}, name='django.contrib.sitemaps.views.sitemap'), url(r'^lastmod/tz-sitemap.xml$', views.sitemap, {'sitemaps': {'tz-sitemap': TimezoneSiteMap}}), url(r'^generic/sitemap\.xml$', views.sitemap, {'sitemaps': generic_sitemaps}), url(r'^flatpages/sitemap\.xml$', views.sitemap, {'sitemaps': flatpage_sitemaps}), {'sitemaps': {'tz-sitemap': TimezoneSiteMap}}, name='django.contrib.sitemaps.views.sitemap'), url(r'^generic/sitemap\.xml$', views.sitemap, {'sitemaps': generic_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^flatpages/sitemap\.xml$', views.sitemap, {'sitemaps': flatpage_sitemaps}, 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), Loading django/contrib/sitemaps/tests/urls/https.py +2 −1 Original line number Diff line number Diff line Loading @@ -14,5 +14,6 @@ secure_sitemaps = { urlpatterns = [ url(r'^secure/index\.xml$', views.index, {'sitemaps': secure_sitemaps}), url(r'^secure/sitemap-(?P<section>.+)\.xml$', views.sitemap, {'sitemaps': secure_sitemaps}), {'sitemaps': secure_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] Loading
django/contrib/sitemaps/tests/test_http.py +29 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ from __future__ import unicode_literals import os from datetime import date from unittest import skipUnless import warnings from django.apps import apps from django.conf import settings Loading @@ -10,6 +11,7 @@ from django.contrib.sitemaps import Sitemap, GenericSitemap from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.test import modify_settings, override_settings from django.utils.deprecation import RemovedInDjango20Warning from django.utils.formats import localize from django.utils._os import upath from django.utils.translation import activate, deactivate Loading @@ -21,6 +23,14 @@ class HTTPSitemapTests(SitemapTestsBase): def test_simple_sitemap_index(self): "A simple sitemap index can be rendered" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence # the erroneous warning until reversing by dotted path is removed. # The test will work without modification when it's removed. response = self.client.get('/simple/index.xml') expected_content = """<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> Loading @@ -34,6 +44,14 @@ class HTTPSitemapTests(SitemapTestsBase): ) def test_simple_sitemap_custom_index(self): "A simple sitemap index can be rendered with a custom template" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence # the erroneous warning until reversing by dotted path is removed. # The test will work without modification when it's removed. response = self.client.get('/simple/custom-index.xml') expected_content = """<?xml version="1.0" encoding="UTF-8"?> <!-- This is a customised template --> Loading Loading @@ -177,6 +195,14 @@ class HTTPSitemapTests(SitemapTestsBase): self.assertXMLEqual(response.content.decode('utf-8'), expected_content) def test_x_robots_sitemap(self): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence # the erroneous warning until reversing by dotted path is removed. # The test will work without modification when it's removed. response = self.client.get('/simple/index.xml') self.assertEqual(response['X-Robots-Tag'], 'noindex, noodp, noarchive') Loading
django/contrib/sitemaps/tests/test_https.py +10 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,14 @@ class HTTPSSitemapTests(SitemapTestsBase): def test_secure_sitemap_index(self): "A secure sitemap index can be rendered" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/https.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence # the erroneous warning until reversing by dotted path is removed. # The test will work without modification when it's removed. response = self.client.get('/secure/index.xml') expected_content = """<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> Loading Loading @@ -42,7 +50,7 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase): "A sitemap index requested in HTTPS is rendered with HTTPS links" with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=RemovedInDjango20Warning) # The URL for views.sitemap in tests/urls/http.py has been updated # The URL for views.sitemap in tests/urls/https.py has been updated # with a name but since reversing by Python path is tried first # before reversing by name and works since we're giving # name='django.contrib.sitemaps.views.sitemap', we need to silence Loading
django/contrib/sitemaps/tests/urls/http.py +29 −11 Original line number Diff line number Diff line Loading @@ -100,20 +100,38 @@ urlpatterns = [ 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, {'sitemaps': simple_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^simple/sitemap\.xml$', views.sitemap, {'sitemaps': simple_sitemaps}), url(r'^simple/i18n\.xml$', views.sitemap, {'sitemaps': simple_i18nsitemaps}), {'sitemaps': simple_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^simple/sitemap\.xml$', views.sitemap, {'sitemaps': simple_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^simple/i18n\.xml$', views.sitemap, {'sitemaps': simple_i18nsitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^simple/custom-sitemap\.xml$', views.sitemap, {'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'}), url(r'^empty/sitemap\.xml$', views.sitemap, {'sitemaps': empty_sitemaps}), url(r'^lastmod/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod_sitemaps}), url(r'^lastmod-mixed/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod__mixed_sitemaps}), {'sitemaps': simple_sitemaps, 'template_name': 'custom_sitemap.xml'}, name='django.contrib.sitemaps.views.sitemap'), url(r'^empty/sitemap\.xml$', views.sitemap, {'sitemaps': empty_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^lastmod/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^lastmod-mixed/sitemap\.xml$', views.sitemap, {'sitemaps': fixed_lastmod__mixed_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^lastmod/date-sitemap.xml$', views.sitemap, {'sitemaps': {'date-sitemap': DateSiteMap}}), {'sitemaps': {'date-sitemap': DateSiteMap}}, name='django.contrib.sitemaps.views.sitemap'), url(r'^lastmod/tz-sitemap.xml$', views.sitemap, {'sitemaps': {'tz-sitemap': TimezoneSiteMap}}), url(r'^generic/sitemap\.xml$', views.sitemap, {'sitemaps': generic_sitemaps}), url(r'^flatpages/sitemap\.xml$', views.sitemap, {'sitemaps': flatpage_sitemaps}), {'sitemaps': {'tz-sitemap': TimezoneSiteMap}}, name='django.contrib.sitemaps.views.sitemap'), url(r'^generic/sitemap\.xml$', views.sitemap, {'sitemaps': generic_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), url(r'^flatpages/sitemap\.xml$', views.sitemap, {'sitemaps': flatpage_sitemaps}, 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), Loading
django/contrib/sitemaps/tests/urls/https.py +2 −1 Original line number Diff line number Diff line Loading @@ -14,5 +14,6 @@ secure_sitemaps = { urlpatterns = [ url(r'^secure/index\.xml$', views.index, {'sitemaps': secure_sitemaps}), url(r'^secure/sitemap-(?P<section>.+)\.xml$', views.sitemap, {'sitemaps': secure_sitemaps}), {'sitemaps': secure_sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ]