コード例 #1
0
    def setUp(self):
        super(ScrapeVideoThumbnailsTestCase, self).setUp()
        course_ids = [unicode(self.course.id)]
        profiles = ['youtube']
        created = datetime.now(pytz.utc)
        previous_uploads = [
            {
                'edx_video_id': 'test1',
                'client_video_id': 'test1.mp4',
                'duration': 42.0,
                'status': 'upload',
                'courses': course_ids,
                'encoded_videos': [],
                'created': created
            },
            {
                'edx_video_id': 'test-youtube-video-1',
                'client_video_id': 'test-youtube-id.mp4',
                'duration': 128.0,
                'status': 'file_complete',
                'courses': course_ids,
                'created': created,
                'encoded_videos': [
                    {
                        'profile': 'youtube',
                        'url': '3_yD_cEKoCk',
                        'file_size': 1600,
                        'bitrate': 100,
                    }
                ],
            },
            {
                'edx_video_id': 'test-youtube-video-2',
                'client_video_id': 'test-youtube-id.mp4',
                'image': 'image2.jpg',
                'duration': 128.0,
                'status': 'file_complete',
                'courses': course_ids,
                'created': created,
                'encoded_videos': [
                    {
                        'profile': 'youtube',
                        'url': '3_yD_cEKoCk',
                        'file_size': 1600,
                        'bitrate': 100,
                    }
                ],
            },
        ]
        for profile in profiles:
            create_profile(profile)

        for video in previous_uploads:
            create_video(video)

        # Create video images.
        with make_image_file() as image_file:
            update_video_image(
                'test-youtube-video-2', unicode(self.course.id), image_file, 'image.jpg'
            )
コード例 #2
0
ファイル: test_video_mongo.py プロジェクト: rhndg/openedx
    def test_export_val_data(self):
        self.descriptor.edx_video_id = "test_edx_video_id"
        create_profile("mobile")
        create_video(
            {
                "edx_video_id": self.descriptor.edx_video_id,
                "client_video_id": "test_client_video_id",
                "duration": 111,
                "status": "dummy",
                "encoded_videos": [
                    {"profile": "mobile", "url": "http://example.com/video", "file_size": 222, "bitrate": 333}
                ],
            }
        )

        actual = self.descriptor.definition_to_xml(resource_fs=None)
        expected_str = """
            <video download_video="false" url_name="SampleProblem">
                <video_asset client_video_id="test_client_video_id" duration="111.0">
                    <encoded_video profile="mobile" url="http://example.com/video" file_size="222" bitrate="333"/>
                </video_asset>
            </video>
        """
        parser = etree.XMLParser(remove_blank_text=True)
        expected = etree.XML(expected_str, parser=parser)
        self.assertXmlEqual(expected, actual)
コード例 #3
0
    def test_export_val_data(self):
        self.descriptor.edx_video_id = 'test_edx_video_id'
        create_profile('mobile')
        create_video({
            'edx_video_id': self.descriptor.edx_video_id,
            'client_video_id': 'test_client_video_id',
            'duration': 111,
            'status': 'dummy',
            'encoded_videos': [{
                'profile': 'mobile',
                'url': 'http://example.com/video',
                'file_size': 222,
                'bitrate': 333,
            }],
        })

        actual = self.descriptor.definition_to_xml(resource_fs=None)
        expected_str = """
            <video download_video="false" url_name="SampleProblem">
                <video_asset client_video_id="test_client_video_id" duration="111.0">
                    <encoded_video profile="mobile" url="http://example.com/video" file_size="222" bitrate="333"/>
                </video_asset>
            </video>
        """
        parser = etree.XMLParser(remove_blank_text=True)
        expected = etree.XML(expected_str, parser=parser)
        self.assertXmlEqual(expected, actual)
コード例 #4
0
    def test_export_val_data(self):
        self.descriptor.edx_video_id = 'test_edx_video_id'
        create_profile('mobile')
        create_video({
            'edx_video_id':
            self.descriptor.edx_video_id,
            'client_video_id':
            'test_client_video_id',
            'duration':
            111,
            'status':
            'dummy',
            'encoded_videos': [{
                'profile': 'mobile',
                'url': 'http://example.com/video',
                'file_size': 222,
                'bitrate': 333,
            }],
        })

        actual = self.descriptor.definition_to_xml(resource_fs=None)
        expected_str = """
            <video download_video="false" url_name="SampleProblem">
                <video_asset client_video_id="test_client_video_id" duration="111.0">
                    <encoded_video profile="mobile" url="http://example.com/video" file_size="222" bitrate="333"/>
                </video_asset>
            </video>
        """
        parser = etree.XMLParser(remove_blank_text=True)
        expected = etree.XML(expected_str, parser=parser)
        self.assertXmlEqual(expected, actual)
コード例 #5
0
    def test_import_val_data(self):
        create_profile('mobile')
        module_system = DummySystem(load_error_modules=True)

        xml_data = """
            <video edx_video_id="test_edx_video_id">
                <video_asset client_video_id="test_client_video_id" duration="111.0">
                    <encoded_video profile="mobile" url="http://example.com/video" file_size="222" bitrate="333"/>
                </video_asset>
            </video>
        """
        id_generator = Mock()
        id_generator.target_course_id = "test_course_id"
        video = VideoDescriptor.from_xml(xml_data, module_system, id_generator)
        self.assertEqual(video.edx_video_id, 'test_edx_video_id')
        video_data = get_video_info(video.edx_video_id)
        self.assertEqual(video_data['client_video_id'], 'test_client_video_id')
        self.assertEqual(video_data['duration'], 111)
        self.assertEqual(video_data['status'], 'imported')
        self.assertEqual(video_data['courses'],
                         [id_generator.target_course_id])
        self.assertEqual(video_data['encoded_videos'][0]['profile'], 'mobile')
        self.assertEqual(video_data['encoded_videos'][0]['url'],
                         'http://example.com/video')
        self.assertEqual(video_data['encoded_videos'][0]['file_size'], 222)
        self.assertEqual(video_data['encoded_videos'][0]['bitrate'], 333)
コード例 #6
0
ファイル: test_video_utils.py プロジェクト: sam1610/ThemeEdx
    def setUp(self):
        super(ScrapeVideoThumbnailsTestCase, self).setUp()
        course_ids = [unicode(self.course.id)]
        profiles = ['youtube']
        created = datetime.now(pytz.utc)
        previous_uploads = [
            {
                'edx_video_id': 'test1',
                'client_video_id': 'test1.mp4',
                'duration': 42.0,
                'status': 'upload',
                'courses': course_ids,
                'encoded_videos': [],
                'created': created
            },
            {
                'edx_video_id': 'test-youtube-video-1',
                'client_video_id': 'test-youtube-id.mp4',
                'duration': 128.0,
                'status': 'file_complete',
                'courses': course_ids,
                'created': created,
                'encoded_videos': [
                    {
                        'profile': 'youtube',
                        'url': '3_yD_cEKoCk',
                        'file_size': 1600,
                        'bitrate': 100,
                    }
                ],
            },
            {
                'edx_video_id': 'test-youtube-video-2',
                'client_video_id': 'test-youtube-id.mp4',
                'image': 'image2.jpg',
                'duration': 128.0,
                'status': 'file_complete',
                'courses': course_ids,
                'created': created,
                'encoded_videos': [
                    {
                        'profile': 'youtube',
                        'url': '3_yD_cEKoCk',
                        'file_size': 1600,
                        'bitrate': 100,
                    }
                ],
            },
        ]
        for profile in profiles:
            create_profile(profile)

        for video in previous_uploads:
            create_video(video)

        # Create video images.
        with make_image_file() as image_file:
            update_video_image(
                'test-youtube-video-2', unicode(self.course.id), image_file, 'image.jpg'
            )
