Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fixed #18408 -- Flatpages tests expect example.com for site 1 #83

Closed
wants to merge 1 commit into from

2 participants

Jens Page Claude Paroz
Jens Page

Resolves a couple of issues with running Flatpages tests 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
Jens Page 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

Conflicts:

	AUTHORS
	django/contrib/flatpages/tests/csrf.py
	django/contrib/flatpages/tests/middleware.py
	django/contrib/flatpages/tests/templatetags.py
	django/contrib/flatpages/tests/views.py
2cc80be
Claude Paroz
Owner
claudep commented May 31, 2012

Many thanks, pushed in ba10be7.
Hope you don't mind I just added a line to your patch (so as a test comparison is made against a translated error message).

Claude Paroz claudep closed this May 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

May 19, 2012
Jens Page 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

Conflicts:

	AUTHORS
	django/contrib/flatpages/tests/csrf.py
	django/contrib/flatpages/tests/middleware.py
	django/contrib/flatpages/tests/templatetags.py
	django/contrib/flatpages/tests/views.py
2cc80be
This page is out of date. Refresh to see the latest.
1  AUTHORS
@@ -566,6 +566,7 @@ answer newbie questions, and generally made Django that much better:
566 566
     Gasper Zejn <zejn@kiberpipa.org>
567 567
     Jarek Zgoda <jarek.zgoda@gmail.com>
568 568
     Cheng Zhang
  569
+    Jens Page
569 570
 
570 571
 A big THANK YOU goes to:
571 572
 
11  django/contrib/flatpages/fixtures/example_site.json
... ...
@@ -0,0 +1,11 @@
  1
+[
  2
+  {
  3
+    "pk": 1, 
  4
+    "model": "sites.site", 
  5
+    "fields": {
  6
+      "domain": "example.com", 
  7
+      "name": "example.com"
  8
+    }
  9
+  }
  10
+]
  11
+
3  django/contrib/flatpages/tests/csrf.py
@@ -18,9 +18,10 @@
18 18
     TEMPLATE_DIRS=(
19 19
         os.path.join(os.path.dirname(__file__), 'templates'),
20 20
     ),
  21
+    SITE_ID=1,
21 22
 )
22 23
 class FlatpageCSRFTests(TestCase):
23  
-    fixtures = ['sample_flatpages']
  24
+    fixtures = ['sample_flatpages', 'example_site']
24 25
     urls = 'django.contrib.flatpages.tests.urls'
25 26
 
26 27
     def setUp(self):
3  django/contrib/flatpages/tests/forms.py
@@ -5,7 +5,10 @@
5 5
 from django.test.utils import override_settings
6 6
 from django.utils import translation
7 7
 
  8
+@override_settings(SITE_ID=1)
8 9
 class FlatpageAdminFormTests(TestCase):
  10
+    fixtures = ['example_site']
  11
+    
9 12
     def setUp(self):
10 13
         self.form_data = {
11 14
             'title': "A test page",
12  django/contrib/flatpages/tests/middleware.py
@@ -19,9 +19,10 @@
19 19
     TEMPLATE_DIRS=(
20 20
         os.path.join(os.path.dirname(__file__), 'templates'),
21 21
     ),
  22
+    SITE_ID=1,
22 23
 )
23 24
 class FlatpageMiddlewareTests(TestCase):
24  
-    fixtures = ['sample_flatpages']
  25
+    fixtures = ['sample_flatpages', 'example_site']
25 26
     urls = 'django.contrib.flatpages.tests.urls'
26 27
 
27 28
     def test_view_flatpage(self):
@@ -75,7 +76,7 @@ def test_fallback_flatpage_special_chars(self):
75 76
             enable_comments=False,
76 77
             registration_required=False,
77 78
         )
78  
-        fp.sites.add(1)
  79
+        fp.sites.add(settings.SITE_ID)
79 80
 
80 81
         response = self.client.get('/some.very_special~chars-here/')
81 82
         self.assertEqual(response.status_code, 200)
@@ -96,9 +97,10 @@ def test_fallback_flatpage_special_chars(self):
96 97
     TEMPLATE_DIRS=(
97 98
         os.path.join(os.path.dirname(__file__), 'templates'),
98 99
     ),
  100
+    SITE_ID=1,
99 101
 )
100 102
 class FlatpageMiddlewareAppendSlashTests(TestCase):
101  
-    fixtures = ['sample_flatpages']
  103
+    fixtures = ['sample_flatpages', 'example_site']
102 104
     urls = 'django.contrib.flatpages.tests.urls'
103 105
 
104 106
     def test_redirect_view_flatpage(self):
@@ -130,7 +132,7 @@ def test_redirect_fallback_flatpage_special_chars(self):
130 132
             enable_comments=False,
131 133
             registration_required=False,
132 134
         )
133  
-        fp.sites.add(1)
  135
+        fp.sites.add(settings.SITE_ID)
134 136
 
135 137
         response = self.client.get('/some.very_special~chars-here')
136 138
         self.assertRedirects(response, '/some.very_special~chars-here/', status_code=301)
@@ -144,7 +146,7 @@ def test_redirect_fallback_flatpage_root(self):
144 146
             enable_comments=False,
145 147
             registration_required=False,
146 148
         )
147  
-        fp.sites.add(1)
  149
+        fp.sites.add(settings.SITE_ID)
148 150
 
149 151
         response = self.client.get('/')
150 152
         self.assertEqual(response.status_code, 200)
1  django/contrib/flatpages/tests/templatetags.py
@@ -18,6 +18,7 @@
18 18
     TEMPLATE_DIRS=(
19 19
         os.path.join(os.path.dirname(__file__), 'templates'),
20 20
     ),
  21
+    SITE_ID=1,
21 22
 )
22 23
 class FlatpageTemplateTagTests(TestCase):
23 24
     fixtures = ['sample_flatpages']
8  django/contrib/flatpages/tests/views.py
@@ -19,9 +19,10 @@
19 19
     TEMPLATE_DIRS=(
20 20
         os.path.join(os.path.dirname(__file__), 'templates'),
21 21
     ),
  22
+    SITE_ID=1,
22 23
 )
23 24
 class FlatpageViewTests(TestCase):
24  
-    fixtures = ['sample_flatpages']
  25
+    fixtures = ['sample_flatpages', 'example_site']
25 26
     urls = 'django.contrib.flatpages.tests.urls'
26 27
 
27 28
     def test_view_flatpage(self):
@@ -85,9 +86,10 @@ def test_view_flatpage_special_chars(self):
85 86
     TEMPLATE_DIRS=(
86 87
         os.path.join(os.path.dirname(__file__), 'templates'),
87 88
     ),
  89
+    SITE_ID=1,
88 90
 )
89 91
 class FlatpageViewAppendSlashTests(TestCase):
90  
-    fixtures = ['sample_flatpages']
  92
+    fixtures = ['sample_flatpages', 'example_site']
91 93
     urls = 'django.contrib.flatpages.tests.urls'
92 94
 
93 95
     def test_redirect_view_flatpage(self):
@@ -119,7 +121,7 @@ def test_redirect_view_flatpage_special_chars(self):
119 121
             enable_comments=False,
120 122
             registration_required=False,
121 123
         )
122  
-        fp.sites.add(1)
  124
+        fp.sites.add(settings.SITE_ID)
123 125
 
124 126
         response = self.client.get('/flatpage_root/some.very_special~chars-here')
125 127
         self.assertRedirects(response, '/flatpage_root/some.very_special~chars-here/', status_code=301)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.