def test_task_notify_moderators_reported_video_comnment( video_comment, mocker, settings): mock_send_mail = mocker.patch(f'{MODULE}.send_mail') video_comment_report_id = services.report_video_comment( video_comment_id=video_comment.id, reason='doxxing', body='body', notify=False, ).id tasks.task_notify_moderators_reported_video_comnment( video_comment_id=video_comment.id, video_comment_report_id=video_comment_report_id, ) assert mock_send_mail.called exp_subject = ( f'New video comment report for video "{video_comment.video.title}"') exp_message = ( f'Video link: http://localhost:8000/v/{video_comment.video.id}/\n' 'View report: http://localhost:8000/admin/moderation/' f'videocommentreport/{video_comment_report_id}/change/\n' 'View all reports: ' 'http://localhost:8000/admin/moderation/videocommentreport/' '\n\n- Veems Support Team\n') mock_send_mail.assert_called_once_with( subject=exp_subject, message=exp_message, from_email=settings.DEFAULT_FROM_EMAIL, recipient_list=[settings.DEFAULT_FROM_EMAIL], fail_silently=False, )
def video_comment_report(self, video_comment): return services.report_video_comment( video_comment_id=video_comment.id, reason='doxxing', body='', notify=False, )
def test_is_processed(self, modeladmin, video_comment): report = services.report_video_comment( video_comment_id=video_comment.id, reason='doxxing', body='') assert modeladmin.is_processed(report) is False report.processed_on = timezone.now() assert modeladmin.is_processed(report) is True
def test_reinstate_video_comment(self, modeladmin, rf, video_comment, mocker): mock_reinstate_removed_video_comment = mocker.patch( f'{MODULE}.services.reinstate_removed_video_comment') report = services.report_video_comment( video_comment_id=video_comment.id, reason='doxxing', body='') request = rf.get('/') modeladmin.reinstate_video_comment(request=request, obj=report) mock_reinstate_removed_video_comment.assert_called_once_with( video_comment_id=video_comment.id) assert modeladmin.message_user.called
def test(self, video_comment, mocker): mock_task = mocker.patch( f'{MODULE}.tasks.task_notify_moderators_reported_video_comnment') reason = 'doxxing' body = 'Hello world' report = services.report_video_comment( video_comment_id=video_comment.id, reason=reason, body=body) assert isinstance(report, services.models.VideoCommentReport) assert report.video_comment == video_comment assert report.body == body assert report.reason == reason assert report.processed_on is None assert mock_task.delay.called
def test_video_link(self, modeladmin, video_comment): report = services.report_video_comment( video_comment_id=video_comment.id, reason='doxxing', body='') assert modeladmin.video_link(report).startswith('http')
def test_video_comment_body(self, modeladmin, video_comment): report = services.report_video_comment( video_comment_id=video_comment.id, reason='doxxing', body='') assert modeladmin.video_comment_body(report) == video_comment.body