Fixed #18408 -- Isolated flatpages tests from existing sites.
Resolves Flatpages test issues by: - Creating an example_site fixture - Overriding project SITE_ID setting to 1 - Normalizing the use of the hardcoded (1) site_id to settings.SITE_ID
This commit is contained in:
parent
ea4e0aad9e
commit
ba10be7032
1
AUTHORS
1
AUTHORS
|
@ -401,6 +401,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
Christian Oudard <christian.oudard@gmail.com>
|
Christian Oudard <christian.oudard@gmail.com>
|
||||||
oggie rob <oz.robharvey@gmail.com>
|
oggie rob <oz.robharvey@gmail.com>
|
||||||
oggy <ognjen.maric@gmail.com>
|
oggy <ognjen.maric@gmail.com>
|
||||||
|
Jens Page
|
||||||
Jay Parlar <parlar@gmail.com>
|
Jay Parlar <parlar@gmail.com>
|
||||||
Carlos Eduardo de Paula <carlosedp@gmail.com>
|
Carlos Eduardo de Paula <carlosedp@gmail.com>
|
||||||
John Paulett <john@paulett.org>
|
John Paulett <john@paulett.org>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"pk": 1,
|
||||||
|
"model": "sites.site",
|
||||||
|
"fields": {
|
||||||
|
"domain": "example.com",
|
||||||
|
"name": "example.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
|
@ -18,9 +18,10 @@ from django.test.utils import override_settings
|
||||||
TEMPLATE_DIRS=(
|
TEMPLATE_DIRS=(
|
||||||
os.path.join(os.path.dirname(__file__), 'templates'),
|
os.path.join(os.path.dirname(__file__), 'templates'),
|
||||||
),
|
),
|
||||||
|
SITE_ID=1,
|
||||||
)
|
)
|
||||||
class FlatpageCSRFTests(TestCase):
|
class FlatpageCSRFTests(TestCase):
|
||||||
fixtures = ['sample_flatpages']
|
fixtures = ['sample_flatpages', 'example_site']
|
||||||
urls = 'django.contrib.flatpages.tests.urls'
|
urls = 'django.contrib.flatpages.tests.urls'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -5,7 +5,10 @@ from django.test import TestCase
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
|
|
||||||
|
@override_settings(SITE_ID=1)
|
||||||
class FlatpageAdminFormTests(TestCase):
|
class FlatpageAdminFormTests(TestCase):
|
||||||
|
fixtures = ['example_site']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.form_data = {
|
self.form_data = {
|
||||||
'title': "A test page",
|
'title': "A test page",
|
||||||
|
@ -89,5 +92,5 @@ class FlatpageAdminFormTests(TestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
f.errors,
|
f.errors,
|
||||||
{'sites': [u'This field is required.']})
|
{'sites': [translation.ugettext(u'This field is required.')]})
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,10 @@ from django.test.utils import override_settings
|
||||||
TEMPLATE_DIRS=(
|
TEMPLATE_DIRS=(
|
||||||
os.path.join(os.path.dirname(__file__), 'templates'),
|
os.path.join(os.path.dirname(__file__), 'templates'),
|
||||||
),
|
),
|
||||||
|
SITE_ID=1,
|
||||||
)
|
)
|
||||||
class FlatpageMiddlewareTests(TestCase):
|
class FlatpageMiddlewareTests(TestCase):
|
||||||
fixtures = ['sample_flatpages']
|
fixtures = ['sample_flatpages', 'example_site']
|
||||||
urls = 'django.contrib.flatpages.tests.urls'
|
urls = 'django.contrib.flatpages.tests.urls'
|
||||||
|
|
||||||
def test_view_flatpage(self):
|
def test_view_flatpage(self):
|
||||||
|
@ -75,7 +76,7 @@ class FlatpageMiddlewareTests(TestCase):
|
||||||
enable_comments=False,
|
enable_comments=False,
|
||||||
registration_required=False,
|
registration_required=False,
|
||||||
)
|
)
|
||||||
fp.sites.add(1)
|
fp.sites.add(settings.SITE_ID)
|
||||||
|
|
||||||
response = self.client.get('/some.very_special~chars-here/')
|
response = self.client.get('/some.very_special~chars-here/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
@ -96,9 +97,10 @@ class FlatpageMiddlewareTests(TestCase):
|
||||||
TEMPLATE_DIRS=(
|
TEMPLATE_DIRS=(
|
||||||
os.path.join(os.path.dirname(__file__), 'templates'),
|
os.path.join(os.path.dirname(__file__), 'templates'),
|
||||||
),
|
),
|
||||||
|
SITE_ID=1,
|
||||||
)
|
)
|
||||||
class FlatpageMiddlewareAppendSlashTests(TestCase):
|
class FlatpageMiddlewareAppendSlashTests(TestCase):
|
||||||
fixtures = ['sample_flatpages']
|
fixtures = ['sample_flatpages', 'example_site']
|
||||||
urls = 'django.contrib.flatpages.tests.urls'
|
urls = 'django.contrib.flatpages.tests.urls'
|
||||||
|
|
||||||
def test_redirect_view_flatpage(self):
|
def test_redirect_view_flatpage(self):
|
||||||
|
@ -130,7 +132,7 @@ class FlatpageMiddlewareAppendSlashTests(TestCase):
|
||||||
enable_comments=False,
|
enable_comments=False,
|
||||||
registration_required=False,
|
registration_required=False,
|
||||||
)
|
)
|
||||||
fp.sites.add(1)
|
fp.sites.add(settings.SITE_ID)
|
||||||
|
|
||||||
response = self.client.get('/some.very_special~chars-here')
|
response = self.client.get('/some.very_special~chars-here')
|
||||||
self.assertRedirects(response, '/some.very_special~chars-here/', status_code=301)
|
self.assertRedirects(response, '/some.very_special~chars-here/', status_code=301)
|
||||||
|
@ -144,7 +146,7 @@ class FlatpageMiddlewareAppendSlashTests(TestCase):
|
||||||
enable_comments=False,
|
enable_comments=False,
|
||||||
registration_required=False,
|
registration_required=False,
|
||||||
)
|
)
|
||||||
fp.sites.add(1)
|
fp.sites.add(settings.SITE_ID)
|
||||||
|
|
||||||
response = self.client.get('/')
|
response = self.client.get('/')
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
|
@ -18,6 +18,7 @@ from django.test.utils import override_settings
|
||||||
TEMPLATE_DIRS=(
|
TEMPLATE_DIRS=(
|
||||||
os.path.join(os.path.dirname(__file__), 'templates'),
|
os.path.join(os.path.dirname(__file__), 'templates'),
|
||||||
),
|
),
|
||||||
|
SITE_ID=1,
|
||||||
)
|
)
|
||||||
class FlatpageTemplateTagTests(TestCase):
|
class FlatpageTemplateTagTests(TestCase):
|
||||||
fixtures = ['sample_flatpages']
|
fixtures = ['sample_flatpages']
|
||||||
|
|
|
@ -19,9 +19,10 @@ from django.test.utils import override_settings
|
||||||
TEMPLATE_DIRS=(
|
TEMPLATE_DIRS=(
|
||||||
os.path.join(os.path.dirname(__file__), 'templates'),
|
os.path.join(os.path.dirname(__file__), 'templates'),
|
||||||
),
|
),
|
||||||
|
SITE_ID=1,
|
||||||
)
|
)
|
||||||
class FlatpageViewTests(TestCase):
|
class FlatpageViewTests(TestCase):
|
||||||
fixtures = ['sample_flatpages']
|
fixtures = ['sample_flatpages', 'example_site']
|
||||||
urls = 'django.contrib.flatpages.tests.urls'
|
urls = 'django.contrib.flatpages.tests.urls'
|
||||||
|
|
||||||
def test_view_flatpage(self):
|
def test_view_flatpage(self):
|
||||||
|
@ -85,9 +86,10 @@ class FlatpageViewTests(TestCase):
|
||||||
TEMPLATE_DIRS=(
|
TEMPLATE_DIRS=(
|
||||||
os.path.join(os.path.dirname(__file__), 'templates'),
|
os.path.join(os.path.dirname(__file__), 'templates'),
|
||||||
),
|
),
|
||||||
|
SITE_ID=1,
|
||||||
)
|
)
|
||||||
class FlatpageViewAppendSlashTests(TestCase):
|
class FlatpageViewAppendSlashTests(TestCase):
|
||||||
fixtures = ['sample_flatpages']
|
fixtures = ['sample_flatpages', 'example_site']
|
||||||
urls = 'django.contrib.flatpages.tests.urls'
|
urls = 'django.contrib.flatpages.tests.urls'
|
||||||
|
|
||||||
def test_redirect_view_flatpage(self):
|
def test_redirect_view_flatpage(self):
|
||||||
|
@ -119,7 +121,7 @@ class FlatpageViewAppendSlashTests(TestCase):
|
||||||
enable_comments=False,
|
enable_comments=False,
|
||||||
registration_required=False,
|
registration_required=False,
|
||||||
)
|
)
|
||||||
fp.sites.add(1)
|
fp.sites.add(settings.SITE_ID)
|
||||||
|
|
||||||
response = self.client.get('/flatpage_root/some.very_special~chars-here')
|
response = self.client.get('/flatpage_root/some.very_special~chars-here')
|
||||||
self.assertRedirects(response, '/flatpage_root/some.very_special~chars-here/', status_code=301)
|
self.assertRedirects(response, '/flatpage_root/some.very_special~chars-here/', status_code=301)
|
||||||
|
|
Loading…
Reference in New Issue