summaryrefslogtreecommitdiff
path: root/tests/sitemaps_tests/test_https.py
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2022-02-03 20:24:19 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit9c19aff7c7561e3a82978a272ecdaad40dda5c00 (patch)
treef0506b668a013d0063e5fba3dbf4863b466713ba /tests/sitemaps_tests/test_https.py
parentf68fa8b45dfac545cfc4111d4e52804c86db68d3 (diff)
Refs #33476 -- Reformatted code with Black.
Diffstat (limited to 'tests/sitemaps_tests/test_https.py')
-rw-r--r--tests/sitemaps_tests/test_https.py34
1 files changed, 23 insertions, 11 deletions
diff --git a/tests/sitemaps_tests/test_https.py b/tests/sitemaps_tests/test_https.py
index 1e8c28d6c3..e2923cf6f4 100644
--- a/tests/sitemaps_tests/test_https.py
+++ b/tests/sitemaps_tests/test_https.py
@@ -5,51 +5,63 @@ from django.test import override_settings
from .base import SitemapTestsBase
-@override_settings(ROOT_URLCONF='sitemaps_tests.urls.https')
+@override_settings(ROOT_URLCONF="sitemaps_tests.urls.https")
class HTTPSSitemapTests(SitemapTestsBase):
- protocol = 'https'
+ protocol = "https"
def test_secure_sitemap_index(self):
"A secure sitemap index can be rendered"
- response = self.client.get('/secure/index.xml')
+ 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">
<sitemap><loc>%s/secure/sitemap-simple.xml</loc><lastmod>%s</lastmod></sitemap>
</sitemapindex>
-""" % (self.base_url, date.today())
+""" % (
+ self.base_url,
+ date.today(),
+ )
self.assertXMLEqual(response.content.decode(), expected_content)
def test_secure_sitemap_section(self):
"A secure sitemap section can be rendered"
- response = self.client.get('/secure/sitemap-simple.xml')
+ response = self.client.get("/secure/sitemap-simple.xml")
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
-""" % (self.base_url, date.today())
+""" % (
+ self.base_url,
+ date.today(),
+ )
self.assertXMLEqual(response.content.decode(), expected_content)
@override_settings(SECURE_PROXY_SSL_HEADER=False)
class HTTPSDetectionSitemapTests(SitemapTestsBase):
- extra = {'wsgi.url_scheme': 'https'}
+ extra = {"wsgi.url_scheme": "https"}
def test_sitemap_index_with_https_request(self):
"A sitemap index requested in HTTPS is rendered with HTTPS links"
- response = self.client.get('/simple/index.xml', **self.extra)
+ response = self.client.get("/simple/index.xml", **self.extra)
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>%s/simple/sitemap-simple.xml</loc><lastmod>%s</lastmod></sitemap>
</sitemapindex>
-""" % (self.base_url.replace('http://', 'https://'), date.today())
+""" % (
+ self.base_url.replace("http://", "https://"),
+ date.today(),
+ )
self.assertXMLEqual(response.content.decode(), expected_content)
def test_sitemap_section_with_https_request(self):
"A sitemap section requested in HTTPS is rendered with HTTPS links"
- response = self.client.get('/simple/sitemap-simple.xml', **self.extra)
+ response = self.client.get("/simple/sitemap-simple.xml", **self.extra)
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset>
-""" % (self.base_url.replace('http://', 'https://'), date.today())
+""" % (
+ self.base_url.replace("http://", "https://"),
+ date.today(),
+ )
self.assertXMLEqual(response.content.decode(), expected_content)