Made use of assertXMLEqual in sitemaps tests

This commit is contained in:
Claude Paroz 2012-10-15 22:33:16 +02:00
parent 6b0a836c9c
commit 08286ca5d9
3 changed files with 12 additions and 12 deletions

View File

@ -19,4 +19,4 @@ class GenericViewsSitemapTests(SitemapTestsBase):
%s %s
</urlset> </urlset>
""" % expected """ % expected
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)

View File

@ -26,7 +26,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap> <sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex> </sitemapindex>
""" % self.base_url """ % self.base_url
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@override_settings( @override_settings(
TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),) TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),)
@ -40,7 +40,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap> <sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex> </sitemapindex>
""" % self.base_url """ % self.base_url
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_simple_sitemap_section(self): def test_simple_sitemap_section(self):
@ -51,7 +51,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset> </urlset>
""" % (self.base_url, date.today()) """ % (self.base_url, date.today())
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_simple_sitemap(self): def test_simple_sitemap(self):
"A simple sitemap can be rendered" "A simple sitemap can be rendered"
@ -61,7 +61,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset> </urlset>
""" % (self.base_url, date.today()) """ % (self.base_url, date.today())
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@override_settings( @override_settings(
TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),) TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),)
@ -75,7 +75,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset> </urlset>
""" % (self.base_url, date.today()) """ % (self.base_url, date.today())
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@skipUnless(settings.USE_I18N, "Internationalization is not enabled") @skipUnless(settings.USE_I18N, "Internationalization is not enabled")
@override_settings(USE_L10N=True) @override_settings(USE_L10N=True)
@ -101,7 +101,7 @@ class HTTPSitemapTests(SitemapTestsBase):
<url><loc>http://testserver/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> <url><loc>http://testserver/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset> </urlset>
""" % date.today() """ % date.today()
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@skipUnless("django.contrib.sites" in settings.INSTALLED_APPS, @skipUnless("django.contrib.sites" in settings.INSTALLED_APPS,
"django.contrib.sites app not installed.") "django.contrib.sites app not installed.")
@ -143,4 +143,4 @@ class HTTPSitemapTests(SitemapTestsBase):
<sitemap><loc>%s/cached/sitemap-simple.xml</loc></sitemap> <sitemap><loc>%s/cached/sitemap-simple.xml</loc></sitemap>
</sitemapindex> </sitemapindex>
""" % self.base_url """ % self.base_url
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)

View File

@ -18,7 +18,7 @@ class HTTPSSitemapTests(SitemapTestsBase):
<sitemap><loc>%s/secure/sitemap-simple.xml</loc></sitemap> <sitemap><loc>%s/secure/sitemap-simple.xml</loc></sitemap>
</sitemapindex> </sitemapindex>
""" % self.base_url """ % self.base_url
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_secure_sitemap_section(self): def test_secure_sitemap_section(self):
"A secure sitemap section can be rendered" "A secure sitemap section can be rendered"
@ -28,7 +28,7 @@ class HTTPSSitemapTests(SitemapTestsBase):
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset> </urlset>
""" % (self.base_url, date.today()) """ % (self.base_url, date.today())
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
@override_settings(SECURE_PROXY_SSL_HEADER=False) @override_settings(SECURE_PROXY_SSL_HEADER=False)
@ -43,7 +43,7 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase):
<sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap> <sitemap><loc>%s/simple/sitemap-simple.xml</loc></sitemap>
</sitemapindex> </sitemapindex>
""" % self.base_url.replace('http://', 'https://') """ % self.base_url.replace('http://', 'https://')
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
def test_sitemap_section_with_https_request(self): def test_sitemap_section_with_https_request(self):
"A sitemap section requested in HTTPS is rendered with HTTPS links" "A sitemap section requested in HTTPS is rendered with HTTPS links"
@ -53,4 +53,4 @@ class HTTPSDetectionSitemapTests(SitemapTestsBase):
<url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url>
</urlset> </urlset>
""" % (self.base_url.replace('http://', 'https://'), date.today()) """ % (self.base_url.replace('http://', 'https://'), date.today())
self.assertEqual(response.content, expected_content.encode('utf-8')) self.assertXMLEqual(response.content.decode('utf-8'), expected_content)