def test_replies_count(self): # The Thread.replies value should remain one less than the # number of posts in the thread. t = ThreadFactory(posts=[{}, {}, {}]) old = t.replies eq_(2, old) t.new_post(author=t.creator, content='test').save() eq_(old + 1, t.replies)
def test_new_post_updates_forum(self): # Saving a new post should update the last_post key in the # forum to point to the new post. t = ThreadFactory() PostFactory(thread=t) p = t.new_post(author=t.creator, content='another update') p.save() f = Forum.objects.get(id=t.forum_id) eq_(p.id, f.last_post_id)
def test_new_post_updates_thread(self): # Saving a new post in a thread should update the last_post # key in that thread to point to the new post. t = ThreadFactory() PostFactory(thread=t) p = t.new_post(author=t.creator, content='an update') p.save() t = Thread.objects.get(id=t.id) eq_(p.id, t.last_post_id)
def test_unlocked_thread(self): unlocked = ThreadFactory() user = UserFactory() # This should not raise an exception unlocked.new_post(author=user, content='empty')
def test_locked_thread(self): """Trying to reply to a locked thread should raise an exception.""" locked = ThreadFactory(is_locked=True) user = UserFactory() # This should raise an exception locked.new_post(author=user, content='empty')