From 2ce03a2bac9f41b803196a45dcd07cc342838e58 Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 17 Feb 2021 19:19:27 +0000 Subject: [PATCH] Refs #25916 -- Isolated sitemap.test_utils tests --- tests/sitemaps_tests/test_utils.py | 2 ++ tests/sitemaps_tests/urls/sitemap_only.py | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/sitemaps_tests/urls/sitemap_only.py diff --git a/tests/sitemaps_tests/test_utils.py b/tests/sitemaps_tests/test_utils.py index 34f46c45b3..d230e1a358 100644 --- a/tests/sitemaps_tests/test_utils.py +++ b/tests/sitemaps_tests/test_utils.py @@ -12,6 +12,7 @@ from .base import SitemapTestsBase class PingGoogleTests(SitemapTestsBase): + @override_settings(ROOT_URLCONF='sitemaps_tests.urls.sitemap_only') @mock.patch('django.contrib.sitemaps.urlopen') def test_something(self, urlopen): ping_google() @@ -19,6 +20,7 @@ class PingGoogleTests(SitemapTestsBase): full_url = 'https://www.google.com/webmasters/tools/ping?%s' % params urlopen.assert_called_with(full_url) + @override_settings(ROOT_URLCONF='sitemaps_tests.urls.sitemap_only') def test_get_sitemap_full_url_global(self): self.assertEqual(_get_sitemap_full_url(None), 'https://example.com/sitemap-without-entries/sitemap.xml') diff --git a/tests/sitemaps_tests/urls/sitemap_only.py b/tests/sitemaps_tests/urls/sitemap_only.py new file mode 100644 index 0000000000..3831fe4787 --- /dev/null +++ b/tests/sitemaps_tests/urls/sitemap_only.py @@ -0,0 +1,9 @@ +from django.contrib.sitemaps import views +from django.urls import path + +urlpatterns = [ + path( + 'sitemap-without-entries/sitemap.xml', views.sitemap, + {'sitemaps': {}}, name='django.contrib.sitemaps.views.sitemap', + ), +]