コード例 #1
0
ファイル: test_models.py プロジェクト: VeemsHQ/veems
    def test_is_removed_returns_true_if_was_removed(self, channel,
                                                    video_factory):
        video = video_factory(channel=channel)
        moderation_services.mark_video_as_removed(
            video_id=video.id,
            reason='doxxing',
        )

        assert video.is_removed is True
コード例 #2
0
ファイル: test_services.py プロジェクト: VeemsHQ/veems
    def test_raises_if_reason_and_report_specified(self, video, mocker,
                                                   video_report):
        mock_task_notify_channel_owner_video_is_removed = mocker.patch(
            f'{MODULE}.tasks.task_notify_channel_owner_video_is_removed')

        with pytest.raises(IntegrityError):
            services.mark_video_as_removed(
                video_id=video.id,
                reason='doxxing',
                video_report_id=video_report.id,
            )
        assert not mock_task_notify_channel_owner_video_is_removed.delay.called
コード例 #3
0
ファイル: test_tasks.py プロジェクト: VeemsHQ/veems
def test_task_notify_channel_owner_video_is_removed(video, mocker, settings):
    mock_send_mail = mocker.patch(f'{MODULE}.send_mail')
    video_removal = services.mark_video_as_removed(video_id=video.id,
                                                   reason='doxxing',
                                                   notify=False)

    tasks.task_notify_channel_owner_video_is_removed(
        video_removal_id=video_removal.id, )

    assert mock_send_mail.called
    exp_subject = 'Your Veems video has been removed'
    exp_message = (f'Your video "{video.title}" has been removed.\n\n'
                   'Other users will not be able to view this video.\n'
                   'This video will be deleted in 30 days.\n'
                   'Reason: doxxing\n'
                   f'Video link: http://localhost:8000/v/{video.id}/\n\n'
                   'If you think this decision has been made in error, '
                   'please reply to this email.\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=[video.channel.user.email],
        fail_silently=False,
    )
コード例 #4
0
    def test_returns_xxx_if_video_is_removed(self, client,
                                             video_with_feedback):
        video, _ = video_with_feedback
        moderation_services.mark_video_as_removed(
            video_id=video.id,
            reason='doxxing',
        )

        response = client.get(f'/v/{video.id}/')

        assert response.status_code == OK
        assert response.context['error_unavailable'] == {
            'title':
            'Video Removed',
            'description':
            ('This video has been removed due to breaking our rules.'),
        }
コード例 #5
0
ファイル: test_api_views.py プロジェクト: VeemsHQ/veems
    def test_get_when_video_is_removed(
        self,
        api_client_no_auth,
        video_with_transcodes,
        expected_video_resp_json,
    ):
        video = video_with_transcodes['video']
        moderation_services.mark_video_as_removed(video_id=video.id,
                                                  reason='doxxing',
                                                  notify=False)

        response = api_client_no_auth.get(f'/api/v1/video/{video.id}/')

        assert response.status_code == OK
        assert response.json() == expected_video_resp_json.extend({
            'is_removed':
            True,
            'visibility':
            'removed'
        })
コード例 #6
0
 def make(
     video_path=VIDEO_PATH,
     channel=None,
     upload=None,
     is_removed=False,
     **kwargs,
 ):
     channel = channel or request.getfixturevalue('channel')
     upload = upload or upload_factory(video_path=video_path,
                                       channel=channel)
     kwargs['title'] = kwargs.get('title', 'Title')
     kwargs['description'] = kwargs.get('description', 'Description')
     kwargs['tags'] = kwargs.get('tags', [])
     kwargs['filename'] = kwargs.get('filename', 'myfile.mp4')
     video = media_services.create_video(upload=upload,
                                         channel=channel,
                                         **kwargs)
     if is_removed:
         moderation_services.mark_video_as_removed(video_id=video.id,
                                                   reason='doxxing')
     return video
コード例 #7
0
ファイル: test_services.py プロジェクト: VeemsHQ/veems
    def test_with_reason(self, video, mocker):
        mock_task_notify_channel_owner_video_is_removed = mocker.patch(
            f'{MODULE}.tasks.task_notify_channel_owner_video_is_removed')

        removal = services.mark_video_as_removed(video_id=video.id,
                                                 reason='doxxing')

        assert isinstance(removal, services.models.VideoRemoval)
        assert removal.reason == 'doxxing'
        assert removal.video_report is None
        assert removal.video == video
        assert removal.reason_text == 'doxxing'
        assert mock_task_notify_channel_owner_video_is_removed.delay.called
コード例 #8
0
ファイル: test_services.py プロジェクト: VeemsHQ/veems
    def test_with_report(self, video, video_report, mocker):
        mock_task_notify_channel_owner_video_is_removed = mocker.patch(
            f'{MODULE}.tasks.task_notify_channel_owner_video_is_removed')

        removal = services.mark_video_as_removed(
            video_id=video.id, video_report_id=video_report.id)

        assert isinstance(removal, services.models.VideoRemoval)
        assert removal.reason is None
        assert removal.video_report == video_report
        assert removal.video == video
        assert removal.reason_text == video_report.reason
        assert mock_task_notify_channel_owner_video_is_removed.delay.called
        video_report.refresh_from_db()
        assert video_report.processed_on
コード例 #9
0
 def make(video=None):
     video = video or request.getfixturevalue('video')
     return moderation_services.mark_video_as_removed(video_id=video.id,
                                                      reason='doxxing')