コード例 #7
0
ファイル: test_api.py プロジェクト: open-craft/edx-val
 def test_create_profile(self):
     """
     Tests the creation of a profile
     """
     api.create_profile(constants.PROFILE_DESKTOP)
     profiles = list(Profile.objects.all())
     self.assertEqual(len(profiles), 6)
     self.assertIn(constants.PROFILE_DESKTOP, [unicode(profile) for profile in profiles])
     self.assertEqual(len(profiles), 6)
コード例 #8
0
 def setUp(self):
     """
     Creation of Video object that will be used to test video update
     Creation of Profile objects that will be used to test video update
     """
     api.create_profile(constants.PROFILE_DESKTOP)
     api.create_profile(constants.PROFILE_MOBILE)
     video_data = dict(
         encoded_videos=[constants.ENCODED_VIDEO_DICT_FISH_MOBILE],
         **constants.VIDEO_DICT_FISH)
     api.create_video(video_data)
コード例 #9
0
 def test_create_profile(self):
     """
     Tests the creation of a profile
     """
     api.create_profile(constants.PROFILE_DESKTOP)
     profiles = list(Profile.objects.all())
     profile_names = [unicode(profile) for profile in profiles]
     self.assertEqual(len(profiles), 7)
     self.assertIn(constants.PROFILE_DESKTOP, profile_names)
     self.assertIn(constants.PROFILE_HLS, profile_names)
     self.assertEqual(len(profiles), 7)
コード例 #10
0
ファイル: tests.py プロジェクト: morsoinferno/ANALYSE
    def setUp(self):
        super(TestVideoOutline, self).setUp()
        self.user = UserFactory.create()
        self.course = CourseFactory.create(mobile_available=True)
        self.section = ItemFactory.create(
            parent_location=self.course.location, category="chapter", display_name=u"test factory section omega \u03a9"
        )
        self.sub_section = ItemFactory.create(
            parent_location=self.section.location, category="sequential", display_name=u"test subsection omega \u03a9"
        )

        self.unit = ItemFactory.create(
            parent_location=self.sub_section.location,
            category="vertical",
            metadata={"graded": True, "format": "Homework"},
            display_name=u"test unit omega \u03a9",
        )
        self.other_unit = ItemFactory.create(
            parent_location=self.sub_section.location,
            category="vertical",
            metadata={"graded": True, "format": "Homework"},
            display_name=u"test unit omega 2 \u03a9",
        )
        self.nameless_unit = ItemFactory.create(
            parent_location=self.sub_section.location,
            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.html5_video_url = "http://video.edx.org/html5/video.mp4"

        api.create_profile({"profile_name": "youtube", "extension": "mp4", "width": 1280, "height": 720})
        api.create_profile({"profile_name": "mobile_low", "extension": "mp4", "width": 640, "height": 480})

        # create the video in VAL
        api.create_video(
            {
                "edx_video_id": self.edx_video_id,
                "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},
                ],
            }
        )

        self.client.login(username=self.user.username, password="******")
コード例 #11
0
    def test_import_val_data_invalid(self):
        create_profile('mobile')
        module_system = DummySystem(load_error_modules=True)

        # Negative file_size is invalid
        xml_data = """
            <video edx_video_id="test_edx_video_id">
                <video_asset client_video_id="test_client_video_id" duration="111.0">
                    <encoded_video profile="mobile" url="http://example.com/video" file_size="-222" bitrate="333"/>
                </video_asset>
            </video>
        """
        with self.assertRaises(ValCannotCreateError):
            VideoDescriptor.from_xml(xml_data, module_system, id_generator=Mock())
        with self.assertRaises(ValVideoNotFoundError):
            get_video_info("test_edx_video_id")
コード例 #12
0
 def setup_val_video(self, associate_course_in_val=False):
     """
     Creates a video entry in VAL.
     Arguments:
         associate_course - If True, associates the test course with the video in VAL.
     """
     create_profile('mobile')
     create_video({
         'edx_video_id': self.TEST_EDX_VIDEO_ID,
         'client_video_id': 'test_client_video_id',
         'duration': self.TEST_DURATION,
         'status': 'dummy',
         'encoded_videos': [self.TEST_ENCODED_VIDEO],
         'courses': [self.video.location.course_key] if associate_course_in_val else [],
     })
     self.val_video = get_video_info(self.TEST_EDX_VIDEO_ID)  # pylint: disable=attribute-defined-outside-init
コード例 #13
0
    def test_import_val_data_invalid(self):
        create_profile('mobile')
        module_system = DummySystem(load_error_modules=True)

        # Negative file_size is invalid
        xml_data = """
            <video edx_video_id="test_edx_video_id">
                <video_asset client_video_id="test_client_video_id" duration="111.0">
                    <encoded_video profile="mobile" url="http://example.com/video" file_size="-222" bitrate="333"/>
                </video_asset>
            </video>
        """
        with self.assertRaises(ValCannotCreateError):
            VideoDescriptor.from_xml(xml_data, module_system, id_generator=Mock())
        with self.assertRaises(ValVideoNotFoundError):
            get_video_info("test_edx_video_id")
コード例 #14
0
    def test_import_val_data(self):
        create_profile('mobile')
        module_system = DummySystem(load_error_modules=True)

        xml_data = """
            <video edx_video_id="test_edx_video_id">
                <video_asset client_video_id="test_client_video_id" duration="111.0">
                    <encoded_video profile="mobile" url="http://example.com/video" file_size="222" bitrate="333"/>
                </video_asset>
            </video>
        """
        video = VideoDescriptor.from_xml(xml_data, module_system, id_generator=Mock())
        self.assertEqual(video.edx_video_id, 'test_edx_video_id')
        video_data = get_video_info(video.edx_video_id)
        self.assertEqual(video_data['client_video_id'], 'test_client_video_id')
        self.assertEqual(video_data['duration'], 111)
        self.assertEqual(video_data['status'], 'imported')
        self.assertEqual(video_data['courses'], [])
        self.assertEqual(video_data['encoded_videos'][0]['profile'], 'mobile')
        self.assertEqual(video_data['encoded_videos'][0]['url'], 'http://example.com/video')
        self.assertEqual(video_data['encoded_videos'][0]['file_size'], 222)
        self.assertEqual(video_data['encoded_videos'][0]['bitrate'], 333)
