def test_author_try_moderate_unpromoted_conversation(self, rf, conversation): request = rf.get("") request.user = User.objects.get(email="*****@*****.**") conversation.is_promoted = False conversation.save() with raises(Http404): routes.moderate(request, conversation)
def test_author_can_moderate_conversation_approving_comment(self, rf, conversation): other = User.objects.create_user("*****@*****.**", "pass") comment = conversation.create_comment(other, "aa", check_limits=False) assert comment.status == comment.STATUS.pending request = rf.post("", {"comment": comment.id, "vote": "approve"}) request.user = User.objects.get(email="*****@*****.**") routes.moderate(request, conversation) comment.refresh_from_db() assert comment.status == comment.STATUS.approved
def test_author_try_moderate_invalid_vote(self, rf, conversation): other = User.objects.create_user("*****@*****.**", "pass") comment = conversation.create_comment(other, "aa", check_limits=False) request = rf.post( "", {"comment": comment.id, "vote": "other", "rejection_reason": "offensive_language"} ) request.user = User.objects.get(email="*****@*****.**") response = routes.moderate(request, conversation) assert isinstance(response, HttpResponseServerError)
def test_get_moderate_conversation(self, rf, conversation): user = conversation.author other_user = User.objects.create_user("*****@*****.**", "pass") comment = conversation.create_comment(other_user, "aa", check_limits=False) assert comment.status == comment.STATUS.pending request = rf.get("", {}) request.user = user response = routes.moderate(request, conversation) assert response["comments"][0] == comment
def conversation_moderate(request, board, **kwargs): return conversations.moderate(request, check=check_board(board), **kwargs)