Esempio n. 1
0
    def test_save_old_thread_created(self):
        """Saving an old thread should not change its created date."""
        t = ThreadFactory(created=YESTERDAY)
        t = Thread.objects.get(id=t.id)
        created = t.created

        # Now make an update to the thread and resave. Created shouldn't change.
        t.title = 'new title'
        t.save()
        t = Thread.objects.get(id=t.id)
        eq_(created, t.created)
Esempio n. 2
0
    def test_save_old_thread_created(self):
        """Saving an old thread should not change its created date."""
        t = ThreadFactory(created=YESTERDAY)
        t = Thread.objects.get(id=t.id)
        created = t.created

        # Now make an update to the thread and resave. Created shouldn't change.
        t.title = 'new title'
        t.save()
        t = Thread.objects.get(id=t.id)
        eq_(created, t.created)
Esempio n. 3
0
    def test_move_updates_last_posts(self):
        # Moving the thread containing a forum's last post to a new
        # forum should update the last_post of both
        # forums. Consequently, deleting the last post shouldn't
        # delete the old forum. [bug 588994]

        # Setup forum to move latest thread from.
        old_forum = ForumFactory()
        t1 = ThreadFactory(forum=old_forum, posts=[])
        p1 = PostFactory(thread=t1, created=YESTERDAY)
        t2 = ThreadFactory(forum=old_forum, posts=[])
        p2 = PostFactory(thread=t2)  # Newest post of all.

        # Setup forum to move latest thread to.
        new_forum = ForumFactory()
        t3 = ThreadFactory(forum=new_forum, posts=[])
        p3 = PostFactory(thread=t3, created=YESTERDAY)

        # Verify the last_post's are correct.
        eq_(p2, Forum.objects.get(id=old_forum.id).last_post)
        eq_(p3, Forum.objects.get(id=new_forum.id).last_post)

        # Move the t2 thread.
        t2 = Thread.objects.get(id=t2.id)
        t2.forum = new_forum
        t2.save()

        # Old forum's last_post updated?
        eq_(p1.id, Forum.objects.get(id=old_forum.id).last_post_id)

        # New forum's last_post updated?
        eq_(p2.id, Forum.objects.get(id=new_forum.id).last_post_id)

        # Delete the post, and both forums should still exist:
        p2.delete()
        eq_(1, Forum.objects.filter(id=old_forum.id).count())
        eq_(1, Forum.objects.filter(id=new_forum.id).count())
Esempio n. 4
0
    def test_move_updates_last_posts(self):
        # Moving the thread containing a forum's last post to a new
        # forum should update the last_post of both
        # forums. Consequently, deleting the last post shouldn't
        # delete the old forum. [bug 588994]

        # Setup forum to move latest thread from.
        old_forum = ForumFactory()
        t1 = ThreadFactory(forum=old_forum, posts=[])
        p1 = PostFactory(thread=t1, created=YESTERDAY)
        t2 = ThreadFactory(forum=old_forum, posts=[])
        p2 = PostFactory(thread=t2)  # Newest post of all.

        # Setup forum to move latest thread to.
        new_forum = ForumFactory()
        t3 = ThreadFactory(forum=new_forum, posts=[])
        p3 = PostFactory(thread=t3, created=YESTERDAY)

        # Verify the last_post's are correct.
        eq_(p2, Forum.objects.get(id=old_forum.id).last_post)
        eq_(p3, Forum.objects.get(id=new_forum.id).last_post)

        # Move the t2 thread.
        t2 = Thread.objects.get(id=t2.id)
        t2.forum = new_forum
        t2.save()

        # Old forum's last_post updated?
        eq_(p1.id, Forum.objects.get(id=old_forum.id).last_post_id)

        # New forum's last_post updated?
        eq_(p2.id, Forum.objects.get(id=new_forum.id).last_post_id)

        # Delete the post, and both forums should still exist:
        p2.delete()
        eq_(1, Forum.objects.filter(id=old_forum.id).count())
        eq_(1, Forum.objects.filter(id=new_forum.id).count())