0
0
mirror of https://github.com/django/django.git synced 2024-11-28 02:27:42 +01:00
django/tests/sitemaps_tests/test_generic.py

24 lines
808 B
Python
Raw Normal View History

from __future__ import unicode_literals
from django.test import override_settings
from .base import SitemapTestsBase
from .models import TestModel
@override_settings(ABSOLUTE_URL_OVERRIDES={})
class GenericViewsSitemapTests(SitemapTestsBase):
def test_generic_sitemap(self):
"A minimal generic sitemap can be rendered"
response = self.client.get('/generic/sitemap.xml')
expected = ''
for pk in TestModel.objects.values_list("id", flat=True):
expected += "<url><loc>%s/testmodel/%s/</loc></url>" % (self.base_url, pk)
2012-08-14 20:12:38 +02:00
expected_content = """<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
%s
</urlset>
2012-08-14 20:12:38 +02:00
""" % expected
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)