##// END OF EJS Templates
Moved signatures block to the model block. All the signed content is in the 'content' block now. Removed edit time, previous and next posts links from the XML sync output because they can be computed from the post itself and can be changed locally for foreign posts (which breaks the signature)
Moved signatures block to the model block. All the signed content is in the 'content' block now. Removed edit time, previous and next posts links from the XML sync output because they can be computed from the post itself and can be changed locally for foreign posts (which breaks the signature)

File last commit:

r822:b2a21b61 merge decentral
r838:2b96b9e7 decentral
Show More
test_forms.py
55 lines | 2.0 KiB | text/x-python | PythonLexer
from django.test import TestCase, Client
import time
from boards import settings
from boards.models import Post
import neboard
TEST_TAG = 'test_tag'
PAGE_404 = 'boards/404.html'
TEST_TEXT = 'test text'
NEW_THREAD_PAGE = '/'
THREAD_PAGE_ONE = '/thread/1/'
HTTP_CODE_REDIRECT = 302
class FormTest(TestCase):
def test_post_validation(self):
client = Client()
valid_tags = 'tag1 tag_2 тег_3'
invalid_tags = '$%_356 ---'
response = client.post(NEW_THREAD_PAGE, {'title': 'test title',
'text': TEST_TEXT,
'tags': valid_tags})
self.assertEqual(response.status_code, HTTP_CODE_REDIRECT,
msg='Posting new message failed: got code ' +
str(response.status_code))
self.assertEqual(1, Post.objects.count(),
msg='No posts were created')
client.post(NEW_THREAD_PAGE, {'text': TEST_TEXT,
'tags': invalid_tags})
self.assertEqual(1, Post.objects.count(), msg='The validation passed '
'where it should fail')
# Change posting delay so we don't have to wait for 30 seconds or more
old_posting_delay = neboard.settings.POSTING_DELAY
# Wait fot the posting delay or we won't be able to post
neboard.settings.POSTING_DELAY = 1
time.sleep(neboard.settings.POSTING_DELAY + 1)
response = client.post(THREAD_PAGE_ONE, {'text': TEST_TEXT,
'tags': valid_tags})
self.assertEqual(HTTP_CODE_REDIRECT, response.status_code,
msg='Posting new message failed: got code ' +
str(response.status_code))
# Restore posting delay
settings.POSTING_DELAY = old_posting_delay
self.assertEqual(2, Post.objects.count(),
msg='No posts were created')