def test_two_pick_1(self): """ The MKV used in this test has two audio streams: Stream #0:1(eng): Audio: dts, 48000 Hz, 8 channels (default) Metadata: title : DTS-HD MA 7.1 DURATION : 00:00:00.000000000 Stream #0:2(eng): Audio: dts, 48000 Hz, 6 channels (default) Metadata: title : DTS-HD MA 5.1 DURATION : 00:00:00.000000000 Expected behavior: - Multiple audio streams will be identified - User will be prompted for selection - User enters "1" Expected values: - stream_count -> 2 - copy_count -> 1 - copy_indices -> [1] - copy_streams[0]['tags']['title'] == 'DTS-HD MA 7.1' """ mkv = MKV(test_paths['audio']['two'], 0) mkv._analyze() assert mkv.audio.stream_count == 2 assert mkv.audio.copy_count == 0 assert mkv.audio.copy_indices == [] assert mkv.intervene['needed']
def test_stage_set_loc(self): """ Does the stage setter properly set location's stage? """ mkv = MKV(test_paths['default'], stages.STAGE_0) mkv.state.clean_name = 'Default Test' assert mkv.state.stage == 0 mkv.stage = stages.STAGE_1 assert mkv.state.stage == 1
def get_mkv(request): """ Some sort of black magic fixture to provide an object to the entire test class """ mkv_path = 'tests/processing/1_remux/Stage 1 Test Good.mkv' mkv = MKV(mkv_path, stages.STAGE_0) if request.cls is not None: request.cls.mkv = mkv # Set the sanitized name, since that will be used mkv.state.clean_name = 'Stage 1 Test Good' mkv.stage = stages.STAGE_1 yield mkv
def test_fake(self): """ The MKV used in this test has three video streams: Stream 0:0 is the 'real' video stream Streams 0:3 and 0:4 are images. Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Metadata: title : Real Video Stream DURATION : 00:00:00.250000000 Stream #0:1(eng): Audio: dts, 48000 Hz, 8 channels (default) Metadata: title : DTS-HD.MA.7.1 DURATION : 00:00:00.000000000 Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle Metadata: title : English-PGS DURATION : 00:00:00.000000000 Stream #0:3: Video: mjpeg, none(pc, bt470bg/unknown/unknown), 600x882, 1k fps, 1k tbr, 1k tbn, 1k tbc Metadata: title : Fake Video Stream 0 FILENAME : cover.jpg MIMETYPE : image/jpeg DURATION : 00:00:00.000000000 Stream #0:4: Video: mjpeg, none(pc, bt470bg/unknown/unknown), 1067x600, 1k fps, 1k tbr, 1k tbn, 1k tbc Metadata: title : Fake Video Stream 1 FILENAME : cover_land.jpg MIMETYPE : image/jpeg DURATION : 00:00:00.000000000 Expected behavior: - Video streams will be identified - Video stream 0:0 will be selected for copying - Video streams 0:3, 0:4 will be filtered out because they are images Expected values: - stream_count -> 3 - copy_count -> 1 - copy_indices -> [0] - copy_streams[0]['tags']['title'] == 'Real Video Stream' """ mkv = MKV(test_paths['video']['mult_fake'], 0) mkv._analyze() assert mkv.video.stream_count == 3 assert mkv.video.copy_count == 1 assert mkv.video.copy_indices == [0] assert mkv.video.copy_streams[0]['tags'][ 'title'] == 'Real Video Stream'
def get_mkv(request): """ Some sort of black magic fixture to provide an object to the entire test class """ mkv_path = 'tests/processing/2_mix/Stage 2 Test Good.mkv' mkv = MKV(mkv_path, stages.STAGE_0) if request.cls is not None: request.cls.mkv = mkv # Note: during normal pipeline execution these values would have been # set in previous stages. mkv.state.clean_name = 'Stage 2 Test Good' mkv.state.assoc_files['stereo_mix'] = pathlib.Path( 'tests/processing/2_mix/Stage 2 Test Good.m4a') mkv.stage = stages.STAGE_2 yield mkv
def get_mkv(request): """ Some sort of black magic fixture to provide an object to the entire test class """ mkv_path = 'tests/processing/0_analyze/Stage 0 Test Good.mkv' mkv = MKV(mkv_path, stages.STAGE_0) if request.cls is not None: request.cls.mkv = mkv yield mkv
def test_blank_global_title(self, monkeypatch): def ask_for_title(the_mkv): title = input('What is the title of this movie: ') the_mkv.media_title = title def mock_title(_): return 'Blank Global Title' monkeypatch.setattr('builtins.input', mock_title) # Set up test shutil.copy(test_paths['errors']['blank_global_title'], 'tests/processing/0_analyze') mkv_path = 'tests/processing/0_analyze/Blank Global Title.mkv' mkv = MKV(mkv_path, stages.STAGE_0) # Should fail here mkv.pre_process() assert mkv.intervene['needed'] assert mkv.intervene['reason']['no_title'] assert mkv.intervene['reason']['audio_stream'] is False assert mkv.intervene['reason']['video_stream'] is False assert mkv.intervene['reason']['subtitle_stream'] is False mkv.intervention('no_title', ask_for_title) assert mkv.media_title == 'Blank Global Title'
def test_one(self): """ The MKV used in this test has a single video stream: Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Metadata: title : Default Test Video Stream BPS : 25832121 BPS-eng : 25832121 DURATION-eng : 01:55:49.860000000 NUMBER_OF_FRAMES: 166630 NUMBER_OF_FRAMES-eng: 166630 NUMBER_OF_BYTES : 22441203434 NUMBER_OF_BYTES-eng: 22441203434 _STATISTICS_WRITING_APP: mkvmerge v8.0.0 ('Til The Day That I Die') 64bit _STATISTICS_WRITING_APP-eng: mkvmerge v8.0.0 ('Til The Day That I Die') 64bit _STATISTICS_WRITING_DATE_UTC: 2015-09-25 12:17:01 _STATISTICS_WRITING_DATE_UTC-eng: 2015-09-25 12:17:01 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES DURATION : 00:00:01.626000000 Expected behavior: - Video stream will be identified - Video stream will be selected for copying Expected values: - stream_count -> 1 - copy_count -> 1 - copy_indices -> [0] - copy_streams[0]['tags']['title'] == 'Default Test Video Stream' """ mkv = MKV(test_paths['default'], 0) mkv._analyze() assert mkv.video.stream_count == 1 assert mkv.video.copy_count == 1 assert mkv.video.copy_indices == [0] assert mkv.video.copy_streams[0]['tags'][ 'title'] == 'Default Test Video Stream'
def test_real(self): """ The MKV used in this test has two video streams: Stream #0:0(eng): Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Metadata: title : Real Video Stream 0 DURATION : 00:00:00.250000000 Stream #0:1(eng): Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Metadata: title : Real Video Stream 1 DURATION : 00:00:00.250000000 Expected behavior: - Video streams will be identified - RunTimeError - I haven't seen this happen enough times to know how I want to handle it """ mkv = MKV(test_paths['video']['mult_real'], 0) with pytest.raises(RuntimeError) as exc: mkv._analyze() assert str(exc.value) == 'Multiple video streams detected'
def test_one(self): """ The MKV used in this test has a single audio stream: Stream #0:1(eng): Audio: dts (DTS-HD MA), 48000 Hz, 5.1(side), s32p (24 bit) (default) Metadata: title : DTS-HD MA 5.1 BPS : 3411810 BPS-eng : 3411810 DURATION-eng : 01:55:49.910000000 NUMBER_OF_FRAMES: 651554 NUMBER_OF_FRAMES-eng: 651554 NUMBER_OF_BYTES : 2963972172 NUMBER_OF_BYTES-eng: 2963972172 _STATISTICS_WRITING_APP: mkvmerge v8.0.0 ('Til The Day That I Die') 64bit _STATISTICS_WRITING_APP-eng: mkvmerge v8.0.0 ('Til The Day That I Die') 64bit _STATISTICS_WRITING_DATE_UTC: 2015-09-25 12:17:01 _STATISTICS_WRITING_DATE_UTC-eng: 2015-09-25 12:17:01 _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES DURATION : 00:00:01.428000000 Expected behavior: - Audio stream will be identified - Audio stream will be selected for copying Expected values: - stream_count -> 1 - copy_count -> 1 - copy_indices -> [1] - copy_streams[0]['tags']['title'] == 'DTS-HD MA 5.1' """ mkv = MKV(test_paths['default'], 0) mkv._analyze() assert mkv.audio.stream_count == 1 assert mkv.audio.copy_count == 1 assert mkv.audio.copy_indices == [1] assert mkv.audio.copy_streams[0]['tags']['title'] == 'DTS-HD MA 5.1'
def test_known_good(self): """ The MKV used in this test case has a single Video, Audio, and Subtitle stream: Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Metadata: title : Default Test Video Stream BPS : 25832121 Stream #0:1(eng): Audio: dts (DTS-HD MA), 48000 Hz, 5.1(side), s32p (24 bit) (default) Metadata: title : DTS-HD MA 5.1 BPS : 3411810 Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle, 1920x1080 Metadata: title : English Subtitles BPS : 19313 Expected behavior: - Video, Audio, and Subtitle streams will be identified Expected values: - .video -> instanceof MKVStream - .video.stream_count -> 1 - .audio -> instanceof MKVStream - .audio.stream_count -> 1 - .subs -> instanceof MKVStream - .subs.stream_count -> 1 """ mkv = MKV(test_paths['default'], stages.STAGE_0) mkv._analyze() assert isinstance(mkv.video, MKVStream) assert isinstance(mkv.audio, MKVStream) assert isinstance(mkv.subs, MKVStream) assert mkv.video.stream_count == 1 assert mkv.audio.stream_count == 1 assert mkv.subs.stream_count == 1
def get_mkvs(stage: int) -> List[MKV]: """ Given a specific processing stage, find all MKVs that need to be handle :param int stage: The desired processing stage :return list: A list of found MKVs """ search_paths = { 0: '0_analyze', 1: '1_remux', 2: '2_mix' } files = list_by_extension(search_paths[stage], '.mkv') return [MKV(_, stage) for _ in files]
def test_colon_in_title(self): """ Do we appropriately sanitize colons from file names? """ mkv = MKV(test_paths['default'], stages.STAGE_0) mkv.media_title = 'Title 2: Revenge of the Colon' assert mkv.media_title == 'Title 2: Revenge of the Colon' assert mkv.state.clean_name == 'Title 2 Revenge of the Colon'
def test_invalid_input(self): """ Do we handle invalid input? """ with pytest.raises(TypeError) as exc: MKV(69, stages.STAGE_0) assert "not int" in str(exc.value)
def mkv1(self): return MKV('tests/processing/1_remux/Stage 1 Test Good.mkv', stages.STAGE_0)
def mkv0(self): return MKV('tests/processing/0_analyze/Stage 0 Test Good.mkv', stages.STAGE_0)
def test_not_exists(self): """Do we raise an exception when given a path to a file that doesn't exist?""" with pytest.raises(FileNotFoundError) as exc: MKV('foo.bar', stages.STAGE_0) assert str(exc.value) == 'Specified MKV does not exist'
def test_load(self): """Can we load a generic mkv?""" m = MKV(test_paths['default'], stages.STAGE_0) assert isinstance(m, MKV)
def test_set_title(self): """ Does the set_title function work for a known good value? """ mkv = MKV(test_paths['default'], stages.STAGE_0) mkv._analyze() assert mkv.media_title == 'Default Test' assert mkv.state.clean_name == 'Default Test'
def test_stage_get(self): """ Does the stage getter return the correct value? """ mkv = MKV(test_paths['default'], stages.STAGE_0) assert mkv.stage == 0
def test_stage_set(self): """ Does the stage setter work? """ mkv = MKV(test_paths['default'], stages.STAGE_0) mkv.state.clean_name = 'Default Test' mkv.stage = stages.STAGE_1 assert mkv.stage == 1