コード例 #15
0
ファイル: test_api.py プロジェクト: cpennington/edx-val
 def test_create_profile(self):
     """
     Tests the creation of a profile
     """
     result = api.create_profile(constants.PROFILE_DICT_DESKTOP)
     profiles = list(Profile.objects.all())
     self.assertEqual(len(profiles), 6)
     self.assertEqual(
         profiles[-1].profile_name,
         constants.PROFILE_DICT_DESKTOP.get('profile_name')
     )
     self.assertEqual(len(profiles), 6)
     self.assertEqual("desktop", result)
コード例 #16
0
ファイル: tests.py プロジェクト: ahmadiga/min_edx
    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()
コード例 #17
0
ファイル: test_video_mongo.py プロジェクト: rhndg/openedx
    def test_import_val_data(self):
        create_profile("mobile")
        module_system = DummySystem(load_error_modules=True)

        xml_data = """
            <video edx_video_id="test_edx_video_id">
                <video_asset client_video_id="test_client_video_id" duration="111.0">
                    <encoded_video profile="mobile" url="http://example.com/video" file_size="222" bitrate="333"/>
                </video_asset>
            </video>
        """
        id_generator = Mock()
        id_generator.target_course_id = "test_course_id"
        video = VideoDescriptor.from_xml(xml_data, module_system, id_generator)
        self.assertEqual(video.edx_video_id, "test_edx_video_id")
        video_data = get_video_info(video.edx_video_id)
        self.assertEqual(video_data["client_video_id"], "test_client_video_id")
        self.assertEqual(video_data["duration"], 111)
        self.assertEqual(video_data["status"], "imported")
        self.assertEqual(video_data["courses"], [id_generator.target_course_id])
        self.assertEqual(video_data["encoded_videos"][0]["profile"], "mobile")
        self.assertEqual(video_data["encoded_videos"][0]["url"], "http://example.com/video")
        self.assertEqual(video_data["encoded_videos"][0]["file_size"], 222)
        self.assertEqual(video_data["encoded_videos"][0]["bitrate"], 333)
コード例 #18
0
ファイル: test_video_mongo.py プロジェクト: rhndg/openedx
    def test_get_html_with_existing_edx_video_id(self):
        # create test profiles and their encodings
        encoded_videos = []
        for profile, extension in [("desktop_webm", "webm"), ("desktop_mp4", "mp4")]:
            create_profile(profile)
            encoded_videos.append(
                dict(
                    url=u"http://fake-video.edx.org/thundercats.{}".format(extension),
                    file_size=9000,
                    bitrate=42,
                    profile=profile,
                )
            )

        result = create_video(
            dict(
                client_video_id="Thunder Cats",
                duration=111,
                edx_video_id="thundercats",
                status="test",
                encoded_videos=encoded_videos,
            )
        )
        self.assertEqual(result, "thundercats")

        SOURCE_XML = """
            <video show_captions="true"
            display_name="A Name"
            sub="a_sub_file.srt.sjson" source="{source}"
            download_video="{download_video}"
            start_time="01:00:03" end_time="01:00:10"
            edx_video_id="{edx_video_id}"
            >
                {sources}
            </video>
        """

        data = {
            "download_video": "true",
            "source": "example_source.mp4",
            "sources": """
                <source src="example.mp4"/>
                <source src="example.webm"/>
            """,
            "edx_video_id": "thundercats",
            "result": {
                "download_video_link": u"http://fake-video.edx.org/thundercats.mp4",
                # make sure the urls for the various encodings are included as part of the alternative sources.
                "sources": [u"example.mp4", u"example.webm"] + [video["url"] for video in encoded_videos],
            },
        }

        # Video found for edx_video_id
        metadata = self.default_metadata_dict
        metadata["sources"] = ""
        initial_context = {
            "branding_info": None,
            "license": None,
            "bumper_metadata": "null",
            "cdn_eval": False,
            "cdn_exp_group": None,
            "display_name": u"A Name",
            "download_video_link": u"example.mp4",
            "handout": None,
            "id": self.item_descriptor.location.html_id(),
            "track": None,
            "transcript_download_format": "srt",
            "transcript_download_formats_list": [
                {"display_name": "SubRip (.srt) file", "value": "srt"},
                {"display_name": "Text (.txt) file", "value": "txt"},
            ],
            "poster": "null",
            "metadata": metadata,
        }

        DATA = SOURCE_XML.format(
            download_video=data["download_video"],
            source=data["source"],
            sources=data["sources"],
            edx_video_id=data["edx_video_id"],
        )
        self.initialize_module(data=DATA)
        context = self.item_descriptor.render(STUDENT_VIEW).content

        expected_context = dict(initial_context)
        expected_context["metadata"].update(
            {
                "transcriptTranslationUrl": self.item_descriptor.xmodule_runtime.handler_url(
                    self.item_descriptor, "transcript", "translation/__lang__"
                ).rstrip("/?"),
                "transcriptAvailableTranslationsUrl": self.item_descriptor.xmodule_runtime.handler_url(
                    self.item_descriptor, "transcript", "available_translations"
                ).rstrip("/?"),
                "saveStateUrl": self.item_descriptor.xmodule_runtime.ajax_url + "/save_user_state",
                "sources": data["result"]["sources"],
            }
        )
        expected_context.update(
            {
                "id": self.item_descriptor.location.html_id(),
                "download_video_link": data["result"]["download_video_link"],
                "metadata": json.dumps(expected_context["metadata"]),
            }
        )

        self.assertEqual(context, self.item_descriptor.xmodule_runtime.render_template("video.html", expected_context))
コード例 #19
0
 def setUp(self):
     super(VideoUploadTestMixin, self).setUp()
     self.url = self.get_url_for_course_key(self.course.id)
     self.test_token = "test_token"
     self.course.video_upload_pipeline = {
         "course_video_upload_token": self.test_token,
     }
     self.save_course()
     self.profiles = [
         {
             "profile_name": "profile1",
             "extension": "mp4",
             "width": 640,
             "height": 480,
         },
         {
             "profile_name": "profile2",
             "extension": "mp4",
             "width": 1920,
             "height": 1080,
         },
     ]
     self.previous_uploads = [
         {
             "edx_video_id": "test1",
             "client_video_id": "test1.mp4",
             "duration": 42.0,
             "status": "upload",
             "encoded_videos": [],
         },
         {
             "edx_video_id":
             "test2",
             "client_video_id":
             "test2.mp4",
             "duration":
             128.0,
             "status":
             "file_complete",
             "encoded_videos": [
                 {
                     "profile": "profile1",
                     "url": "http://example.com/profile1/test2.mp4",
                     "file_size": 1600,
                     "bitrate": 100,
                 },
                 {
                     "profile": "profile2",
                     "url": "http://example.com/profile2/test2.mov",
                     "file_size": 16000,
                     "bitrate": 1000,
                 },
             ],
         },
         {
             "edx_video_id":
             "non-ascii",
             "client_video_id":
             u"nón-ascii-näme.mp4",
             "duration":
             256.0,
             "status":
             "transcode_active",
             "encoded_videos": [
                 {
                     "profile": "profile1",
                     "url":
                     u"http://example.com/profile1/nón-ascii-näme.mp4",
                     "file_size": 3200,
                     "bitrate": 100,
                 },
             ]
         },
     ]
     for profile in self.profiles:
         create_profile(profile)
     for video in self.previous_uploads:
         create_video(video)
         modulestore().save_asset_metadata(
             AssetMetadata(
                 self.course.id.make_asset_key(VIDEO_ASSET_TYPE,
                                               video["edx_video_id"])),
             self.user.id)
