Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed #20048 -- Fixed flatpages tests for custom User model. #908

Closed
wants to merge 1 commit into from

2 participants

Matias Bordese Russell Keith-Magee
Matias Bordese

Skipped flatpages tests depending on default User model.
Also fixed flatpage test failing depending on the project locale.

Matias Bordese matiasb Fixed #20048 -- Fixed flatpages tests for custom User model.
Skipped flatpages tests depending on default User model.
Also fixed flatpage test failing depending on the project locale.
6e59257
Russell Keith-Magee

Thanks for the patch.

I've left out the project locale failure fix in the final version; I tried to reproduce the conditions that I thought would make the test fail, but I wasn't successful. Please open that as a separate ticket with reproduction instructions so that it can be fixed as a separate commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 16, 2013
  1. Matias Bordese

    Fixed #20048 -- Fixed flatpages tests for custom User model.

    matiasb authored
    Skipped flatpages tests depending on default User model.
    Also fixed flatpage test failing depending on the project locale.
This page is out of date. Refresh to see the latest.
2  django/contrib/flatpages/tests/csrf.py
View
@@ -1,6 +1,7 @@
import os
from django.conf import settings
from django.contrib.auth.models import User
+from django.contrib.auth.tests.utils import skipIfCustomUser
from django.test import TestCase, Client
from django.test.utils import override_settings
@@ -38,6 +39,7 @@ def test_view_non_existent_flatpage(self):
response = self.client.get('/flatpage_root/no_such_flatpage/')
self.assertEqual(response.status_code, 404)
+ @skipIfCustomUser
def test_view_authenticated_flatpage(self):
"A flatpage served through a view can require authentication"
response = self.client.get('/flatpage_root/sekrit/')
10 django/contrib/flatpages/tests/forms.py
View
@@ -58,11 +58,11 @@ def test_flatpage_admin_form_url_uniqueness_validation(self):
f = FlatpageForm(data=data)
- self.assertFalse(f.is_valid())
-
- self.assertEqual(
- f.errors,
- {'__all__': ['Flatpage with url /myflatpage1/ already exists for site example.com']})
+ with translation.override('en'):
+ self.assertFalse(f.is_valid())
+ self.assertEqual(
+ f.errors,
+ {'__all__': ['Flatpage with url /myflatpage1/ already exists for site example.com']})
def test_flatpage_admin_form_edit(self):
"""
3  django/contrib/flatpages/tests/middleware.py
View
@@ -1,6 +1,7 @@
import os
from django.conf import settings
from django.contrib.auth.models import User
+from django.contrib.auth.tests.utils import skipIfCustomUser
from django.contrib.flatpages.models import FlatPage
from django.test import TestCase
from django.test.utils import override_settings
@@ -36,6 +37,7 @@ def test_view_non_existent_flatpage(self):
response = self.client.get('/flatpage_root/no_such_flatpage/')
self.assertEqual(response.status_code, 404)
+ @skipIfCustomUser
def test_view_authenticated_flatpage(self):
"A flatpage served through a view can require authentication"
response = self.client.get('/flatpage_root/sekrit/')
@@ -57,6 +59,7 @@ def test_fallback_non_existent_flatpage(self):
response = self.client.get('/no_such_flatpage/')
self.assertEqual(response.status_code, 404)
+ @skipIfCustomUser
def test_fallback_authenticated_flatpage(self):
"A flatpage served by the middleware can require authentication"
response = self.client.get('/sekrit/')
12 django/contrib/flatpages/tests/templatetags.py
View
@@ -1,6 +1,7 @@
import os
from django.conf import settings
from django.contrib.auth.models import AnonymousUser, User
+from django.contrib.auth.tests.utils import skipIfCustomUser
from django.template import Template, Context, TemplateSyntaxError
from django.test import TestCase
from django.test.utils import override_settings
@@ -24,9 +25,6 @@ class FlatpageTemplateTagTests(TestCase):
fixtures = ['sample_flatpages']
urls = 'django.contrib.flatpages.tests.urls'
- def setUp(self):
- self.me = User.objects.create_user('testuser', 'test@example.com', 's3krit')
-
def test_get_flatpages_tag(self):
"The flatpage template tag retrives unregistered prefixed flatpages by default"
out = Template(
@@ -51,8 +49,10 @@ def test_get_flatpages_tag_for_anon_user(self):
}))
self.assertEqual(out, "A Flatpage,A Nested Flatpage,")
+ @skipIfCustomUser
def test_get_flatpages_tag_for_user(self):
"The flatpage template tag retrives all flatpages for an authenticated user"
+ me = User.objects.create_user('testuser', 'test@example.com', 's3krit')
out = Template(
"{% load flatpages %}"
"{% get_flatpages for me as flatpages %}"
@@ -60,7 +60,7 @@ def test_get_flatpages_tag_for_user(self):
"{{ page.title }},"
"{% endfor %}"
).render(Context({
- 'me': self.me
+ 'me': me
}))
self.assertEqual(out, "A Flatpage,A Nested Flatpage,Sekrit Nested Flatpage,Sekrit Flatpage,")
@@ -88,8 +88,10 @@ def test_get_flatpages_with_prefix_for_anon_user(self):
}))
self.assertEqual(out, "A Nested Flatpage,")
+ @skipIfCustomUser
def test_get_flatpages_with_prefix_for_user(self):
"The flatpage template tag retrive prefixed flatpages for an authenticated user"
+ me = User.objects.create_user('testuser', 'test@example.com', 's3krit')
out = Template(
"{% load flatpages %}"
"{% get_flatpages '/location/' for me as location_flatpages %}"
@@ -97,7 +99,7 @@ def test_get_flatpages_with_prefix_for_user(self):
"{{ page.title }},"
"{% endfor %}"
).render(Context({
- 'me': self.me
+ 'me': me
}))
self.assertEqual(out, "A Nested Flatpage,Sekrit Nested Flatpage,")
2  django/contrib/flatpages/tests/views.py
View
@@ -1,6 +1,7 @@
import os
from django.conf import settings
from django.contrib.auth.models import User
+from django.contrib.auth.tests.utils import skipIfCustomUser
from django.contrib.flatpages.models import FlatPage
from django.test import TestCase
from django.test.utils import override_settings
@@ -36,6 +37,7 @@ def test_view_non_existent_flatpage(self):
response = self.client.get('/flatpage_root/no_such_flatpage/')
self.assertEqual(response.status_code, 404)
+ @skipIfCustomUser
def test_view_authenticated_flatpage(self):
"A flatpage served through a view can require authentication"
response = self.client.get('/flatpage_root/sekrit/')
Something went wrong with that request. Please try again.