diff options
| author | django-bot <ops@djangoproject.com> | 2022-02-08 12:09:55 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-08 12:15:38 +0100 |
| commit | 6a682b38e75d4c975b4c4493565a59f1bc14397c (patch) | |
| tree | 0bd9cda550bea26238656d9f120d769e8b41bb9e /tests/sitemaps_tests/test_utils.py | |
| parent | e73ce08888e6f34d3f050377cfd2fbb733be94a9 (diff) | |
[4.0.x] Refs #33476 -- Reformatted code with Black.
Backport of 9c19aff7c7561e3a82978a272ecdaad40dda5c00 from main.
Diffstat (limited to 'tests/sitemaps_tests/test_utils.py')
| -rw-r--r-- | tests/sitemaps_tests/test_utils.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/tests/sitemaps_tests/test_utils.py b/tests/sitemaps_tests/test_utils.py index 34f46c45b3..ec94d7d5ea 100644 --- a/tests/sitemaps_tests/test_utils.py +++ b/tests/sitemaps_tests/test_utils.py @@ -1,9 +1,7 @@ from unittest import mock from urllib.parse import urlencode -from django.contrib.sitemaps import ( - SitemapNotFound, _get_sitemap_full_url, ping_google, -) +from django.contrib.sitemaps import SitemapNotFound, _get_sitemap_full_url, ping_google from django.core.exceptions import ImproperlyConfigured from django.test import modify_settings, override_settings @@ -11,37 +9,45 @@ from .base import SitemapTestsBase class PingGoogleTests(SitemapTestsBase): - - @mock.patch('django.contrib.sitemaps.urlopen') + @mock.patch("django.contrib.sitemaps.urlopen") def test_something(self, urlopen): ping_google() - params = urlencode({'sitemap': 'https://example.com/sitemap-without-entries/sitemap.xml'}) - full_url = 'https://www.google.com/webmasters/tools/ping?%s' % params + params = urlencode( + {"sitemap": "https://example.com/sitemap-without-entries/sitemap.xml"} + ) + full_url = "https://www.google.com/webmasters/tools/ping?%s" % params urlopen.assert_called_with(full_url) def test_get_sitemap_full_url_global(self): - self.assertEqual(_get_sitemap_full_url(None), 'https://example.com/sitemap-without-entries/sitemap.xml') + self.assertEqual( + _get_sitemap_full_url(None), + "https://example.com/sitemap-without-entries/sitemap.xml", + ) - @override_settings(ROOT_URLCONF='sitemaps_tests.urls.index_only') + @override_settings(ROOT_URLCONF="sitemaps_tests.urls.index_only") def test_get_sitemap_full_url_index(self): - self.assertEqual(_get_sitemap_full_url(None), 'https://example.com/simple/index.xml') + self.assertEqual( + _get_sitemap_full_url(None), "https://example.com/simple/index.xml" + ) - @override_settings(ROOT_URLCONF='sitemaps_tests.urls.empty') + @override_settings(ROOT_URLCONF="sitemaps_tests.urls.empty") def test_get_sitemap_full_url_not_detected(self): msg = "You didn't provide a sitemap_url, and the sitemap URL couldn't be auto-detected." with self.assertRaisesMessage(SitemapNotFound, msg): _get_sitemap_full_url(None) def test_get_sitemap_full_url_exact_url(self): - self.assertEqual(_get_sitemap_full_url('/foo.xml'), 'https://example.com/foo.xml') + self.assertEqual( + _get_sitemap_full_url("/foo.xml"), "https://example.com/foo.xml" + ) def test_get_sitemap_full_url_insecure(self): self.assertEqual( - _get_sitemap_full_url('/foo.xml', sitemap_uses_https=False), - 'http://example.com/foo.xml' + _get_sitemap_full_url("/foo.xml", sitemap_uses_https=False), + "http://example.com/foo.xml", ) - @modify_settings(INSTALLED_APPS={'remove': 'django.contrib.sites'}) + @modify_settings(INSTALLED_APPS={"remove": "django.contrib.sites"}) def test_get_sitemap_full_url_no_sites(self): msg = "ping_google requires django.contrib.sites, which isn't installed." with self.assertRaisesMessage(ImproperlyConfigured, msg): |
