2012-08-14 11:57:18 +02:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2013-12-23 16:01:13 +01:00
|
|
|
from django.test import override_settings
|
2012-01-29 20:24:32 +01:00
|
|
|
|
2015-02-10 14:11:25 +01:00
|
|
|
from .base import SitemapTestsBase
|
|
|
|
from .models import TestModel
|
2013-03-23 02:57:48 +01:00
|
|
|
|
2012-01-29 20:24:32 +01:00
|
|
|
|
2012-06-30 18:49:11 +02:00
|
|
|
@override_settings(ABSOLUTE_URL_OVERRIDES={})
|
2012-01-29 20:24:32 +01:00
|
|
|
class GenericViewsSitemapTests(SitemapTestsBase):
|
|
|
|
|
|
|
|
def test_generic_sitemap(self):
|
|
|
|
"A minimal generic sitemap can be rendered"
|
|
|
|
response = self.client.get('/generic/sitemap.xml')
|
|
|
|
expected = ''
|
2013-03-23 02:57:48 +01:00
|
|
|
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"?>
|
2012-01-29 20:24:32 +01:00
|
|
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
|
|
%s
|
|
|
|
</urlset>
|
2012-08-14 20:12:38 +02:00
|
|
|
""" % expected
|
2012-10-15 22:33:16 +02:00
|
|
|
self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
|