Beispiel #1
0
 def test_video_profile_list_with_whitespace(self):
     """Check video_profiles config with leading and trailing whitespace"""
     MobileApiConfig(
         video_profiles=" mobile_low , mobile_high,youtube ").save()
     video_profile_list = MobileApiConfig.get_video_profiles()
     self.assertEqual(video_profile_list,
                      [u'mobile_low', u'mobile_high', u'youtube'])
 def test_video_profile_list(self):
     """Check that video_profiles config is returned in order as a list"""
     MobileApiConfig(video_profiles="mobile_low,mobile_high,youtube").save()
     video_profile_list = MobileApiConfig.get_video_profiles()
     self.assertEqual(
         video_profile_list,
         [u'mobile_low', u'mobile_high', u'youtube']
     )
Beispiel #3
0
 def list(self, request, course, *args, **kwargs):
     video_profiles = MobileApiConfig.get_video_profiles()
     video_outline = list(
         BlockOutline(course.id, course,
                      {"video": partial(video_summary, video_profiles)},
                      request, video_profiles, kwargs.get('api_version')))
     return Response(video_outline)
 def test_video_profile_list(self):
     """Check that video_profiles config is returned in order as a list"""
     MobileApiConfig(video_profiles="mobile_low,mobile_high,youtube").save()
     video_profile_list = MobileApiConfig.get_video_profiles()
     self.assertEqual(
         video_profile_list,
         [u'mobile_low', u'mobile_high', u'youtube']
     )
 def test_video_profile_list_with_whitespace(self):
     """Check video_profiles config with leading and trailing whitespace"""
     MobileApiConfig(video_profiles=" mobile_low , mobile_high,youtube ").save()
     video_profile_list = MobileApiConfig.get_video_profiles()
     self.assertEqual(
         video_profile_list,
         [u'mobile_low', u'mobile_high', u'youtube']
     )
Beispiel #6
0
 def list(self, request, course, *args, **kwargs):
     video_profiles = MobileApiConfig.get_video_profiles()
     video_outline = list(
         BlockOutline(
             course.id,
             course,
             {"video": partial(video_summary, video_profiles)},
             request,
             video_profiles,
         )
     )
     return Response(video_outline)
Beispiel #7
0
    def test_mobile_api_config(self):
        """
        Tests VideoSummaryList with different MobileApiConfig video_profiles
        """
        self.login_and_enroll()
        edx_video_id = "testing_mobile_high"
        api.create_video({
            'edx_video_id':
            edx_video_id,
            'status':
            'test',
            'client_video_id':
            u"test video omega \u03a9",
            'duration':
            12,
            'courses': [unicode(self.course.id)],
            'encoded_videos': [
                {
                    'profile': 'youtube',
                    'url': self.youtube_url,
                    'file_size': 2222,
                    'bitrate': 4444
                },
                {
                    'profile': 'mobile_high',
                    'url': self.video_url_high,
                    'file_size': 111,
                    'bitrate': 333
                },
            ]
        })
        ItemFactory.create(
            parent=self.other_unit,
            category="video",
            display_name=u"testing mobile high video",
            edx_video_id=edx_video_id,
        )

        expected_output = {
            'category': u'video',
            'video_thumbnail_url': None,
            'language': u'en',
            'name': u'testing mobile high video',
            'video_url': self.video_url_high,
            'duration': 12.0,
            'transcripts': {
                'en':
                'http://testserver/api/mobile/v0.5/video_outlines/transcripts/{}/testing_mobile_high_video/en'
                .format(self.course.id)  # pylint: disable=line-too-long
            },
            'only_on_web': False,
            'encoded_videos': {
                u'mobile_high': {
                    'url': self.video_url_high,
                    'file_size': 111
                },
                u'youtube': {
                    'url': self.youtube_url,
                    'file_size': 2222
                }
            },
            'size': 111
        }

        # Testing when video_profiles='mobile_low,mobile_high,youtube'
        course_outline = self.api_response().data
        course_outline[0]['summary'].pop("id")
        self.assertEqual(course_outline[0]['summary'], expected_output)

        # Testing when there is no mobile_low, and that mobile_high doesn't show
        MobileApiConfig(video_profiles="mobile_low,youtube").save()

        course_outline = self.api_response().data

        expected_output['encoded_videos'].pop('mobile_high')
        expected_output['video_url'] = self.youtube_url
        expected_output['size'] = 2222

        course_outline[0]['summary'].pop("id")
        self.assertEqual(course_outline[0]['summary'], expected_output)

        # Testing where youtube is the default video over mobile_high
        MobileApiConfig(video_profiles="youtube,mobile_high").save()

        course_outline = self.api_response().data

        expected_output['encoded_videos']['mobile_high'] = {
            'url': self.video_url_high,
            'file_size': 111
        }

        course_outline[0]['summary'].pop("id")
        self.assertEqual(course_outline[0]['summary'], expected_output)