コード例 #20
0
ファイル: test_videos.py プロジェクト: jzoldak/edx-platform
    def setUp(self):
        super(VideoUploadTestMixin, self).setUp()
        self.url = self.get_url_for_course_key(self.course.id)
        self.test_token = "test_token"
        self.course.video_upload_pipeline = {
            "course_video_upload_token": self.test_token,
        }
        self.save_course()

        # create another course for videos belonging to multiple courses
        self.course2 = CourseFactory.create()
        self.course2.video_upload_pipeline = {
            "course_video_upload_token": self.test_token,
        }
        self.course2.save()
        self.store.update_item(self.course2, self.user.id)

        # course ids for videos
        course_ids = [unicode(self.course.id), unicode(self.course2.id)]

        self.profiles = ["profile1", "profile2"]
        self.previous_uploads = [
            {
                "edx_video_id": "test1",
                "client_video_id": "test1.mp4",
                "duration": 42.0,
                "status": "upload",
                "courses": course_ids,
                "encoded_videos": [],
            },
            {
                "edx_video_id": "test2",
                "client_video_id": "test2.mp4",
                "duration": 128.0,
                "status": "file_complete",
                "courses": course_ids,
                "encoded_videos": [
                    {
                        "profile": "profile1",
                        "url": "http://example.com/profile1/test2.mp4",
                        "file_size": 1600,
                        "bitrate": 100,
                    },
                    {
                        "profile": "profile2",
                        "url": "http://example.com/profile2/test2.mov",
                        "file_size": 16000,
                        "bitrate": 1000,
                    },
                ],
            },
            {
                "edx_video_id": "non-ascii",
                "client_video_id": u"nón-ascii-näme.mp4",
                "duration": 256.0,
                "status": "transcode_active",
                "courses": course_ids,
                "encoded_videos": [
                    {
                        "profile": "profile1",
                        "url": u"http://example.com/profile1/nón-ascii-näme.mp4",
                        "file_size": 3200,
                        "bitrate": 100,
                    },
                ]
            },
        ]
        # Ensure every status string is tested
        self.previous_uploads += [
            {
                "edx_video_id": "status_test_{}".format(status),
                "client_video_id": "status_test.mp4",
                "duration": 3.14,
                "status": status,
                "courses": course_ids,
                "encoded_videos": [],
            }
            for status in (
                StatusDisplayStrings._STATUS_MAP.keys() +  # pylint:disable=protected-access
                ["non_existent_status"]
            )
        ]
        for profile in self.profiles:
            create_profile(profile)
        for video in self.previous_uploads:
            create_video(video)
コード例 #21
0
 def setUp(self):
     super(VideoUploadTestMixin, self).setUp()
     self.url = self.get_url_for_course_key(self.course.id)
     self.test_token = "test_token"
     self.course.video_upload_pipeline = {
         "course_video_upload_token": self.test_token,
     }
     self.save_course()
     self.profiles = [
         {
             "profile_name": "profile1",
             "extension": "mp4",
             "width": 640,
             "height": 480,
         },
         {
             "profile_name": "profile2",
             "extension": "mp4",
             "width": 1920,
             "height": 1080,
         },
     ]
     self.previous_uploads = [
         {
             "edx_video_id": "test1",
             "client_video_id": "test1.mp4",
             "duration": 42.0,
             "status": "upload",
             "encoded_videos": [],
         },
         {
             "edx_video_id": "test2",
             "client_video_id": "test2.mp4",
             "duration": 128.0,
             "status": "file_complete",
             "encoded_videos": [
                 {
                     "profile": "profile1",
                     "url": "http://example.com/profile1/test2.mp4",
                     "file_size": 1600,
                     "bitrate": 100,
                 },
                 {
                     "profile": "profile2",
                     "url": "http://example.com/profile2/test2.mov",
                     "file_size": 16000,
                     "bitrate": 1000,
                 },
             ],
         },
         {
             "edx_video_id": "non-ascii",
             "client_video_id": u"nón-ascii-näme.mp4",
             "duration": 256.0,
             "status": "transcode_active",
             "encoded_videos": [
                 {
                     "profile": "profile1",
                     "url": u"http://example.com/profile1/nón-ascii-näme.mp4",
                     "file_size": 3200,
                     "bitrate": 100,
                 },
             ]
         },
     ]
     for profile in self.profiles:
         create_profile(profile)
     for video in self.previous_uploads:
         create_video(video)
         modulestore().save_asset_metadata(
             AssetMetadata(
                 self.course.id.make_asset_key(VIDEO_ASSET_TYPE, video["edx_video_id"])
             ),
             self.user.id
         )
コード例 #22
0
    def test_get_html_with_existing_edx_video_id(self):
        # create test profiles and their encodings
        encoded_videos = []
        for profile, extension in [("desktop_webm", "webm"), ("desktop_mp4", "mp4")]:
            result = create_profile(dict(profile_name=profile, extension=extension, width=200, height=2001))
            self.assertEqual(result, profile)
            encoded_videos.append(
                dict(
                    url=u"http://fake-video.edx.org/thundercats.{}".format(extension),
                    file_size=9000,
                    bitrate=42,
                    profile=profile,
                )
            )

        result = create_video(
            dict(
                client_video_id="Thunder Cats",
                duration=111,
                edx_video_id="thundercats",
                status="test",
                encoded_videos=encoded_videos,
            )
        )
        self.assertEqual(result, "thundercats")

        SOURCE_XML = """
            <video show_captions="true"
            display_name="A Name"
            sub="a_sub_file.srt.sjson" source="{source}"
            download_video="{download_video}"
            start_time="01:00:03" end_time="01:00:10"
            edx_video_id="{edx_video_id}"
            >
                {sources}
            </video>
        """

        data = {
            "download_video": "true",
            "source": "example_source.mp4",
            "sources": """
                <source src="example.mp4"/>
                <source src="example.webm"/>
            """,
            "edx_video_id": "thundercats",
            "result": {
                "download_video_link": u"http://fake-video.edx.org/thundercats.mp4",
                # make sure the urls for the various encodings are included as part of the alternative sources.
                "sources": json.dumps([u"example.mp4", u"example.webm"] + [video["url"] for video in encoded_videos]),
            },
        }

        # Video found for edx_video_id
        initial_context = {
            "data_dir": getattr(self, "data_dir", None),
            "show_captions": "true",
            "handout": None,
            "display_name": u"A Name",
            "download_video_link": None,
            "end": 3610.0,
            "id": None,
            "sources": "[]",
            "speed": "null",
            "general_speed": 1.0,
            "start": 3603.0,
            "saved_video_position": 0.0,
            "sub": u"a_sub_file.srt.sjson",
            "track": None,
            "youtube_streams": "1.00:OEoXaMPEzfM",
            "autoplay": settings.FEATURES.get("AUTOPLAY_VIDEOS", True),
            "yt_test_timeout": 1500,
            "yt_api_url": "www.youtube.com/iframe_api",
            "yt_test_url": "gdata.youtube.com/feeds/api/videos/",
            "transcript_download_format": "srt",
            "transcript_download_formats_list": [
                {"display_name": "SubRip (.srt) file", "value": "srt"},
                {"display_name": "Text (.txt) file", "value": "txt"},
            ],
            "transcript_language": u"en",
            "transcript_languages": '{"en": "English"}',
        }

        DATA = SOURCE_XML.format(
            download_video=data["download_video"],
            source=data["source"],
            sources=data["sources"],
            edx_video_id=data["edx_video_id"],
        )
        self.initialize_module(data=DATA)
        context = self.item_descriptor.render(STUDENT_VIEW).content

        expected_context = dict(initial_context)
        expected_context.update(
            {
                "transcript_translation_url": self.item_descriptor.xmodule_runtime.handler_url(
                    self.item_descriptor, "transcript", "translation"
                ).rstrip("/?"),
                "transcript_available_translations_url": self.item_descriptor.xmodule_runtime.handler_url(
                    self.item_descriptor, "transcript", "available_translations"
                ).rstrip("/?"),
                "ajax_url": self.item_descriptor.xmodule_runtime.ajax_url + "/save_user_state",
                "id": self.item_descriptor.location.html_id(),
            }
        )
        expected_context.update(data["result"])

        self.assertEqual(context, self.item_descriptor.xmodule_runtime.render_template("video.html", expected_context))
