Example #1
0
 def test_sorting_last_post_desc(self):
     """Sorting threads by last_post descendingly."""
     t1 = thread(save=True)
     t1.new_post(t1.creator, 'foo')
     t2 = thread(save=True)
     t2.new_post(t2.creator, 'bar')
     threads = sort_threads(Thread.objects, 5, 1)
     self.assertGreaterEqual(threads[0].last_post.created,
                             threads[1].last_post.created)
Example #2
0
 def test_sorting_creator(self):
     """Sorting threads by creator."""
     u1 = user(username='******', save=True)
     u2 = user(username='******', save=True)
     thread(creator=u1, save=True)
     thread(creator=u2, save=True)
     threads = sort_threads(Thread.objects, 3, 1)
     self.assertEqual(threads[0].creator.username, u1.username)
     self.assertEqual(threads[1].creator.username, u2.username)
Example #3
0
 def test_sorting_creator(self):
     """Sorting threads by creator."""
     u1 = UserFactory(username='******')
     u2 = UserFactory(username='******')
     ThreadFactory(creator=u1)
     ThreadFactory(creator=u2)
     threads = sort_threads(Thread.objects, 3, 1)
     self.assertEqual(threads[0].creator.username, u1.username)
     self.assertEqual(threads[1].creator.username, u2.username)
Example #4
0
 def test_sorting_creator(self):
     """Sorting threads by creator."""
     u1 = UserFactory(username='******')
     u2 = UserFactory(username='******')
     ThreadFactory(creator=u1)
     ThreadFactory(creator=u2)
     threads = sort_threads(Thread.objects, 3, 1)
     self.assertEqual(threads[0].creator.username, u1.username)
     self.assertEqual(threads[1].creator.username, u2.username)
Example #5
0
 def test_sorting_last_post_desc(self):
     """Sorting threads by last_post descendingly."""
     t1 = ThreadFactory()
     t1.new_post(t1.creator, 'foo')
     t2 = ThreadFactory()
     t2.new_post(t2.creator, 'bar')
     threads = sort_threads(Thread.objects, 5, 1)
     self.assertGreaterEqual(threads[0].last_post.created,
                             threads[1].last_post.created)
Example #6
0
 def test_sorting_creator(self):
     """Sorting threads by creator."""
     u1 = user(username='******', save=True)
     u2 = user(username='******', save=True)
     thread(creator=u1, save=True)
     thread(creator=u2, save=True)
     threads = sort_threads(Thread.objects, 3, 1)
     self.assertEqual(threads[0].creator.username, u1.username)
     self.assertEqual(threads[1].creator.username, u2.username)
Example #7
0
 def test_sorting_replies(self):
     """Sorting threads by replies."""
     t1 = ThreadFactory()
     t1.new_post(t1.creator, 'foo')
     t2 = ThreadFactory()
     t2.new_post(t2.creator, 'bar')
     t2.new_post(t2.creator, 'baz')
     threads = sort_threads(Thread.objects, 4)
     self.assertLessEqual(threads[0].replies, threads[1].replies)
     eq_(threads[0].replies, t1.replies)
     eq_(threads[1].replies, t2.replies)
     eq_(threads[0].title, t1.title)
     eq_(threads[1].title, t2.title)
Example #8
0
 def test_sorting_replies(self):
     """Sorting threads by replies."""
     t1 = thread(save=True)
     t1.new_post(t1.creator, 'foo')
     t2 = thread(save=True)
     t2.new_post(t2.creator, 'bar')
     t2.new_post(t2.creator, 'baz')
     threads = sort_threads(Thread.objects, 4)
     self.assertLessEqual(threads[0].replies,
                          threads[1].replies)
     eq_(threads[0].replies, t1.replies)
     eq_(threads[1].replies, t2.replies)
     eq_(threads[0].title, t1.title)
     eq_(threads[1].title, t2.title)