def test_old_video_format(self): """ Test backwards compatibility with VideoModule's XML format. """ module_system = DummySystem(load_error_modules=True) xml_data = """ <videoalpha display_name="Test Video" youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8" show_captions="false" from="00:00:01" to="00:01:00"> <source src="http://www.example.com/source.mp4"/> <track src="http://www.example.com/track"/> </videoalpha> """ output = VideoAlphaDescriptor.from_xml(xml_data, module_system) self.assert_attributes_equal(output, { 'youtube_id_0_75': 'izygArpw-Qo', 'youtube_id_1_0': 'p2Q6BrNhdh8', 'youtube_id_1_25': '1EeWXzPdhSA', 'youtube_id_1_5': 'rABDYkeK0x8', 'show_captions': False, 'start_time': 1.0, 'end_time': 60, 'track': 'http://www.example.com/track', 'html5_sources': ['http://www.example.com/source.mp4'], 'data': '' })
def test_from_xml_missing_attributes(self): """ Ensure that attributes have the right values if they aren't explicitly set in XML. """ module_system = DummySystem(load_error_modules=True) xml_data = ''' <videoalpha display_name="Test Video" youtube="1.0:p2Q6BrNhdh8,1.25:1EeWXzPdhSA" show_captions="true"> <source src="http://www.example.com/source.mp4"/> <track src="http://www.example.com/track"/> </videoalpha> ''' output = VideoAlphaDescriptor.from_xml(xml_data, module_system) self.assert_attributes_equal(output, { 'youtube_id_0_75': '', 'youtube_id_1_0': 'p2Q6BrNhdh8', 'youtube_id_1_25': '1EeWXzPdhSA', 'youtube_id_1_5': '', 'show_captions': True, 'start_time': 0.0, 'end_time': 0.0, 'track': 'http://www.example.com/track', 'source': 'http://www.example.com/source.mp4', 'html5_sources': ['http://www.example.com/source.mp4'], 'data': '' })
def test_from_xml_no_attributes(self): """ Make sure settings are correct if none are explicitly set in XML. """ module_system = DummySystem(load_error_modules=True) xml_data = '<videoalpha></videoalpha>' output = VideoAlphaDescriptor.from_xml(xml_data, module_system) self.assert_attributes_equal(output, { 'youtube_id_0_75': '', 'youtube_id_1_0': 'OEoXaMPEzfM', 'youtube_id_1_25': '', 'youtube_id_1_5': '', 'show_captions': True, 'start_time': 0.0, 'end_time': 0.0, 'track': '', 'source': '', 'html5_sources': [], 'data': '' })