コード例 #23
0
ファイル: tests.py プロジェクト: TMJUSTNOW/edx-platform_lti
    def setUp(self):
        super(TestVideoAPITestCase, self).setUp()
        self.section = ItemFactory.create(
            parent_location=self.course.location,
            category="chapter",
            display_name=u"test factory section omega \u03a9",
        )
        self.sub_section = ItemFactory.create(
            parent_location=self.section.location,
            category="sequential",
            display_name=u"test subsection omega \u03a9",
        )

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

        self.split_test = ItemFactory.create(
            parent_location=self.split_unit.location,
            category="split_test",
            display_name=u"split test unit")

        self.edx_video_id = 'testing-123'

        self.video_url = 'http://val.edx.org/val/video.mp4'
        self.html5_video_url = 'http://video.edx.org/html5/video.mp4'

        api.create_profile({
            'profile_name': 'youtube',
            'extension': 'mp4',
            'width': 1280,
            'height': 720
        })
        api.create_profile({
            'profile_name': 'mobile_low',
            'extension': 'mp4',
            'width': 640,
            'height': 480
        })

        # 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
            }]
        })
コード例 #24
0
ファイル: tests.py プロジェクト: ZheJiuShiMing/edx-platform
    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()
コード例 #25
0
ファイル: test_videos.py プロジェクト: gregrgay/edx-platform
 def setUp(self):
     super(VideoUploadTestMixin, self).setUp()
     self.url = self.get_url_for_course_key(self.course.id)
     self.test_token = "test_token"
     self.course.video_upload_pipeline = {
         "course_video_upload_token": self.test_token,
     }
     self.save_course()
     self.profiles = ["profile1", "profile2"]
     self.previous_uploads = [
         {
             "edx_video_id": "test1",
             "client_video_id": "test1.mp4",
             "duration": 42.0,
             "status": "upload",
             "encoded_videos": [],
         },
         {
             "edx_video_id": "test2",
             "client_video_id": "test2.mp4",
             "duration": 128.0,
             "status": "file_complete",
             "encoded_videos": [
                 {
                     "profile": "profile1",
                     "url": "http://example.com/profile1/test2.mp4",
                     "file_size": 1600,
                     "bitrate": 100,
                 },
                 {
                     "profile": "profile2",
                     "url": "http://example.com/profile2/test2.mov",
                     "file_size": 16000,
                     "bitrate": 1000,
                 },
             ],
         },
         {
             "edx_video_id": "non-ascii",
             "client_video_id": u"nón-ascii-näme.mp4",
             "duration": 256.0,
             "status": "transcode_active",
             "encoded_videos": [
                 {
                     "profile": "profile1",
                     "url": u"http://example.com/profile1/nón-ascii-näme.mp4",
                     "file_size": 3200,
                     "bitrate": 100,
                 },
             ]
         },
     ]
     # Ensure every status string is tested
     self.previous_uploads += [
         {
             "edx_video_id": "status_test_{}".format(status),
             "client_video_id": "status_test.mp4",
             "duration": 3.14,
             "status": status,
             "encoded_videos": [],
         }
         for status in (
             StatusDisplayStrings._STATUS_MAP.keys() +  # pylint:disable=protected-access
             ["non_existent_status"]
         )
     ]
     for profile in self.profiles:
         create_profile(profile)
     for video in self.previous_uploads:
         create_video(video)
         modulestore().save_asset_metadata(
             AssetMetadata(
                 self.course.id.make_asset_key(VIDEO_ASSET_TYPE, video["edx_video_id"])
             ),
             self.user.id
         )
コード例 #26
0
ファイル: tests.py プロジェクト: PiyushDeshmukh/edx-platform
    def setUp(self):
        super(TestVideoOutline, self).setUp()
        self.user = UserFactory.create()
        self.course = CourseFactory.create(mobile_available=True)
        self.section = ItemFactory.create(
            parent_location=self.course.location,
            category="chapter",
            display_name=u"test factory section omega \u03a9",
        )
        self.sub_section = ItemFactory.create(
            parent_location=self.section.location,
            category="sequential",
            display_name=u"test subsection omega \u03a9",
        )

        self.unit = ItemFactory.create(
            parent_location=self.sub_section.location,
            category="vertical",
            metadata={'graded': True, 'format': 'Homework'},
            display_name=u"test unit omega \u03a9",
        )
        self.other_unit = ItemFactory.create(
            parent_location=self.sub_section.location,
            category="vertical",
            metadata={'graded': True, 'format': 'Homework'},
            display_name=u"test unit omega 2 \u03a9",
        )
        self.nameless_unit = ItemFactory.create(
            parent_location=self.sub_section.location,
            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.html5_video_url = 'http://video.edx.org/html5/video.mp4'

        api.create_profile({
            'profile_name': 'youtube',
            'extension': 'mp4',
            'width': 1280,
            'height': 720
        })
        api.create_profile({
            'profile_name': 'mobile_low',
            'extension': 'mp4',
            'width': 640,
            'height': 480
        })

        # create the video in VAL
        api.create_video({
            'edx_video_id': self.edx_video_id,
            '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
                }
            ]})

        self.client.login(username=self.user.username, password='******')
コード例 #27
0
 def test_create_profile_duplicate(self):
     api.create_profile(constants.PROFILE_DESKTOP)
     with self.assertRaises(ValCannotCreateError):
         api.create_profile(constants.PROFILE_DESKTOP)
