コード例 #1
0
    def test_save_unapproved_no_email(self, send_approval_email):
        """If the video is not approved, do not call send_approval_email."""
        video = Video2013Factory.create(approved=True, user_notified=False)
        eq_(video.user_notified, False)
        video.approved = False
        video.save()

        ok_(not send_approval_email.called)
コード例 #2
0
    def test_command(self):
        """If a user has not uploaded any videos, their profile should be deleted."""
        user_with_profile_no_videos = UserProfileFactory.create().user
        user_no_profile_no_videos = UserFactory.create()
        user_with_profile_with_videos = UserProfileFactory.create().user
        user_no_profile_with_videos = UserFactory.create()  # Shouldn't exist, but we'll test.

        Video2013Factory.create(user=user_with_profile_with_videos)
        Video2013Factory.create(user=user_no_profile_with_videos)

        command = wipe_spectator_personal_info.Command()
        command.handle()

        ok_(not UserProfile.objects.filter(user=user_with_profile_no_videos).exists())
        ok_(not UserProfile.objects.filter(user=user_no_profile_no_videos).exists())
        ok_(UserProfile.objects.filter(user=user_with_profile_with_videos).exists())
        ok_(not UserProfile.objects.filter(user=user_no_profile_with_videos).exists())
コード例 #3
0
    def test_delete_process(self, process_deletion):
        """
        When a video is deleted, the process_deletion task should be triggered.
        """
        user = UserProfileFactory.create().user
        video = Video2013Factory.create(user=user, vimeo_id=123456)
        ok_(not process_deletion.delay.called)

        video.delete()
        process_deletion.delay.assert_called_with(123456, user.id)
コード例 #4
0
    def test_save_unapproved_no_email(self):
        """If the video is not approved, do not call send_approval_email."""
        video = Video2013Factory.create(approved=True)
        video.user_notified = False
        video.approved = False

        path = 'flicks.videos.models.send_approval_email'
        with patch(path) as send_approval_email:
            video.save()
            ok_(not send_approval_email.called)
コード例 #5
0
    def test_save_noprocess_old(self):
        """
        Do not call process_approval if the approval status did not change.
        """
        video = Video2013Factory.create(approved=False)
        video.process_approval = Mock()

        video.title = 'new_title'
        video.save()
        ok_(not video.process_approval.called)
コード例 #6
0
    def test_save_unapproved_no_email(self):
        """If the video is not approved, do not call send_approval_email."""
        video = Video2013Factory.create(approved=True)
        video.user_notified = False
        video.approved = False

        path = 'flicks.videos.models.send_approval_email'
        with patch(path) as send_approval_email:
            video.save()
            ok_(not send_approval_email.called)
コード例 #7
0
    def test_delete_process(self, process_deletion):
        """
        When a video is deleted, the process_deletion task should be triggered.
        """
        user = UserProfileFactory.create().user
        video = Video2013Factory.create(user=user, vimeo_id=123456)
        ok_(not process_deletion.delay.called)

        video.delete()
        process_deletion.delay.assert_called_with(123456, user.id)
コード例 #8
0
    def test_save_noprocess_old(self):
        """
        Do not call process_approval if the approval status did not change.
        """
        video = Video2013Factory.create(approved=False)
        video.process_approval = Mock()

        video.title = 'new_title'
        video.save()
        ok_(not video.process_approval.called)
コード例 #9
0
    def test_save_approved_notified_no_email(self, send_approval_email):
        """
        If the video is approved and the user has already been notified, do not
        call send_approval_email.
        """
        video = Video2013Factory.create(approved=False, user_notified=True)
        eq_(video.user_notified, True)
        video.approved = True
        video.save()

        ok_(not send_approval_email.called)
コード例 #10
0
    def test_save_approved_notified_no_email(self, send_approval_email):
        """
        If the video is approved and the user has already been notified, do not
        call send_approval_email.
        """
        video = Video2013Factory.create(approved=False, user_notified=True)
        eq_(video.user_notified, True)
        video.approved = True
        video.save()

        ok_(not send_approval_email.called)
コード例 #11
0
    def test_save_approved_not_notified(self, send_approval_email):
        """
        If the video is approved and the user hasn't been notified, call
        send_approval_email and update user_notified.
        """
        video = Video2013Factory.create(approved=False, user_notified=False)
        eq_(video.user_notified, False)
        video.approved = True
        video.save()

        video = Video2013.objects.get(id=video.id)
        send_approval_email.assert_called_with(video)
        ok_(video.user_notified)
コード例 #12
0
    def test_save_approved_not_notified(self, send_approval_email):
        """
        If the video is approved and the user hasn't been notified, call
        send_approval_email and update user_notified.
        """
        video = Video2013Factory.create(approved=False, user_notified=False)
        eq_(video.user_notified, False)
        video.approved = True
        video.save()

        video = Video2013.objects.get(id=video.id)
        send_approval_email.assert_called_with(video)
        ok_(video.user_notified)
コード例 #13
0
    def test_save_process_changed(self):
        """Call process_approval if the approval status changed."""
        video = Video2013Factory.create(approved=False)
        video.process_approval = Mock()

        video.approved = True
        video.save()
        video.process_approval.assert_called_with()

        video.process_approval.reset_mock()
        ok_(not video.process_approval.called)
        video.approved = False
        video.save()
        video.process_approval.assert_called_with()
コード例 #14
0
    def test_save_process_changed(self):
        """Call process_approval if the approval status changed."""
        video = Video2013Factory.create(approved=False)
        video.process_approval = Mock()

        video.approved = True
        video.save()
        video.process_approval.assert_called_with()

        video.process_approval.reset_mock()
        ok_(not video.process_approval.called)
        video.approved = False
        video.save()
        video.process_approval.assert_called_with()
コード例 #15
0
    def test_command(self):
        """If a user has not uploaded any videos, their profile should be deleted."""
        user_with_profile_no_videos = UserProfileFactory.create().user
        user_no_profile_no_videos = UserFactory.create()
        user_with_profile_with_videos = UserProfileFactory.create().user
        user_no_profile_with_videos = UserFactory.create(
        )  # Shouldn't exist, but we'll test.

        Video2013Factory.create(user=user_with_profile_with_videos)
        Video2013Factory.create(user=user_no_profile_with_videos)

        command = wipe_spectator_personal_info.Command()
        command.handle()

        ok_(not UserProfile.objects.filter(
            user=user_with_profile_no_videos).exists())
        ok_(not UserProfile.objects.filter(
            user=user_no_profile_no_videos).exists())
        ok_(
            UserProfile.objects.filter(
                user=user_with_profile_with_videos).exists())
        ok_(not UserProfile.objects.filter(
            user=user_no_profile_with_videos).exists())