Example #1
0
 def test_get_latest_with_threads(self):
     board = Board.create('board name', 'bcode')
     user = User.objects.create(username='******', email='*****@*****.**')
     pub_date = timezone.now()
     thread_list = []
     for i in range(10):
         thread_list.append(Thread.create(title='thread' + str(i), message=str(i), author=user, board=board))
         thread_list[i].first_post.pub_date = pub_date - datetime.timedelta(minutes=i)
         thread_list[i].first_post.save()
     threads1 = board.get_latest()
     threads2 = board.get_latest(5)
     threads3 = board.get_latest('pippo')
     self.assertEqual(threads1, thread_list)
     self.assertEqual(threads2, thread_list[:5])
     self.assertEqual(threads3, thread_list)
Example #2
0
 def test_thread_view_with_no_responses(self):
     board = Board.create('boardname', 'bc')
     author = User.objects.create_user(username='******', password='******', email='*****@*****.**')
     thread = Thread.create('thread title', 'thread message', board, author)
     response = self.client.get(reverse('forum:thread', kwargs={'thread_pk': thread.pk, 'page': ''}), follow=True)
     self.assertEqual(response.status_code, 200)