##// END OF EJS Templates
Show only one border in the first last replies post when there are no skipped...
Show only one border in the first last replies post when there are no skipped replies

File last commit:

r821:572aaa88 default
r826:eba030e9 default
Show More
test_pages.py
56 lines | 2.0 KiB | text/x-python | PythonLexer
from django.test import TestCase, Client
from boards.models import Tag, Post
TEST_TEXT = 'test'
NEW_THREAD_PAGE = '/'
THREAD_PAGE_ONE = '/thread/1/'
THREAD_PAGE = '/thread/'
TAG_PAGE = '/tag/'
HTTP_CODE_REDIRECT = 302
HTTP_CODE_OK = 200
HTTP_CODE_NOT_FOUND = 404
PAGE_404 = 'boards/404.html'
class PagesTest(TestCase):
def test_404(self):
"""Test receiving error 404 when opening a non-existent page"""
tag_name = 'test_tag'
tag = Tag.objects.create(name=tag_name)
client = Client()
Post.objects.create_post('title', TEST_TEXT, tags=[tag])
existing_post_id = Post.objects.all()[0].id
response_existing = client.get(THREAD_PAGE + str(existing_post_id) +
'/')
self.assertEqual(HTTP_CODE_OK, response_existing.status_code,
'Cannot open existing thread')
response_not_existing = client.get(THREAD_PAGE + str(
existing_post_id + 1) + '/')
self.assertEqual(PAGE_404, response_not_existing.templates[0].name,
'Not existing thread is opened')
response_existing = client.get(TAG_PAGE + tag_name + '/')
self.assertEqual(HTTP_CODE_OK,
response_existing.status_code,
'Cannot open existing tag')
response_not_existing = client.get(TAG_PAGE + 'not_tag' + '/')
self.assertEqual(PAGE_404,
response_not_existing.templates[0].name,
'Not existing tag is opened')
reply_id = Post.objects.create_post('', TEST_TEXT,
thread=Post.objects.all()[0]
.get_thread())
response_not_existing = client.get(THREAD_PAGE + str(
reply_id) + '/')
self.assertEqual(PAGE_404,
response_not_existing.templates[0].name,
'Reply is opened as a thread')