def test_video_constructor(self):
        """Make sure that all parameters extracted correctly from xml"""
        context = self.item_module.render('student_view').content

        sources = {
            'main': u'example.mp4',
            u'mp4': u'example.mp4',
            u'webm': u'example.webm',
        }

        expected_context = {
            'ajax_url': self.item_descriptor.xmodule_runtime.ajax_url + '/save_user_state',
            'data_dir': getattr(self, 'data_dir', None),
            'caption_asset_path': '/static/subs/',
            'show_captions': 'true',
            'display_name': u'A Name',
            'end': 3610.0,
            'id': self.item_module.location.html_id(),
            'sources': sources,
            'speed': 'null',
            'general_speed': 1.0,
            'start': 3603.0,
            'sub': u'a_sub_file.srt.sjson',
            'track': None,
            'youtube_streams': _create_youtube_string(self.item_module),
            'autoplay': settings.FEATURES.get('AUTOPLAY_VIDEOS', False),
            'yt_test_timeout': 1500,
            'yt_test_url': 'https://gdata.youtube.com/feeds/api/videos/',
        }

        self.assertEqual(
            context,
            self.item_module.xmodule_runtime.render_template('video.html', expected_context),
        )
    def test_video_get_html(self):
        """Make sure that all parameters extracted correclty from xml"""
        module = VideoFactory.create()

        sources = {
            'main': 'example.mp4',
            'mp4': 'example.mp4',
            'webm': 'example.webm',
            'ogv': 'example.ogv'
        }

        expected_context = {
            'caption_asset_path': '/static/subs/',
            'sub': 'a_sub_file.srt.sjson',
            'data_dir': getattr(self, 'data_dir', None),
            'display_name': 'A Name',
            'end': 3610.0,
            'start': 3603.0,
            'id': module.location.html_id(),
            'show_captions': 'true',
            'sources': sources,
            'youtube_streams': _create_youtube_string(module),
            'track': '',
            'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', False),
            'yt_test_timeout': 1500,
            'yt_test_url': 'https://gdata.youtube.com/feeds/api/videos/'
        }

        self.assertEqual(
            module.render('student_view').content,
            module.runtime.render_template('video.html', expected_context)
        )
Example #3
0
    def test_video_get_html(self):
        """Make sure that all parameters extracted correclty from xml"""
        module = VideoFactory.create()
        module.runtime.render_template = lambda template, context: context

        sources = {
            'main': 'example.mp4',
            'mp4': 'example.mp4',
            'webm': 'example.webm',
            'ogv': 'example.ogv'
        }

        expected_context = {
            'caption_asset_path': '/static/subs/',
            'sub': 'a_sub_file.srt.sjson',
            'data_dir': getattr(self, 'data_dir', None),
            'display_name': 'A Name',
            'end': 3610.0,
            'start': 3603.0,
            'id': module.location.html_id(),
            'show_captions': 'true',
            'sources': sources,
            'youtube_streams': _create_youtube_string(module),
            'track': '',
            'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True)
        }

        self.assertEqual(module.get_html(), expected_context)
    def test_video_get_html(self):
        """Make sure that all parameters extracted correclty from xml"""
        module = VideoFactory.create()
        module.runtime.render_template = lambda template, context: context

        sources = {
            'main': 'example.mp4',
            'mp4': 'example.mp4',
            'webm': 'example.webm',
            'ogv': 'example.ogv'
        }

        expected_context = {
            'caption_asset_path': '/static/subs/',
            'sub': 'a_sub_file.srt.sjson',
            'data_dir': getattr(self, 'data_dir', None),
            'display_name': 'A Name',
            'end': 3610.0,
            'start': 3603.0,
            'id': module.location.html_id(),
            'show_captions': 'true',
            'sources': sources,
            'youtube_streams': _create_youtube_string(module),
            'track': '',
            'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True)
        }

        self.assertEqual(module.get_html(), expected_context)
    def test_video_constructor(self):
        """Make sure that all parameters extracted correclty from xml"""

        context = self.item_module.get_html()

        sources = {
            'main': u'example.mp4',
            u'mp4': u'example.mp4',
            u'webm': u'example.webm',
            u'ogv': u'example.ogv'
        }

        expected_context = {
            'data_dir': getattr(self, 'data_dir', None),
            'caption_asset_path': '/static/subs/',
            'show_captions': 'true',
            'display_name': 'A Name',
            'end': 3610.0,
            'id': self.item_module.location.html_id(),
            'sources': sources,
            'start': 3603.0,
            'sub': u'a_sub_file.srt.sjson',
            'track': '',
            'youtube_streams': _create_youtube_string(self.item_module),
            'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True)
        }

        self.maxDiff = None
        self.assertEqual(context, expected_context)
    def test_video_constructor(self):
        """Make sure that all parameters extracted correclty from xml"""

        context = self.item_module.get_html()

        sources = {
            'main': u'example.mp4',
            u'mp4': u'example.mp4',
            u'webm': u'example.webm',
            u'ogv': u'example.ogv'
        }

        expected_context = {
            'data_dir': getattr(self, 'data_dir', None),
            'caption_asset_path': '/static/subs/',
            'show_captions': 'true',
            'display_name': 'A Name',
            'end': 3610.0,
            'id': self.item_module.location.html_id(),
            'sources': sources,
            'start': 3603.0,
            'sub': u'a_sub_file.srt.sjson',
            'track': '',
            'youtube_streams': _create_youtube_string(self.item_module),
            'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True)
        }

        self.maxDiff = None
        self.assertEqual(context, expected_context)
