Exemplo n.º 1
0
 def test_with_already_existing_fields(self):
     Board.create('board name', 'bcode')
     data = {'name': 'board name', 'code': 'code'}
     form1 = BoardForm(data=data)
     data = {'name': 'other name', 'code': 'bcode'}
     form2 = BoardForm(data=data)
     self.assertFalse(form1.is_valid())
     self.assertFalse(form2.is_valid())
Exemplo n.º 2
0
 def test_view_with_logged_mod(self):
     mod = User.objects.create_user(username='******', password='******', email='*****@*****.**')
     board = Board.create('board', 'b')
     Moderation.objects.create(user=mod, board=board)
     self.client.login(username='******', password='******')
     response = self.client.get(reverse('forum:create_board'), follow=True)
     self.assertEqual(response.status_code, 403)
Exemplo n.º 3
0
 def test_get_latest_without_threads(self):
     board = Board.create('board name', 'bcode')
     threads1 = board.get_latest()
     threads2 = board.get_latest(5)
     threads3 = board.get_latest('pippo')
     self.assertEqual(threads1, [])
     self.assertEqual(threads2, [])
     self.assertEqual(threads3, [])
Exemplo n.º 4
0
 def import_boards(self):
     print "* Importing boards"
     rows = self._query("select * from smf_boards order by ID_PARENT")
     for row in rows:
         category = Category.objects.get(id=row['ID_CAT'])
         if row['ID_PARENT'] == 0:
             parent = None
         else:
             parent = Board.objects.get(id=row['ID_PARENT'])
         board = Board(
             id=row['ID_BOARD'],
             category=category,
             parent=parent,
             order=row['boardOrder'],
             name=row['name'],
             description=row['description'])
         disable_auto_now(board)
         board.save()
Exemplo n.º 5
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)
Exemplo n.º 6
0
 def test_correct_creation(self):
     board1 = Board.create(name='board1 name', code='b1')
     board2 = Board.create('board2 name', 'b2')
     self.assertIsInstance(board1, Board)
     self.assertIsInstance(board2, Board)
Exemplo n.º 7
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)
Exemplo n.º 8
0
 def test_board_view_with_no_threads(self):
     board = Board.create('boardname', 'bc')
     response = self.client.get(reverse('forum:board', kwargs={'board_code': board.code, 'page': ''}), follow=True)
     self.assertEqual(response.status_code, 200)