Пример #1
0
 def test_conversation_detail_not_in_board(self, rf, db, board,
                                           conversation):
     conversation.author = board.owner
     conversation.save()
     request = rf.post('', {'action': 'comment', 'content': 'test comment'})
     request.user = conversation.author
     with pytest.raises(Http404):
         routes.conversation_detail(request, board, conversation)
Пример #2
0
 def test_conversation_detail_not_in_board(self, rf, db, board,
                                           conversation):
     conversation.author = board.owner
     conversation.save()
     request = rf.post("", {"action": "comment", "content": "test comment"})
     request.user = conversation.author
     with pytest.raises(Http404):
         routes.conversation_detail(request, board, conversation)
Пример #3
0
 def test_conversation_detail(self, rf, db, board, conversation):
     conversation.author = board.owner
     conversation.save()
     request = rf.get("", {})
     request.user = conversation.author
     conversation.is_promoted = False
     board.add_conversation(conversation)
     response = routes.conversation_detail(request, board, conversation)
     assert response["conversation"] == conversation
     assert response["can_comment"]
     assert response["can_edit"]
Пример #4
0
 def test_conversation_detail_post_comment(self, rf, db, board,
                                           conversation):
     user = board.owner
     conversation.author = user
     conversation.save()
     request = rf.post("", {"action": "comment", "content": "test comment"})
     request.user = conversation.author
     conversation.is_promoted = False
     board.add_conversation(conversation)
     response = routes.conversation_detail(request, board, conversation)
     assert response["conversation"] == conversation
     assert response["can_comment"]
     assert response["can_edit"]
     assert Comment.objects.filter(author=user)[0].content == "test comment"
Пример #5
0
 def test_conversation_detail_post_comment(self, rf, db, board,
                                           conversation):
     user = board.owner
     conversation.author = user
     conversation.save()
     request = rf.post('', {'action': 'comment', 'content': 'test comment'})
     request.user = conversation.author
     conversation.is_promoted = False
     board.add_conversation(conversation)
     response = routes.conversation_detail(request, board, conversation)
     assert response['conversation'] == conversation
     assert response['can_comment']
     assert response['can_edit']
     assert Comment.objects.filter(author=user)[0].content == 'test comment'
Пример #6
0
 def test_conversation_detail_vote_comment(self, rf, db, board,
                                           conversation):
     user = board.owner
     conversation.author = user
     conversation.save()
     comment = conversation.create_comment(user, "comment")
     request = rf.post("", {
         "action": "vote",
         "vote": "agree",
         "comment_id": comment.id
     })
     request.user = conversation.author
     conversation.is_promoted = False
     board.add_conversation(conversation)
     response = routes.conversation_detail(request, board, conversation)
     assert response["conversation"] == conversation
     assert response["can_comment"]
     assert response["can_edit"]
     assert votes_counter(comment) == 1
Пример #7
0
 def test_conversation_detail_vote_comment(self, rf, db, board,
                                           conversation):
     user = board.owner
     conversation.author = user
     conversation.save()
     comment = conversation.create_comment(user, 'comment')
     request = rf.post('', {
         'action': 'vote',
         'vote': 'agree',
         'comment_id': comment.id
     })
     request.user = conversation.author
     conversation.is_promoted = False
     board.add_conversation(conversation)
     response = routes.conversation_detail(request, board, conversation)
     assert response['conversation'] == conversation
     assert response['can_comment']
     assert response['can_edit']
     assert votes_counter(comment) == 1