Beispiel #8
0
    def setUp(self):
        super(TestVideoAPITestCase, self).setUp()
        self.section = ItemFactory.create(
            parent=self.course,
            category="chapter",
            display_name=u"test factory section omega \u03a9",
        )
        self.sub_section = ItemFactory.create(
            parent=self.section,
            category="sequential",
            display_name=u"test subsection omega \u03a9",
        )

        self.unit = ItemFactory.create(
            parent=self.sub_section,
            category="vertical",
            metadata={
                'graded': True,
                'format': 'Homework'
            },
            display_name=u"test unit omega \u03a9",
        )
        self.other_unit = ItemFactory.create(
            parent=self.sub_section,
            category="vertical",
            metadata={
                'graded': True,
                'format': 'Homework'
            },
            display_name=u"test unit omega 2 \u03a9",
        )
        self.nameless_unit = ItemFactory.create(
            parent=self.sub_section,
            category="vertical",
            metadata={
                'graded': True,
                'format': 'Homework'
            },
            display_name=None,
        )

        self.edx_video_id = 'testing-123'
        self.video_url = 'http://val.edx.org/val/video.mp4'
        self.video_url_high = 'http://val.edx.org/val/video_high.mp4'
        self.youtube_url = 'http://val.edx.org/val/youtube.mp4'
        self.html5_video_url = 'http://video.edx.org/html5/video.mp4'

        api.create_profile('youtube')
        api.create_profile('mobile_high')
        api.create_profile('mobile_low')

        # create the video in VAL
        api.create_video({
            'edx_video_id':
            self.edx_video_id,
            'status':
            'test',
            'client_video_id':
            u"test video omega \u03a9",
            'duration':
            12,
            'courses': [unicode(self.course.id)],
            'encoded_videos': [
                {
                    'profile': 'youtube',
                    'url': 'xyz123',
                    'file_size': 0,
                    'bitrate': 1500
                },
                {
                    'profile': 'mobile_low',
                    'url': self.video_url,
                    'file_size': 12345,
                    'bitrate': 250
                },
                {
                    'profile': 'mobile_high',
                    'url': self.video_url_high,
                    'file_size': 99999,
                    'bitrate': 250
                },
            ]
        })

        # Set requested profiles
        MobileApiConfig(video_profiles="mobile_low,mobile_high,youtube").save()
Beispiel #9
0
 def test_empty_video_profile(self):
     """Test an empty video_profile"""
     MobileApiConfig(video_profiles="").save()
     video_profile_list = MobileApiConfig.get_video_profiles()
     self.assertEqual(video_profile_list, [])
Beispiel #10
0
    def test_mobile_api_video_profiles(self):
        """
        Tests VideoSummaryList with different MobileApiConfig video_profiles
        """
        self.login_and_enroll()
        edx_video_id = "testing_mobile_high"
        api.create_video({
            'edx_video_id':
            edx_video_id,
            'status':
            'test',
            'client_video_id':
            u"test video omega \u03a9",
            'duration':
            12,
            'courses': [unicode(self.course.id)],
            'encoded_videos': [
                {
                    'profile': 'youtube',
                    'url': self.youtube_url,
                    'file_size': 2222,
                    'bitrate': 4444
                },
                {
                    'profile': 'mobile_high',
                    'url': self.video_url_high,
                    'file_size': 111,
                    'bitrate': 333
                },
            ]
        })
        ItemFactory.create(
            parent=self.other_unit,
            category="video",
            display_name=u"testing mobile high video",
            edx_video_id=edx_video_id,
        )

        expected_output = {
            'all_sources': [],
            'category': u'video',
            'video_thumbnail_url': None,
            'language': u'en',
            'name': u'testing mobile high video',
            'video_url': self.video_url_high,
            'duration': 12.0,
            'transcripts': {
                'en':
                'http://testserver/api/mobile/v0.5/video_outlines/transcripts/{}/testing_mobile_high_video/en'
                .format(self.course.id)  # pylint: disable=line-too-long
            },
            'only_on_web': False,
            'encoded_videos': {
                u'mobile_high': {
                    'url': self.video_url_high,
                    'file_size': 111
                },
                u'youtube': {
                    'url': self.youtube_url,
                    'file_size': 2222
                }
            },
            'size': 111
        }

        # The transcript was not entered, so it should not be found!
        # This is the default behaviour at courses.edX.org, based on `FALLBACK_TO_ENGLISH_TRANSCRIPTS`
        transcripts_response = self.client.get(
            expected_output['transcripts']['en'])
        self.assertEqual(404, transcripts_response.status_code)

        with patch.dict(settings.FEATURES,
                        FALLBACK_TO_ENGLISH_TRANSCRIPTS=False):
            # Other platform installations may override this setting
            # This ensures that the server don't return empty English transcripts when there's none!
            self.assertFalse(
                self.api_response().data[0]['summary'].get('transcripts'))

        # Testing when video_profiles='mobile_low,mobile_high,youtube'
        course_outline = self.api_response().data
        course_outline[0]['summary'].pop("id")
        self.assertEqual(course_outline[0]['summary'], expected_output)

        # Testing when there is no mobile_low, and that mobile_high doesn't show
        MobileApiConfig(video_profiles="mobile_low,youtube").save()

        course_outline = self.api_response().data

        expected_output['encoded_videos'].pop('mobile_high')
        expected_output['video_url'] = self.youtube_url
        expected_output['size'] = 2222

        course_outline[0]['summary'].pop("id")
        self.assertEqual(course_outline[0]['summary'], expected_output)

        # Testing where youtube is the default video over mobile_high
        MobileApiConfig(video_profiles="youtube,mobile_high").save()

        course_outline = self.api_response().data

        expected_output['encoded_videos']['mobile_high'] = {
            'url': self.video_url_high,
            'file_size': 111
        }

        course_outline[0]['summary'].pop("id")
        self.assertEqual(course_outline[0]['summary'], expected_output)
 def test_empty_video_profile(self):
     """Test an empty video_profile"""
     MobileApiConfig(video_profiles="").save()
     video_profile_list = MobileApiConfig.get_video_profiles()
     self.assertEqual(video_profile_list, [])