##// END OF EJS Templates
Initial commit. One test doesn't work, missing posting form.
Initial commit. One test doesn't work, missing posting form.

File last commit:

r0:8aafc193 default
r0:8aafc193 default
Show More
tests.py
64 lines | 1.6 KiB | text/x-python | PythonLexer
from django.test import TestCase
from django.utils import timezone
from django.conf import settings
from boards.models import Board, Thread, Post
class BoardTests(TestCase):
def create_board(self):
return Board.objects.create(name='t', description='test')
def create_thread(self, board):
return Thread.objects.create_thread(board=board)
def create_post(self, thread):
return Post.objects.create_post(title='title',
text='text', thread=thread, image=None)
def test_add_thread(self):
thread = self.create_thread(self.create_board())
self.assertIsNotNone(thread)
def test_post_add(self):
thread = self.create_thread(self.create_board())
post = self.create_post(thread)
self.assertIsNotNone(post)
self.assertEqual(thread, post.thread)
def test_thread_post_count(self):
thread = self.create_thread(self.create_board())
self.create_post(thread)
self.assertEqual(1, thread.posts)
def test_thread_dead(self):
thread = self.create_thread(self.create_board())
for i in range(0, settings.MAX_POSTS_PER_THREAD):
self.create_post(thread)
self.assertTrue(thread.is_dead())
def test_thread_empty(self):
thread = self.create_thread(self.create_board())
self.assertTrue(thread.is_empty)
def test_delete_post(self):
thread = self.create_thread(self.create_board())
post = self.create_post(thread)
Post.objects.delete_post(post)
self.assertTrue(thread.is_empty())
def test_delete_posts_by_ip(self):
thread = self.create_thread(self.create_board())
self.create_post(thread)
Post.objects.delete_posts_by_ip('0.0.0.0')
self.assertTrue(thread.is_empty())