コード例 #28
0
ファイル: test_api.py プロジェクト: cpennington/edx-val
 def test_invalid_create_profile(self, data): # pylint: disable=W0621
     """
     Tests the creation of invalid profile data
     """
     with self.assertRaises(ValCannotCreateError):
         api.create_profile(data)
コード例 #29
0
 def setUp(self):
     super(VideoUploadTestMixin, self).setUp()
     self.url = self.get_url_for_course_key(self.course.id)
     self.test_token = "test_token"
     self.course.video_upload_pipeline = {
         "course_video_upload_token": self.test_token,
     }
     self.save_course()
     self.profiles = ["profile1", "profile2"]
     self.previous_uploads = [
         {
             "edx_video_id": "test1",
             "client_video_id": "test1.mp4",
             "duration": 42.0,
             "status": "upload",
             "encoded_videos": [],
         },
         {
             "edx_video_id":
             "test2",
             "client_video_id":
             "test2.mp4",
             "duration":
             128.0,
             "status":
             "file_complete",
             "encoded_videos": [
                 {
                     "profile": "profile1",
                     "url": "http://example.com/profile1/test2.mp4",
                     "file_size": 1600,
                     "bitrate": 100,
                 },
                 {
                     "profile": "profile2",
                     "url": "http://example.com/profile2/test2.mov",
                     "file_size": 16000,
                     "bitrate": 1000,
                 },
             ],
         },
         {
             "edx_video_id":
             "non-ascii",
             "client_video_id":
             u"nón-ascii-näme.mp4",
             "duration":
             256.0,
             "status":
             "transcode_active",
             "encoded_videos": [
                 {
                     "profile": "profile1",
                     "url":
                     u"http://example.com/profile1/nón-ascii-näme.mp4",
                     "file_size": 3200,
                     "bitrate": 100,
                 },
             ]
         },
     ]
     # Ensure every status string is tested
     self.previous_uploads += [
         {
             "edx_video_id": "status_test_{}".format(status),
             "client_video_id": "status_test.mp4",
             "duration": 3.14,
             "status": status,
             "encoded_videos": [],
         } for status in (StatusDisplayStrings._STATUS_MAP.keys() +  # pylint:disable=protected-access
                          ["non_existent_status"])
     ]
     for profile in self.profiles:
         create_profile(profile)
     for video in self.previous_uploads:
         create_video(video)
         modulestore().save_asset_metadata(
             AssetMetadata(
                 self.course.id.make_asset_key(VIDEO_ASSET_TYPE,
                                               video["edx_video_id"])),
             self.user.id)
コード例 #30
0
    def test_get_html_with_existing_edx_video_id(self):
        # create test profiles and their encodings
        encoded_videos = []
        for profile, extension in [("desktop_webm", "webm"), ("desktop_mp4", "mp4")]:
            create_profile(profile)
            encoded_videos.append(
                dict(
                    url=u"http://fake-video.edx.org/thundercats.{}".format(extension),
                    file_size=9000,
                    bitrate=42,
                    profile=profile,
                )
            )

        result = create_video(
            dict(
                client_video_id="Thunder Cats",
                duration=111,
                edx_video_id="thundercats",
                status='test',
                encoded_videos=encoded_videos
            )
        )
        self.assertEqual(result, "thundercats")

        SOURCE_XML = """
            <video show_captions="true"
            display_name="A Name"
            sub="a_sub_file.srt.sjson" source="{source}"
            download_video="{download_video}"
            start_time="01:00:03" end_time="01:00:10"
            edx_video_id="{edx_video_id}"
            >
                {sources}
            </video>
        """

        data = {
            'download_video': 'true',
            'source': 'example_source.mp4',
            'sources': """
                <source src="example.mp4"/>
                <source src="example.webm"/>
            """,
            'edx_video_id': "thundercats",
            'result': {
                'download_video_link': u'http://fake-video.edx.org/thundercats.mp4',
                # make sure the urls for the various encodings are included as part of the alternative sources.
                'sources': [u'example.mp4', u'example.webm'] +
                           [video['url'] for video in encoded_videos],
            }
        }

        # Video found for edx_video_id
        metadata = self.default_metadata_dict
        metadata['sources'] = ""
        initial_context = {
            'branding_info': None,
            'license': None,
            'bumper_metadata': 'null',
            'cdn_eval': False,
            'cdn_exp_group': None,
            'display_name': u'A Name',
            'download_video_link': u'example.mp4',
            'handout': None,
            'id': self.item_descriptor.location.html_id(),
            'track': None,
            'transcript_download_format': 'srt',
            'transcript_download_formats_list': [
                {'display_name': 'SubRip (.srt) file', 'value': 'srt'},
                {'display_name': 'Text (.txt) file', 'value': 'txt'}
            ],
            'poster': 'null',
            'metadata': metadata,
        }

        DATA = SOURCE_XML.format(
            download_video=data['download_video'],
            source=data['source'],
            sources=data['sources'],
            edx_video_id=data['edx_video_id']
        )
        self.initialize_module(data=DATA)
        context = self.item_descriptor.render(STUDENT_VIEW).content

        expected_context = dict(initial_context)
        expected_context['metadata'].update({
            'transcriptTranslationUrl': self.item_descriptor.xmodule_runtime.handler_url(
                self.item_descriptor, 'transcript', 'translation/__lang__'
            ).rstrip('/?'),
            'transcriptAvailableTranslationsUrl': self.item_descriptor.xmodule_runtime.handler_url(
                self.item_descriptor, 'transcript', 'available_translations'
            ).rstrip('/?'),
            'saveStateUrl': self.item_descriptor.xmodule_runtime.ajax_url + '/save_user_state',
            'sources': data['result']['sources'],
        })
        expected_context.update({
            'id': self.item_descriptor.location.html_id(),
            'download_video_link': data['result']['download_video_link'],
            'metadata': json.dumps(expected_context['metadata'])
        })

        self.assertEqual(
            context,
            self.item_descriptor.xmodule_runtime.render_template('video.html', expected_context)
        )
コード例 #31
0
    def setUp(self):
        super(TestVideoOutline, self).setUp()
        self.user = UserFactory.create()
        self.course = CourseFactory.create(mobile_available=True)
        section = ItemFactory.create(
            parent_location=self.course.location,
            category="chapter",
            display_name=u"test factory section omega \u03a9",
        )
        self.sub_section = ItemFactory.create(
            parent_location=section.location,
            category="sequential",
            display_name=u"test subsection omega \u03a9",
        )

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

        self.edx_video_id = 'testing-123'

        self.video_url = 'http://val.edx.org/val/video.mp4'
        self.html5_video_url = 'http://video.edx.org/html5/video.mp4'

        api.create_profile({
            'profile_name': 'youtube',
            'extension': 'mp4',
            'width': 1280,
            'height': 720
            })
        api.create_profile({
            'profile_name': 'mobile_low',
            'extension': 'mp4',
            'width': 640,
            'height': 480
            })

        val_video = api.create_video({
            'edx_video_id': self.edx_video_id,
            '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
                }
            ]})

        subid = uuid4().hex
        self.video = ItemFactory.create(
            parent_location=self.unit.location,
            category="video",
            edx_video_id=self.edx_video_id,
            display_name=u"test video omega \u03a9",
            sub=subid
        )

        result_location = transcripts_utils.save_subs_to_store({
            'start': [100, 200, 240, 390, 1000],
            'end': [200, 240, 380, 1000, 1500],
            'text': [
                'subs #1',
                'subs #2',
                'subs #3',
                'subs #4',
                'subs #5'
            ]},
            subid,
            self.course)

        self.client.login(username=self.user.username, password='******')
