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)
def test_goto_new(self): """thread_new link points to first unread post in thread""" # add 32 posts to thread [reply_thread(self.thread) for p in xrange(32)] # read thread response = self.client.get(self.thread.get_last_reply_url()) response = self.client.get(response['location']) # add unread posts unread_post = reply_thread(self.thread) [reply_thread(self.thread) for p in xrange(32)] response = self.client.get(self.thread.get_new_reply_url()) self.assertEqual(response.status_code, 302) unread_link = goto.new(self.user, self.thread, self.thread.post_set) self.assertTrue(response['location'].endswith(unread_link))
def get_redirect(self, user, thread, posts_qs): return goto.new(user, thread, posts_qs)
def get_redirect(self, user, thread): return goto.new(user, thread)