Example #7
0
    def test_video_constructor(self):
        """Make sure that all parameters extracted correclty from xml"""

        context = self.item_module.render('student_view').content

        sources = {
            'main': u'example.mp4',
            u'mp4': u'example.mp4',
            u'webm': u'example.webm',
            u'ogv': u'example.ogv'
        }

        expected_context = {
            'data_dir': getattr(self, 'data_dir', None),
            'caption_asset_path': '/static/subs/',
            'show_captions': 'true',
            'display_name': u'A Name',
            'end': 3610.0,
            'id': self.item_module.location.html_id(),
            'sources': sources,
            'start': 3603.0,
            'sub': u'a_sub_file.srt.sjson',
            'track': '',
            'youtube_streams': _create_youtube_string(self.item_module),
            'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', False),
            'yt_test_timeout': 1500,
            'yt_test_url': 'https://gdata.youtube.com/feeds/api/videos/'
        }

        self.assertEqual(
            context,
            self.item_module.xmodule_runtime.render_template(
                'video.html', expected_context))
Example #8
0
 def test_create_youtube_string_missing(self):
     """
     Test that Youtube IDs which aren't explicitly set aren't included
     in the output string.
     """
     system = DummySystem(load_error_modules=True)
     location = Location(["i4x", "edX", "video", "default", "SampleProblem1"])
     model_data = {'location': location}
     descriptor = VideoDescriptor(system, model_data)
     descriptor.youtube_id_0_75 = 'izygArpw-Qo'
     descriptor.youtube_id_1_0 = 'p2Q6BrNhdh8'
     descriptor.youtube_id_1_25 = '1EeWXzPdhSA'
     expected = "0.75:izygArpw-Qo,1.00:p2Q6BrNhdh8,1.25:1EeWXzPdhSA"
     self.assertEqual(_create_youtube_string(descriptor), expected)
Example #9
0
 def test_create_youtube_string_missing(self):
     """
     Test that Youtube IDs which aren't explicitly set aren't included
     in the output string.
     """
     system = DummySystem(load_error_modules=True)
     location = Location(["i4x", "edX", "video", "default", "SampleProblem1"])
     field_data = DictFieldData({'location': location})
     descriptor = VideoDescriptor(system, field_data, Mock())
     descriptor.youtube_id_0_75 = 'izygArpw-Qo'
     descriptor.youtube_id_1_0 = 'p2Q6BrNhdh8'
     descriptor.youtube_id_1_25 = '1EeWXzPdhSA'
     expected = "0.75:izygArpw-Qo,1.00:p2Q6BrNhdh8,1.25:1EeWXzPdhSA"
     self.assertEqual(_create_youtube_string(descriptor), expected)
Example #10
0
 def test_create_youtube_string(self):
     """
     Test that Youtube ID strings are correctly created when writing
     back out to XML.
     """
     system = DummySystem(load_error_modules=True)
     location = Location(["i4x", "edX", "video", "default", "SampleProblem1"])
     model_data = {'location': location}
     descriptor = VideoDescriptor(system, model_data)
     descriptor.youtube_id_0_75 = 'izygArpw-Qo'
     descriptor.youtube_id_1_0 = 'p2Q6BrNhdh8'
     descriptor.youtube_id_1_25 = '1EeWXzPdhSA'
     descriptor.youtube_id_1_5 = 'rABDYkeK0x8'
     expected = "0.75:izygArpw-Qo,1.00:p2Q6BrNhdh8,1.25:1EeWXzPdhSA,1.50:rABDYkeK0x8"
     self.assertEqual(_create_youtube_string(descriptor), expected)
Example #11
0
 def test_create_youtube_string(self):
     """
     Test that Youtube ID strings are correctly created when writing
     back out to XML.
     """
     system = DummySystem(load_error_modules=True)
     location = Location(["i4x", "edX", "video", "default", "SampleProblem1"])
     field_data = DictFieldData({'location': location})
     descriptor = VideoDescriptor(system, field_data, Mock())
     descriptor.youtube_id_0_75 = 'izygArpw-Qo'
     descriptor.youtube_id_1_0 = 'p2Q6BrNhdh8'
     descriptor.youtube_id_1_25 = '1EeWXzPdhSA'
     descriptor.youtube_id_1_5 = 'rABDYkeK0x8'
     expected = "0.75:izygArpw-Qo,1.00:p2Q6BrNhdh8,1.25:1EeWXzPdhSA,1.50:rABDYkeK0x8"
     self.assertEqual(_create_youtube_string(descriptor), expected)
Example #12
0
    def test_video_constructor(self):
        """Make sure that all parameters extracted correclty from xml"""

        context = self.item_module.get_html()

        sources = {"main": u"example.mp4", u"mp4": u"example.mp4", u"webm": u"example.webm", u"ogv": u"example.ogv"}

        expected_context = {
            "data_dir": getattr(self, "data_dir", None),
            "caption_asset_path": "/c4x/MITx/999/asset/subs_",
            "show_captions": "true",
            "display_name": "A Name",
            "end": 3610.0,
            "id": self.item_module.location.html_id(),
            "sources": sources,
            "start": 3603.0,
            "sub": u"a_sub_file.srt.sjson",
            "track": "",
            "youtube_streams": _create_youtube_string(self.item_module),
            "autoplay": settings.MITX_FEATURES.get("AUTOPLAY_VIDEOS", True),
        }

        self.maxDiff = None
        self.assertEqual(context, expected_context)