コード例 #32
0
    def test_get_html_with_existing_edx_video_id(self):
        # create test profiles and their encodings
        encoded_videos = []
        for profile, extension in [("desktop_webm", "webm"), ("desktop_mp4", "mp4")]:
            create_profile(profile)
            encoded_videos.append(
                dict(
                    url=u"http://fake-video.edx.org/thundercats.{}".format(extension),
                    file_size=9000,
                    bitrate=42,
                    profile=profile,
                )
            )

        result = create_video(
            dict(
                client_video_id="Thunder Cats",
                duration=111,
                edx_video_id="thundercats",
                status='test',
                encoded_videos=encoded_videos
            )
        )
        self.assertEqual(result, "thundercats")

        SOURCE_XML = """
            <video show_captions="true"
            display_name="A Name"
            sub="a_sub_file.srt.sjson" source="{source}"
            download_video="{download_video}"
            start_time="01:00:03" end_time="01:00:10"
            edx_video_id="{edx_video_id}"
            >
                {sources}
            </video>
        """

        data = {
            'download_video': 'true',
            'source': 'example_source.mp4',
            'sources': """
                <source src="example.mp4"/>
                <source src="example.webm"/>
            """,
            'edx_video_id': "thundercats",
            'result': {
                'download_video_link': u'http://fake-video.edx.org/thundercats.mp4',
                # make sure the urls for the various encodings are included as part of the alternative sources.
                'sources': json.dumps(
                    [u'example.mp4', u'example.webm'] +
                    [video['url'] for video in encoded_videos]
                ),
            }
        }

        # Video found for edx_video_id
        initial_context = {
            'branding_info': None,
            'cdn_eval': False,
            'cdn_exp_group': None,
            'data_dir': getattr(self, 'data_dir', None),
            'show_captions': 'true',
            'handout': None,
            'display_name': u'A Name',
            'download_video_link': None,
            'end': 3610.0,
            'id': None,
            'sources': '[]',
            'speed': 'null',
            'general_speed': 1.0,
            'start': 3603.0,
            'saved_video_position': 0.0,
            'sub': u'a_sub_file.srt.sjson',
            'track': None,
            'youtube_streams': '1.00:3_yD_cEKoCk',
            'autoplay': settings.FEATURES.get('AUTOPLAY_VIDEOS', True),
            'yt_test_timeout': 1500,
            'yt_api_url': 'www.youtube.com/iframe_api',
            'yt_test_url': 'gdata.youtube.com/feeds/api/videos/',
            'transcript_download_format': 'srt',
            'transcript_download_formats_list': [{'display_name': 'SubRip (.srt) file', 'value': 'srt'}, {'display_name': 'Text (.txt) file', 'value': 'txt'}],
            'transcript_language': u'en',
            'transcript_languages': '{"en": "English"}',
        }

        DATA = SOURCE_XML.format(
            download_video=data['download_video'],
            source=data['source'],
            sources=data['sources'],
            edx_video_id=data['edx_video_id']
        )
        self.initialize_module(data=DATA)
        context = self.item_descriptor.render(STUDENT_VIEW).content

        expected_context = dict(initial_context)
        expected_context.update({
            'transcript_translation_url': self.item_descriptor.xmodule_runtime.handler_url(
                self.item_descriptor, 'transcript', 'translation'
            ).rstrip('/?'),
            'transcript_available_translations_url': self.item_descriptor.xmodule_runtime.handler_url(
                self.item_descriptor, 'transcript', 'available_translations'
            ).rstrip('/?'),
            'ajax_url': self.item_descriptor.xmodule_runtime.ajax_url + '/save_user_state',
            'id': self.item_descriptor.location.html_id(),
        })
        expected_context.update(data['result'])

        self.assertEqual(
            context,
            self.item_descriptor.xmodule_runtime.render_template('video.html', expected_context)
        )
コード例 #33
0
 def test_invalid_create_profile(self):
     """
     Tests the creation of invalid profile data
     """
     with self.assertRaises(ValCannotCreateError):
         api.create_profile(constants.PROFILE_INVALID_NAME)
コード例 #34
0
    def setUp(self):
        super(TestVideoOutline, self).setUp()
        self.user = UserFactory.create()
        self.course = CourseFactory.create(mobile_available=True)
        section = ItemFactory.create(
            parent_location=self.course.location,
            category="chapter",
            display_name=u"test factory section omega \u03a9",
        )
        self.sub_section = ItemFactory.create(
            parent_location=section.location,
            category="sequential",
            display_name=u"test subsection omega \u03a9",
        )

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

        self.edx_video_id = 'testing-123'

        self.video_url = 'http://val.edx.org/val/video.mp4'
        self.html5_video_url = 'http://video.edx.org/html5/video.mp4'

        api.create_profile({
            'profile_name': 'youtube',
            'extension': 'mp4',
            'width': 1280,
            'height': 720
        })
        api.create_profile({
            'profile_name': 'mobile_low',
            'extension': 'mp4',
            'width': 640,
            'height': 480
        })

        # create the video in VAL
        api.create_video({
            'edx_video_id': self.edx_video_id,
            '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
                }
            ]})

        subid = uuid4().hex
        self.video = ItemFactory.create(
            parent_location=self.unit.location,
            category="video",
            edx_video_id=self.edx_video_id,
            display_name=u"test video omega \u03a9",
            sub=subid
        )

        transcripts_utils.save_subs_to_store({
            'start': [100, 200, 240, 390, 1000],
            'end': [200, 240, 380, 1000, 1500],
            'text': [
                'subs #1',
                'subs #2',
                'subs #3',
                'subs #4',
                'subs #5'
            ]},
            subid,
            self.course)

        self.client.login(username=self.user.username, password='******')
コード例 #35
0
ファイル: test_api.py プロジェクト: open-craft/edx-val
 def test_invalid_create_profile(self):
     """
     Tests the creation of invalid profile data
     """
     with self.assertRaises(ValCannotCreateError):
         api.create_profile(constants.PROFILE_INVALID_NAME)
