Exemplo n.º 1
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)
Exemplo n.º 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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 def test_sorting_last_post_desc(self):
     """Sorting threads by last_post descendingly."""
     threads = sort_threads(Thread.objects, 5, 1)
     assert (threads[0].last_post.created >= threads[1].last_post.created)
Exemplo n.º 8
0
 def test_sorting_replies(self):
     """Sorting threads by replies."""
     threads = sort_threads(Thread.objects, 4)
     assert threads[0].replies <= threads[1].replies
Exemplo n.º 9
0
 def test_sorting_creator(self):
     """Sorting threads by creator."""
     threads = sort_threads(Thread.objects, 3, 1)
     assert (threads[0].creator.username >= threads[1].creator.username)
Exemplo n.º 10
0
 def test_sorting_last_post_desc(self):
     """Sorting threads by last_post descendingly."""
     threads = sort_threads(Thread.objects, 5, 1)
     assert (threads[0].last_post.created >=
             threads[1].last_post.created)
Exemplo n.º 11
0
 def test_sorting_replies(self):
     """Sorting threads by replies."""
     threads = sort_threads(Thread.objects, 4)
     assert threads[0].replies <= threads[1].replies
Exemplo n.º 12
0
 def test_sorting_creator(self):
     """Sorting threads by creator."""
     threads = sort_threads(Thread.objects, 3, 1)
     assert (threads[0].creator.username >=
                  threads[1].creator.username)