Пример #1
0
    def test_goto_first_new_post_in_read_thread(self):
        """goto new in read thread points to last post"""
        for i in range(settings.MISAGO_POSTS_PER_PAGE + settings.MISAGO_POSTS_TAIL):
            post = testutils.reply_thread(self.thread, posted_on=timezone.now())

        make_thread_read_aware(self.user, self.thread)
        read_thread(self.user, self.thread, self.thread.last_post)

        response = self.client.get(self.thread.get_new_post_url())
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'], GOTO_PAGE_URL % (self.thread.get_absolute_url(), 2, post.pk))
Пример #2
0
    def test_goto_first_new_post(self):
        """first unread post redirect url in already read thread is valid"""
        make_thread_read_aware(self.user, self.thread)
        read_thread(self.user, self.thread, self.thread.last_post)

        post = testutils.reply_thread(self.thread, posted_on=timezone.now())
        for i in range(settings.MISAGO_POSTS_PER_PAGE + settings.MISAGO_POSTS_TAIL - 1):
            testutils.reply_thread(self.thread, posted_on=timezone.now())

        response = self.client.get(self.thread.get_new_post_url())
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'], GOTO_URL % (self.thread.get_absolute_url(), post.pk))
Пример #3
0
    def test_goto_first_new_post(self):
        """first unread post redirect url in already read thread is valid"""
        make_thread_read_aware(self.user, self.thread)
        read_thread(self.user, self.thread, self.thread.last_post)

        post = testutils.reply_thread(self.thread, posted_on=timezone.now())
        for i in range(settings.MISAGO_POSTS_PER_PAGE +
                       settings.MISAGO_POSTS_TAIL - 1):
            testutils.reply_thread(self.thread, posted_on=timezone.now())

        response = self.client.get(self.thread.get_new_post_url())
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'],
                         GOTO_URL % (self.thread.get_absolute_url(), post.pk))
Пример #4
0
    def test_goto_first_new_post_in_read_thread(self):
        """goto new in read thread points to last post"""
        for i in range(settings.MISAGO_POSTS_PER_PAGE +
                       settings.MISAGO_POSTS_TAIL):
            post = testutils.reply_thread(self.thread,
                                          posted_on=timezone.now())

        make_thread_read_aware(self.user, self.thread)
        read_thread(self.user, self.thread, self.thread.last_post)

        response = self.client.get(self.thread.get_new_post_url())
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response['location'],
            GOTO_PAGE_URL % (self.thread.get_absolute_url(), 2, post.pk))
Пример #5
0
    def test_vie_handles_unapproved_posts(self):
        """if thread has unapproved posts, redirect to first of them"""
        for i in range(settings.MISAGO_POSTS_PER_PAGE + settings.MISAGO_POSTS_TAIL):
            testutils.reply_thread(self.thread, posted_on=timezone.now())

        make_thread_read_aware(self.user, self.thread)
        read_thread(self.user, self.thread, self.thread.last_post)

        post = testutils.reply_thread(self.thread, is_unapproved=True, posted_on=timezone.now())
        for i in range(settings.MISAGO_POSTS_PER_PAGE + settings.MISAGO_POSTS_TAIL - 1):
            testutils.reply_thread(self.thread, posted_on=timezone.now())

        self.grand_permission()

        response = self.client.get(self.thread.get_new_post_url())
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response['location'], GOTO_PAGE_URL % (self.thread.get_absolute_url(), 2, post.pk))
Пример #6
0
    def test_vie_handles_unapproved_posts(self):
        """if thread has unapproved posts, redirect to first of them"""
        for i in range(settings.MISAGO_POSTS_PER_PAGE +
                       settings.MISAGO_POSTS_TAIL):
            testutils.reply_thread(self.thread, posted_on=timezone.now())

        make_thread_read_aware(self.user, self.thread)
        read_thread(self.user, self.thread, self.thread.last_post)

        post = testutils.reply_thread(self.thread,
                                      is_unapproved=True,
                                      posted_on=timezone.now())
        for i in range(settings.MISAGO_POSTS_PER_PAGE +
                       settings.MISAGO_POSTS_TAIL - 1):
            testutils.reply_thread(self.thread, posted_on=timezone.now())

        self.grant_permission()

        response = self.client.get(self.thread.get_new_post_url())
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response['location'],
            GOTO_PAGE_URL % (self.thread.get_absolute_url(), 2, post.pk))