예제 #1
0
    def test_valid_video(self, send_mail, mock_vimeo):
        """If a valid video id is given, update the Vimeo metadata."""
        # Many to many makes this super-verbose. Essentially, create two
        # moderators, one who is part of a moderator group and the other who
        # has the change_video2013 permission directly.
        perm = Permission.objects.get(codename='change_video2013')
        group = GroupFactory()
        group.permissions = [perm]
        group.save()
        moderator1 = UserFactory(email='*****@*****.**')
        moderator1.user_permissions = [perm]
        moderator1.save()
        moderator2 = UserFactory.create(email='*****@*****.**')
        moderator2.groups = [group]
        moderator2.save()

        user = UserProfileFactory.create(nickname='name', country='us').user
        video = VideoFactory.create(user=user,
                                    title='blah',
                                    description='asdf',
                                    vimeo_id=7)

        with self.settings(VIMEO_REGION_CHANNELS={regions.NORTH_AMERICA: 18},
                           DEFAULT_FROM_EMAIL='*****@*****.**'):
            process_video(video.id)

        mock_vimeo.set_title.assert_called_with(7, 'blah')
        mock_vimeo.set_description.assert_called_with(7,
                                                      'blah by name\n\nasdf')
        mock_vimeo.add_to_channel.assert_called_with(7, 18)
        mock_vimeo.add_tags.assert_called_with(7, ['us'])

        send_mail.assert_called_with(
            ANY, ANY, '*****@*****.**',
            CONTAINS('*****@*****.**', '*****@*****.**'))
예제 #2
0
 def test_no_video(self, mock_vimeo):
     """If no video is found with the given id, do nothing."""
     process_video(1387589156831)
     ok_(not mock_vimeo.set_title.called)
     ok_(not mock_vimeo.set_description.called)
     ok_(not mock_vimeo.add_to_channel.called)
     ok_(not mock_vimeo.add_tags.called)
예제 #3
0
 def test_no_video(self, mock_vimeo):
     """If no video is found with the given id, do nothing."""
     process_video(1387589156831)
     ok_(not mock_vimeo.set_title.called)
     ok_(not mock_vimeo.set_description.called)
     ok_(not mock_vimeo.add_to_channel.called)
     ok_(not mock_vimeo.add_tags.called)
예제 #4
0
    def test_valid_video(self, send_mail, mock_vimeo):
        """If a valid video id is given, update the Vimeo metadata."""
        # Many to many makes this super-verbose. Essentially, create two
        # moderators, one who is part of a moderator group and the other who
        # has the change_video2013 permission directly.
        perm = Permission.objects.get(codename='change_video2013')
        group = GroupFactory()
        group.permissions = [perm]
        group.save()
        moderator1 = UserFactory(email='*****@*****.**')
        moderator1.user_permissions = [perm]
        moderator1.save()
        moderator2 = UserFactory.create(email='*****@*****.**')
        moderator2.groups = [group]
        moderator2.save()

        user = UserProfileFactory.create(nickname='name', country='us').user
        video = VideoFactory.create(user=user, title='blah', description='asdf',
                                    vimeo_id=7)

        with self.settings(VIMEO_REGION_CHANNELS={regions.NORTH_AMERICA: 18},
                           DEFAULT_FROM_EMAIL='*****@*****.**'):
            process_video(video.id)

        mock_vimeo.set_title.assert_called_with(7, 'blah')
        mock_vimeo.set_description.assert_called_with(7, 'blah by name\n\nasdf')
        mock_vimeo.add_to_channel.assert_called_with(7, 18)
        mock_vimeo.add_tags.assert_called_with(7, ['us'])

        send_mail.assert_called_with(ANY, ANY, '*****@*****.**',
                                     CONTAINS('*****@*****.**',
                                              '*****@*****.**'))
예제 #5
0
    def process_videos(self, request, queryset):
        """Synchronously run the video processing task on the selected videos."""
        for video in queryset:
            process_video(video.id)

        msg = '{0} videos processed successfully.'
        self.message_user(request, msg.format(len(queryset)))