def test_videoalpha_get_html(self):
        """Make sure that all parameters extracted correclty from xml"""
        module = VideoAlphaFactory.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_videoalpha_constructor(self):
        """Make sure that all parameters extracted correclty from xml"""

        context = self.item_module.get_html()

        sources = {
            'main': 'example.mp4',
            'mp4': 'example.mp4',
            'webm': 'example.webm',
            'ogv': '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': 'a_sub_file.srt.sjson',
            'track': '',
            'youtube_streams': _create_youtube_string(self.item_module),
            'autoplay': settings.MITX_FEATURES.get('AUTOPLAY_VIDEOS', True)
        }

        self.assertEqual(context, expected_context)
Esempio n. 3
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", "videoalpha", "default", "SampleProblem1"])
     model_data = {'location': location}
     descriptor = VideoAlphaDescriptor(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)
Esempio n. 4
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", "videoalpha", "default", "SampleProblem1"])
     model_data = {'location': location}
     descriptor = VideoAlphaDescriptor(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)