Ticket #14447: fixes_trunk.diff

File fixes_trunk.diff, 3.1 KB (added by Gabriel Hurley, 14 years ago)
  • contrib/auth/tests/decorators.py

     
     1from django.conf import settings
    12from django.contrib.auth.decorators import login_required
    23from django.contrib.auth.tests.views import AuthViewsTestCase
    34
     
    2425            pass
    2526        login_required(normal_view)
    2627
    27     def testLoginRequired(self, view_url='/login_required/', login_url='/login/'):
     28    def testLoginRequired(self, view_url='/login_required/', login_url=settings.LOGIN_URL):
    2829        """
    2930        Check that login_required works on a simple view wrapped in a
    3031        login_required decorator.
  • contrib/sitemaps/tests/basic.py

     
    11from datetime import date
    22from django.conf import settings
    33from django.contrib.auth.models import User
    4 from django.contrib.flatpages.models import FlatPage
    54from django.contrib.sitemaps import Sitemap
    65from django.contrib.sites.models import Site
    76from django.core.exceptions import ImproperlyConfigured
    87from django.test import TestCase
     8from django.utils.unittest import skipUnless
    99from django.utils.formats import localize
    1010from django.utils.translation import activate, deactivate
    1111
     
    5252        "A minimal generic sitemap can be rendered"
    5353        # Retrieve the sitemap.
    5454        response = self.client.get('/generic/sitemap.xml')
     55       
     56        expected = ''
     57        for username in User.objects.values_list("username", flat=True):
     58            expected += "<url><loc>http://example.com/users/%s/</loc></url>" %username
    5559        # Check for all the important bits:
    5660        self.assertEquals(response.content, """<?xml version="1.0" encoding="UTF-8"?>
    5761<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    58 <url><loc>http://example.com/users/testuser/</loc></url>
     62%s
    5963</urlset>
    60 """)
     64""" %expected)
    6165
     66    @skipUnless("django.contrib.flatpages" in settings.INSTALLED_APPS, "django.contrib.flatpages app not installed.")
    6267    def test_flatpage_sitemap(self):
    6368        "Basic FlatPage sitemap test"
     69       
     70        # Import FlatPage inside the test so that when django.contrib.flatpages
     71        # is not installed we don't get problems trying to delete Site
     72        # objects (FlatPage has an M2M to Site, Site.delete() tries to
     73        # delete related objects, but the M2M table doesn't exist.
     74        from django.contrib.flatpages.models import FlatPage
     75
    6476        public = FlatPage.objects.create(
    6577            url=u'/public/',
    6678            title=u'Public Page',
     
    8597        # Make sure hitting the flatpages sitemap without the sites framework
    8698        # installed doesn't raise an exception
    8799        Site._meta.installed = False
    88         response = self.client.get('/flatpages/sitemap.xml')
    89100        # Retrieve the sitemap.
    90101        response = self.client.get('/simple/sitemap.xml')
    91102        # Check for all the important bits:
Back to Top