|
@@ -4,6 +4,7 @@ from misago.readtracker import threadstracker
|
|
from misago.users.testutils import AuthenticatedUserTestCase
|
|
from misago.users.testutils import AuthenticatedUserTestCase
|
|
|
|
|
|
from misago.threads import goto
|
|
from misago.threads import goto
|
|
|
|
+from misago.threads.permissions import exclude_invisible_posts
|
|
from misago.threads.testutils import post_thread, reply_thread
|
|
from misago.threads.testutils import post_thread, reply_thread
|
|
|
|
|
|
|
|
|
|
@@ -64,21 +65,21 @@ class GotoTests(AuthenticatedUserTestCase):
|
|
|
|
|
|
def test_last(self):
|
|
def test_last(self):
|
|
"""last returns link to last post in thread"""
|
|
"""last returns link to last post in thread"""
|
|
- url_last = goto.last(self.user, self.thread)
|
|
|
|
|
|
+ url_last = goto.last(self.thread, self.thread.post_set)
|
|
url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
|
|
url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
|
|
self.assertEqual(url_last, '%s#post-%s' % url_formats)
|
|
self.assertEqual(url_last, '%s#post-%s' % url_formats)
|
|
|
|
|
|
# add 12 posts to reach page limit
|
|
# add 12 posts to reach page limit
|
|
[reply_thread(self.thread) for p in xrange(12)]
|
|
[reply_thread(self.thread) for p in xrange(12)]
|
|
|
|
|
|
- url_last = goto.last(self.user, self.thread)
|
|
|
|
|
|
+ url_last = goto.last(self.thread, self.thread.post_set)
|
|
url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
|
|
url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
|
|
self.assertEqual(url_last, '%s#post-%s' % url_formats)
|
|
self.assertEqual(url_last, '%s#post-%s' % url_formats)
|
|
|
|
|
|
# add 2 posts to add second page to thread
|
|
# add 2 posts to add second page to thread
|
|
[reply_thread(self.thread) for p in xrange(2)]
|
|
[reply_thread(self.thread) for p in xrange(2)]
|
|
|
|
|
|
- url_last = goto.last(self.user, self.thread)
|
|
|
|
|
|
+ url_last = goto.last(self.thread, self.thread.post_set)
|
|
url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
|
|
url_formats = self.thread.get_absolute_url(), self.thread.last_post_id
|
|
self.assertEqual(url_last, '%s2/#post-%s' % url_formats)
|
|
self.assertEqual(url_last, '%s2/#post-%s' % url_formats)
|
|
|
|
|
|
@@ -86,22 +87,25 @@ class GotoTests(AuthenticatedUserTestCase):
|
|
"""get_post_link returns link to specified post"""
|
|
"""get_post_link returns link to specified post"""
|
|
post_link = goto.get_post_link(
|
|
post_link = goto.get_post_link(
|
|
1, self.thread.post_set, self.thread, self.thread.last_post)
|
|
1, self.thread.post_set, self.thread, self.thread.last_post)
|
|
- self.assertEqual(post_link, goto.last(self.user, self.thread))
|
|
|
|
|
|
+ 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
|
|
# add 16 posts to add extra page to thread
|
|
[reply_thread(self.thread) for p in xrange(16)]
|
|
[reply_thread(self.thread) for p in xrange(16)]
|
|
|
|
|
|
post_link = goto.get_post_link(
|
|
post_link = goto.get_post_link(
|
|
17, self.thread.post_set, self.thread, self.thread.last_post)
|
|
17, self.thread.post_set, self.thread, self.thread.last_post)
|
|
- self.assertEqual(post_link, goto.last(self.user, self.thread))
|
|
|
|
|
|
+ last_link = goto.last(self.thread, self.thread.post_set)
|
|
|
|
+ self.assertEqual(post_link, last_link)
|
|
|
|
|
|
def test_new(self):
|
|
def test_new(self):
|
|
"""new returns link to first unread post"""
|
|
"""new returns link to first unread post"""
|
|
self.user.new_threads = MockThreadsCounter()
|
|
self.user.new_threads = MockThreadsCounter()
|
|
self.user.unread_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))
|
|
|
|
|
|
+ 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
|
|
# add 18 posts to add extra page to thread, then read them
|
|
[reply_thread(self.thread) for p in xrange(18)]
|
|
[reply_thread(self.thread) for p in xrange(18)]
|
|
@@ -112,7 +116,7 @@ class GotoTests(AuthenticatedUserTestCase):
|
|
first_unread = reply_thread(self.thread)
|
|
first_unread = reply_thread(self.thread)
|
|
[reply_thread(self.thread) for p in xrange(30)]
|
|
[reply_thread(self.thread) for p in xrange(30)]
|
|
|
|
|
|
- new_link = goto.new(self.user, self.thread)
|
|
|
|
|
|
+ new_link = goto.new(self.user, self.thread, self.thread.post_set)
|
|
post_link = goto.get_post_link(
|
|
post_link = goto.get_post_link(
|
|
50, self.thread.post_set, self.thread, first_unread)
|
|
50, self.thread.post_set, self.thread, first_unread)
|
|
self.assertEqual(new_link, post_link)
|
|
self.assertEqual(new_link, post_link)
|
|
@@ -122,18 +126,21 @@ class GotoTests(AuthenticatedUserTestCase):
|
|
self.user, self.thread, self.thread.last_post)
|
|
self.user, self.thread, self.thread.last_post)
|
|
|
|
|
|
# assert new() points to last reply
|
|
# assert new() points to last reply
|
|
- post_link = goto.new(self.user, self.thread)
|
|
|
|
- self.assertEqual(post_link, goto.last(self.user, self.thread))
|
|
|
|
|
|
+ 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)
|
|
|
|
|
|
def test_post(self):
|
|
def test_post(self):
|
|
"""post returns link to post given"""
|
|
"""post returns link to post given"""
|
|
- self.assertEqual(
|
|
|
|
- goto.last(self.user, self.thread),
|
|
|
|
- goto.post(self.user, self.thread, self.thread.last_post))
|
|
|
|
|
|
+ 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
|
|
# add 24 posts
|
|
[reply_thread(self.thread) for p in xrange(24)]
|
|
[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))
|
|
|
|
|
|
+ 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)
|