Beispiel #1
0
    def test_new(self):
        """new returns link to first unread post"""
        self.user.new_threads = MockThreadsCounter()
        self.user.unread_threads = MockThreadsCounter()

        post_link = goto.new(self.user, self.thread)
        self.assertEqual(post_link, goto.last(self.user, self.thread))

        # add 18 posts to add extra page to thread, then read them
        [reply_thread(self.thread) for p in xrange(18)]
        threadstracker.read_thread(
            self.user, self.thread, self.thread.last_post)

        # add extra unread posts
        first_unread = reply_thread(self.thread)
        [reply_thread(self.thread) for p in xrange(30)]

        new_link = goto.new(self.user, self.thread)
        post_link = goto.get_post_link(
            50, self.thread.post_set, self.thread, first_unread)
        self.assertEqual(new_link, post_link)

        # read thread
        threadstracker.read_thread(
            self.user, self.thread, self.thread.last_post)

        # assert new() points to last reply
        post_link = goto.new(self.user, self.thread)
        self.assertEqual(post_link, goto.last(self.user, self.thread))
    def test_new(self):
        """new returns link to first unread post"""
        self.user.new_threads = MockThreadsCounter()
        self.user.unread_threads = MockThreadsCounter()

        post_link = goto.new(self.user, self.thread, self.thread.post_set)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)

        # add 18 posts to add extra page to thread, then read them
        [reply_thread(self.thread) for p in xrange(18)]
        threadstracker.read_thread(
            self.user, self.thread, self.thread.last_post)

        # add extra unread posts
        first_unread = reply_thread(self.thread)
        [reply_thread(self.thread) for p in xrange(30)]

        new_link = goto.new(self.user, self.thread, self.thread.post_set)
        post_link = goto.get_post_link(
            50, self.thread.post_set, self.thread, first_unread)
        self.assertEqual(new_link, post_link)

        # read thread
        threadstracker.read_thread(
            self.user, self.thread, self.thread.last_post)

        # assert new() points to last reply
        post_link = goto.new(self.user, self.thread, self.thread.post_set)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)
Beispiel #3
0
    def test_get_post_link(self):
        """get_post_link returns link to specified post"""
        post_link = goto.get_post_link(
            1, self.thread.post_set, self.thread, self.thread.last_post)
        self.assertEqual(post_link, goto.last(self.user, self.thread))

        # add 16 posts to add extra page to thread
        [reply_thread(self.thread) for p in xrange(16)]

        post_link = goto.get_post_link(
            17, self.thread.post_set, self.thread, self.thread.last_post)
        self.assertEqual(post_link, goto.last(self.user, self.thread))
Beispiel #4
0
    def test_post(self):
        """post returns link to post given"""
        self.assertEqual(
            goto.last(self.user, self.thread),
            goto.post(self.user, self.thread, self.thread.last_post))

        # add 24 posts
        [reply_thread(self.thread) for p in xrange(24)]

        self.assertEqual(
            goto.last(self.user, self.thread),
            goto.post(self.user, self.thread, self.thread.last_post))
Beispiel #5
0
    def test_goto_last(self):
        """thread_last link points to last post in thread"""
        response = self.client.get(self.thread.get_last_reply_url())
        self.assertEqual(response.status_code, 302)
        self.assertTrue(
            response['location'].endswith(goto.last(self.user, self.thread)))

        # add 36 posts to thread
        [reply_thread(self.thread) for p in xrange(36)]

        response = self.client.get(self.thread.get_last_reply_url())
        self.assertEqual(response.status_code, 302)
        self.assertTrue(
            response['location'].endswith(goto.last(self.user, self.thread)))
Beispiel #6
0
    def test_get_post_link(self):
        """get_post_link returns link to specified post"""
        post_link = goto.get_post_link(1, self.thread.post_set, self.thread,
                                       self.thread.last_post)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)

        # add posts to add extra page to thread
        [reply_thread(self.thread) for p in xrange(MAX_PAGE_LEN)]

        post_link = goto.get_post_link(MAX_PAGE_LEN + 1, self.thread.post_set,
                                       self.thread, self.thread.last_post)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)
Beispiel #7
0
    def test_post(self):
        """post returns link to post given"""
        thread = self.thread

        post_link = goto.post(thread, thread.post_set, thread.last_post)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)

        # add 24 posts
        [reply_thread(self.thread) for p in xrange(24)]

        post_link = goto.post(thread, thread.post_set, thread.last_post)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)
    def test_get_post_link(self):
        """get_post_link returns link to specified post"""
        post_link = goto.get_post_link(
            1, self.thread.post_set, self.thread, self.thread.last_post)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)

        # add 16 posts to add extra page to thread
        [reply_thread(self.thread) for p in xrange(16)]

        post_link = goto.get_post_link(
            17, self.thread.post_set, self.thread, self.thread.last_post)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)
    def test_post(self):
        """post returns link to post given"""
        thread = self.thread

        post_link = goto.post(thread, thread.post_set, thread.last_post)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)

        # add 24 posts
        [reply_thread(self.thread) for p in xrange(24)]

        post_link = goto.post(thread, thread.post_set, thread.last_post)
        last_link = goto.last(self.thread, self.thread.post_set)
        self.assertEqual(post_link, last_link)
Beispiel #10
0
    def test_goto_last(self):
        """thread_last link points to last post in thread"""
        response = self.client.get(self.thread.get_last_reply_url())
        self.assertEqual(response.status_code, 302)
        self.assertTrue(response['location'].endswith(
            goto.last(self.user, self.thread)))

        # add 36 posts to thread
        [reply_thread(self.thread) for p in xrange(36)]

        response = self.client.get(self.thread.get_last_reply_url())
        self.assertEqual(response.status_code, 302)
        self.assertTrue(response['location'].endswith(
            goto.last(self.user, self.thread)))
Beispiel #11
0
    def test_last(self):
        """last returns link to last post in thread"""
        url_last = goto.last(self.user, self.thread)
        url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
        self.assertEqual(url_last, '%s#post-%s' % url_formats)

        # add 12 posts to reach page limit
        [reply_thread(self.thread) for p in xrange(12)]

        url_last = goto.last(self.user, self.thread)
        url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
        self.assertEqual(url_last, '%s#post-%s' % url_formats)

        # add 2 posts to add second page to thread
        [reply_thread(self.thread) for p in xrange(2)]

        url_last = goto.last(self.user, self.thread)
        url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
        self.assertEqual(url_last, '%s2/#post-%s' % url_formats)
    def test_last(self):
        """last returns link to last post in thread"""
        url_last = goto.last(self.thread, self.thread.post_set)
        url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
        self.assertEqual(url_last, '%s#post-%s' % url_formats)

        # add 12 posts to reach page limit
        [reply_thread(self.thread) for p in xrange(12)]

        url_last = goto.last(self.thread, self.thread.post_set)
        url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
        self.assertEqual(url_last, '%s#post-%s' % url_formats)

        # add 2 posts to add second page to thread
        [reply_thread(self.thread) for p in xrange(2)]

        url_last = goto.last(self.thread, self.thread.post_set)
        url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
        self.assertEqual(url_last, '%s2/#post-%s' % url_formats)
Beispiel #13
0
 def get_redirect(self, user, thread, posts_qs):
     return goto.last(thread, posts_qs)
Beispiel #14
0
 def get_redirect(self, user, thread):
     return goto.last(user, thread)
Beispiel #15
0
 def get_redirect(self, user, thread):
     return goto.last(user, thread)