コード例 #36
0
    def test_get_html_with_existing_edx_video_id(self):
        # create test profiles and their encodings
        encoded_videos = []
        for profile, extension in [("desktop_webm", "webm"),
                                   ("desktop_mp4", "mp4")]:
            create_profile(profile)
            encoded_videos.append(
                dict(
                    url=u"http://fake-video.edx.org/thundercats.{}".format(
                        extension),
                    file_size=9000,
                    bitrate=42,
                    profile=profile,
                ))

        result = create_video(
            dict(client_video_id="Thunder Cats",
                 duration=111,
                 edx_video_id="thundercats",
                 status='test',
                 encoded_videos=encoded_videos))
        self.assertEqual(result, "thundercats")

        SOURCE_XML = """
            <video show_captions="true"
            display_name="A Name"
            sub="a_sub_file.srt.sjson" source="{source}"
            download_video="{download_video}"
            start_time="01:00:03" end_time="01:00:10"
            edx_video_id="{edx_video_id}"
            >
                {sources}
            </video>
        """

        data = {
            'download_video': 'true',
            'source': 'example_source.mp4',
            'sources': """
                <source src="example.mp4"/>
                <source src="example.webm"/>
            """,
            'edx_video_id': "thundercats",
            'result': {
                'download_video_link':
                u'http://fake-video.edx.org/thundercats.mp4',
                # make sure the urls for the various encodings are included as part of the alternative sources.
                'sources':
                json.dumps([u'example.mp4', u'example.webm'] +
                           [video['url'] for video in encoded_videos]),
            }
        }

        # Video found for edx_video_id
        initial_context = {
            'branding_info':
            None,
            'cdn_eval':
            False,
            'cdn_exp_group':
            None,
            'data_dir':
            getattr(self, 'data_dir', None),
            'show_captions':
            'true',
            'handout':
            None,
            'display_name':
            u'A Name',
            'download_video_link':
            None,
            'end':
            3610.0,
            'id':
            None,
            'sources':
            '[]',
            'speed':
            'null',
            'general_speed':
            1.0,
            'start':
            3603.0,
            'saved_video_position':
            0.0,
            'sub':
            u'a_sub_file.srt.sjson',
            'track':
            None,
            'youtube_streams':
            '1.00:3_yD_cEKoCk',
            'autoplay':
            settings.FEATURES.get('AUTOPLAY_VIDEOS', True),
            'yt_test_timeout':
            1500,
            'yt_api_url':
            'www.youtube.com/iframe_api',
            'yt_test_url':
            'gdata.youtube.com/feeds/api/videos/',
            'transcript_download_format':
            'srt',
            'transcript_download_formats_list': [{
                'display_name': 'SubRip (.srt) file',
                'value': 'srt'
            }, {
                'display_name': 'Text (.txt) file',
                'value': 'txt'
            }],
            'transcript_language':
            u'en',
            'transcript_languages':
            '{"en": "English"}',
        }

        DATA = SOURCE_XML.format(download_video=data['download_video'],
                                 source=data['source'],
                                 sources=data['sources'],
                                 edx_video_id=data['edx_video_id'])
        self.initialize_module(data=DATA)
        context = self.item_descriptor.render(STUDENT_VIEW).content

        expected_context = dict(initial_context)
        expected_context.update({
            'transcript_translation_url':
            self.item_descriptor.xmodule_runtime.handler_url(
                self.item_descriptor, 'transcript',
                'translation').rstrip('/?'),
            'transcript_available_translations_url':
            self.item_descriptor.xmodule_runtime.handler_url(
                self.item_descriptor, 'transcript',
                'available_translations').rstrip('/?'),
            'ajax_url':
            self.item_descriptor.xmodule_runtime.ajax_url + '/save_user_state',
            'id':
            self.item_descriptor.location.html_id(),
        })
        expected_context.update(data['result'])

        self.assertEqual(
            context,
            self.item_descriptor.xmodule_runtime.render_template(
                'video.html', expected_context))
コード例 #37
0
ファイル: test_api.py プロジェクト: open-craft/edx-val
 def test_create_profile_duplicate(self):
     api.create_profile(constants.PROFILE_DESKTOP)
     with self.assertRaises(ValCannotCreateError):
         api.create_profile(constants.PROFILE_DESKTOP)
コード例 #38
0
ファイル: tests.py プロジェクト: xuyeli2002/edx-platform
    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()
コード例 #39
0
ファイル: test_api.py プロジェクト: open-craft/edx-val
 def setUp(self):
     """
     Creation of Profile objects that will be used to test video creation
     """
     api.create_profile(constants.PROFILE_DESKTOP)
     api.create_profile(constants.PROFILE_MOBILE)
コード例 #40
0
    def setUp(self):
        super(VideoUploadTestBase, self).setUp()
        self.url = self.get_url_for_course_key(self.course.id)
        self.test_token = "test_token"
        self.course.video_upload_pipeline = {
            "course_video_upload_token": self.test_token,
        }
        self.save_course()

        # create another course for videos belonging to multiple courses
        self.course2 = CourseFactory.create()
        self.course2.video_upload_pipeline = {
            "course_video_upload_token": self.test_token,
        }
        self.course2.save()
        self.store.update_item(self.course2, self.user.id)

        # course ids for videos
        course_ids = [unicode(self.course.id), unicode(self.course2.id)]
        created = datetime.now(pytz.utc)

        self.profiles = ["profile1", "profile2"]
        self.previous_uploads = [
            {
                "edx_video_id": "test1",
                "client_video_id": "test1.mp4",
                "duration": 42.0,
                "status": "upload",
                "courses": course_ids,
                "encoded_videos": [],
                "created": created
            },
            {
                "edx_video_id":
                "test2",
                "client_video_id":
                "test2.mp4",
                "duration":
                128.0,
                "status":
                "file_complete",
                "courses":
                course_ids,
                "created":
                created,
                "encoded_videos": [
                    {
                        "profile": "profile1",
                        "url": "http://example.com/profile1/test2.mp4",
                        "file_size": 1600,
                        "bitrate": 100,
                    },
                    {
                        "profile": "profile2",
                        "url": "http://example.com/profile2/test2.mov",
                        "file_size": 16000,
                        "bitrate": 1000,
                    },
                ],
            },
            {
                "edx_video_id":
                "non-ascii",
                "client_video_id":
                u"nón-ascii-näme.mp4",
                "duration":
                256.0,
                "status":
                "transcode_active",
                "courses":
                course_ids,
                "created":
                created,
                "encoded_videos": [
                    {
                        "profile": "profile1",
                        "url":
                        u"http://example.com/profile1/nón-ascii-näme.mp4",
                        "file_size": 3200,
                        "bitrate": 100,
                    },
                ]
            },
        ]
        # Ensure every status string is tested
        self.previous_uploads += [
            {
                "edx_video_id": "status_test_{}".format(status),
                "client_video_id": "status_test.mp4",
                "duration": 3.14,
                "status": status,
                "courses": course_ids,
                "created": created,
                "encoded_videos": [],
            } for status in (StatusDisplayStrings._STATUS_MAP.keys() +  # pylint:disable=protected-access
                             ["non_existent_status"])
        ]
        for profile in self.profiles:
            create_profile(profile)
        for video in self.previous_uploads:
            create_video(video)
コード例 #41
0
 def setUp(self):
     """
     Creation of Profile objects that will be used to test video creation
     """
     api.create_profile(constants.PROFILE_DESKTOP)
     api.create_profile(constants.PROFILE_MOBILE)