##// END OF EJS Templates
Fixed page 404 test. Added a cat image to the banned page.
neko259 -
r181:fcbeb0b1 default
parent child Browse files
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -7,5 +7,6 b''
7 {% endblock %}
7 {% endblock %}
8
8
9 {% block staticcontent %}
9 {% block staticcontent %}
10 {% trans 'Your IP address has been banned. Contact the administrator' %}
10 <p><img src="{{ STATIC_URL }}images/banned.png" width="200" /></p>
11 <p>{% trans 'Your IP address has been banned. Contact the administrator' %}</p>
11 {% endblock %} No newline at end of file
12 {% endblock %}
@@ -113,13 +113,18 b' class BoardTests(TestCase):'
113 self.assertEqual(1, Post.objects.count(), msg='The validation passed '
113 self.assertEqual(1, Post.objects.count(), msg='The validation passed '
114 'where it should fail')
114 'where it should fail')
115
115
116 # Change posting delay so we don't have to wait for 30 seconds or more
117 old_posting_delay = settings.POSTING_DELAY
116 # Wait fot the posting delay or we won't be able to post
118 # Wait fot the posting delay or we won't be able to post
119 settings.POSTING_DELAY = 1
117 time.sleep(settings.POSTING_DELAY + 1)
120 time.sleep(settings.POSTING_DELAY + 1)
118 response = client.post(THREAD_PAGE_ONE, {'text': TEST_TEXT,
121 response = client.post(THREAD_PAGE_ONE, {'text': TEST_TEXT,
119 'tags': valid_tags})
122 'tags': valid_tags})
120 self.assertEqual(HTTP_CODE_REDIRECT, response.status_code,
123 self.assertEqual(HTTP_CODE_REDIRECT, response.status_code,
121 msg=u'Posting new message failed: got code ' +
124 msg=u'Posting new message failed: got code ' +
122 str(response.status_code))
125 str(response.status_code))
126 # Restore posting delay
127 settings.POSTING_DELAY = old_posting_delay
123
128
124 self.assertEqual(2, Post.objects.count(),
129 self.assertEqual(2, Post.objects.count(),
125 msg=u'No posts were created')
130 msg=u'No posts were created')
@@ -127,8 +132,6 b' class BoardTests(TestCase):'
127 # Restore captcha setting
132 # Restore captcha setting
128 settings.ENABLE_CAPTCHA = captcha_enabled
133 settings.ENABLE_CAPTCHA = captcha_enabled
129
134
130 # TODO This test fails for now. We must check for 404.html instead of
131 # code 404
132 def test_404(self):
135 def test_404(self):
133 """Test receiving error 404 when opening a non-existent page"""
136 """Test receiving error 404 when opening a non-existent page"""
134
137
@@ -149,9 +152,8 b' class BoardTests(TestCase):'
149
152
150 response_not_existing = client.get(THREAD_PAGE + str(
153 response_not_existing = client.get(THREAD_PAGE + str(
151 existing_post_id + 1) + '/')
154 existing_post_id + 1) + '/')
152 response_not_existing.get_full_path()
155 self.assertEqual('boards/404.html',
153 self.assertEqual(HTTP_CODE_NOT_FOUND,
156 response_not_existing.templates[0].name,
154 response_not_existing.status_code,
155 u'Not existing thread is opened')
157 u'Not existing thread is opened')
156
158
157 response_existing = client.get(TAG_PAGE + tag_name + '/')
159 response_existing = client.get(TAG_PAGE + tag_name + '/')
@@ -160,14 +162,14 b' class BoardTests(TestCase):'
160 u'Cannot open existing tag')
162 u'Cannot open existing tag')
161
163
162 response_not_existing = client.get(TAG_PAGE + u'not_tag' + '/')
164 response_not_existing = client.get(TAG_PAGE + u'not_tag' + '/')
163 self.assertEqual(HTTP_CODE_NOT_FOUND,
165 self.assertEqual('boards/404.html',
164 response_not_existing.status_code,
166 response_not_existing.templates[0].name,
165 u'Not existing tag is opened')
167 u'Not existing tag is opened')
166
168
167 reply_id = Post.objects.create_post('', TEST_TEXT,
169 reply_id = Post.objects.create_post('', TEST_TEXT,
168 parent_id=existing_post_id)
170 thread=Post.objects.all()[0])
169 response_not_existing = client.get(THREAD_PAGE + str(
171 response_not_existing = client.get(THREAD_PAGE + str(
170 reply_id) + '/')
172 reply_id) + '/')
171 self.assertEqual(HTTP_CODE_NOT_FOUND,
173 self.assertEqual('boards/404.html',
172 response_not_existing.status_code,
174 response_not_existing.templates[0].name,
173 u'Not existing thread is opened')
175 u'Reply is opened as a thread')
@@ -82,9 +82,6 b' def _new_post(request, form, thread_id=b'
82 tag, created = Tag.objects.get_or_create(name=tag_name)
82 tag, created = Tag.objects.get_or_create(name=tag_name)
83 tags.append(tag)
83 tags.append(tag)
84
84
85 # TODO Add a possibility to define a link image instead of an image file.
86 # If a link is given, download the image automatically.
87
88 op = None if thread_id == boards.models.NO_PARENT else \
85 op = None if thread_id == boards.models.NO_PARENT else \
89 get_object_or_404(Post, id=thread_id)
86 get_object_or_404(Post, id=thread_id)
90 post = Post.objects.create_post(title=title, text=text, ip=ip,
87 post = Post.objects.create_post(title=title, text=text, ip=ip,
General Comments 0
You need to be logged in to leave comments. Login now