App Engine Python SDK version 1.7.4 (2)
[gae.git] / python / lib / django_1_4 / django / contrib / sitemaps / tests / flatpages.py
bloba40876e8596dc1525137371a60a1755dbf6fe1ab
1 from django.conf import settings
2 from django.utils.unittest import skipUnless
4 from .base import SitemapTestsBase
6 class FlatpagesSitemapTests(SitemapTestsBase):
8 @skipUnless("django.contrib.flatpages" in settings.INSTALLED_APPS,
9 "django.contrib.flatpages app not installed.")
10 def test_flatpage_sitemap(self):
11 "Basic FlatPage sitemap test"
13 # Import FlatPage inside the test so that when django.contrib.flatpages
14 # is not installed we don't get problems trying to delete Site
15 # objects (FlatPage has an M2M to Site, Site.delete() tries to
16 # delete related objects, but the M2M table doesn't exist.
17 from django.contrib.flatpages.models import FlatPage
19 public = FlatPage.objects.create(
20 url=u'/public/',
21 title=u'Public Page',
22 enable_comments=True,
23 registration_required=False,
25 public.sites.add(settings.SITE_ID)
26 private = FlatPage.objects.create(
27 url=u'/private/',
28 title=u'Private Page',
29 enable_comments=True,
30 registration_required=True
32 private.sites.add(settings.SITE_ID)
33 response = self.client.get('/flatpages/sitemap.xml')
34 # Public flatpage should be in the sitemap
35 self.assertContains(response, '<loc>%s%s</loc>' % (self.base_url, public.url))
36 # Private flatpage should not be in the sitemap
37 self.assertNotContains(response, '<loc>%s%s</loc>' % (self.base_url, private.url))