def test_multiple_subs_can_be_added(video_file): """ Baseline check to make sure we're not dropping subtitle files on validate. """ local_path = os.path.join("tests", "testcontent", "samples", "testsubtitles_ar.srt") assert os.path.exists(local_path) video_node = VideoNode('vid-src-id', "Video", licenses.PUBLIC_DOMAIN) video_node.add_file(video_file) sub1 = SubtitleFile(local_path, language='en') video_node.add_file(sub1) sub2 = SubtitleFile(local_path, language='ar') video_node.add_file(sub2) video_node.validate() sub_files = [f for f in video_node.files if isinstance(f, SubtitleFile)] assert len(sub_files) == 2, 'Missing subtitles files!'
def test_duplicate_language_codes_fixed_by_validate(video_file): """ Video nodes should have at most one subtitle file for a particular lang code. """ local_path = os.path.join("tests", "testcontent", "samples", "testsubtitles_ar.srt") assert os.path.exists(local_path) video_node = VideoNode('vid-src-id', "Video", licenses.PUBLIC_DOMAIN) video_node.add_file(video_file) sub1 = SubtitleFile(local_path, language='ar') video_node.add_file(sub1) # now let's add file with a duplicate language code... sub2 = SubtitleFile(local_path, language='ar') video_node.add_file(sub2) video_node.validate() sub_files = [f for f in video_node.files if isinstance(f, SubtitleFile)] assert len(sub_files) == 1, 'Duplicate subtitles files not removed!'