def test_screenshots_process_is_cancelled_after_normalizing_timestamps( tmp_path, screenshots_process_patches): screenshots_process_patches.first_video.return_value = 'path/to/foo/bar.mkv' screenshots_process_patches.normalize_timestamps.return_value = ('0:10:00', '0:20:00') screenshots_process_patches.shall_terminate.side_effect = (False, True) _screenshots_process( output_queue=screenshots_process_patches.output_queue, input_queue=screenshots_process_patches.input_queue, content_path='path/to/foo', timestamps=(10 * 60, '20:00'), count=2, output_dir='path/to/destination', overwrite=False, ) assert screenshots_process_patches.mock_calls == [ call.first_video('path/to/foo'), call.shall_terminate(screenshots_process_patches.input_queue), call.output_queue.put( (MsgType.info, ('video_file', 'path/to/foo/bar.mkv'))), call.normalize_timestamps( video_file='path/to/foo/bar.mkv', timestamps=(10 * 60, '20:00'), count=2, ), call.output_queue.put( (MsgType.info, ('timestamps', ('0:10:00', '0:20:00')))), call.shall_terminate(screenshots_process_patches.input_queue), ]
def test_screenshots_process_fails_to_normalize_timestamps( tmp_path, screenshots_process_patches): screenshots_process_patches.first_video.return_value = 'path/to/foo/bar.mkv' screenshots_process_patches.normalize_timestamps.side_effect = ValueError( 'Invalid timestamp') _screenshots_process( output_queue=screenshots_process_patches.output_queue, input_queue=screenshots_process_patches.input_queue, content_path='path/to/foo', timestamps=(10 * 60, '20:00'), count=2, output_dir='path/to/destination', overwrite=False, ) assert screenshots_process_patches.mock_calls == [ call.first_video('path/to/foo'), call.shall_terminate(screenshots_process_patches.input_queue), call.output_queue.put( (MsgType.info, ('video_file', 'path/to/foo/bar.mkv'))), call.normalize_timestamps( video_file='path/to/foo/bar.mkv', timestamps=(10 * 60, '20:00'), count=2, ), call.output_queue.put((MsgType.error, 'Invalid timestamp')), ]
def test_screenshots_process_fails_to_create_second_screenshot( tmp_path, screenshots_process_patches): screenshots_process_patches.first_video.return_value = 'path/to/foo/bar.mkv' screenshots_process_patches.normalize_timestamps.return_value = ('0:10:00', '0:20:00') screenshots_process_patches.screenshot.side_effect = ( 'path/to/destination/bar.mkv.0:10:00.png', errors.ScreenshotError('No space left'), ) _screenshots_process( output_queue=screenshots_process_patches.output_queue, input_queue=screenshots_process_patches.input_queue, content_path='path/to/foo', timestamps=(10 * 60, '20:00'), count=2, output_dir='path/to/destination', overwrite=False, ) assert screenshots_process_patches.mock_calls == [ call.first_video('path/to/foo'), call.shall_terminate(screenshots_process_patches.input_queue), call.output_queue.put( (MsgType.info, ('video_file', 'path/to/foo/bar.mkv'))), call.normalize_timestamps( video_file='path/to/foo/bar.mkv', timestamps=(10 * 60, '20:00'), count=2, ), call.output_queue.put( (MsgType.info, ('timestamps', ('0:10:00', '0:20:00')))), call.shall_terminate(screenshots_process_patches.input_queue), call.screenshot( video_file='path/to/foo/bar.mkv', screenshot_file='path/to/destination/bar.mkv.0:10:00.png', timestamp='0:10:00', overwrite=False, ), call.output_queue.put( (MsgType.info, ('screenshot', 'path/to/destination/bar.mkv.0:10:00.png'))), call.shall_terminate(screenshots_process_patches.input_queue), call.screenshot( video_file='path/to/foo/bar.mkv', screenshot_file='path/to/destination/bar.mkv.0:20:00.png', timestamp='0:20:00', overwrite=False, ), call.output_queue.put((MsgType.error, 'No space left')), ]
def test_screenshots_process_is_cancelled_after_finding_first_video( tmp_path, screenshots_process_patches): screenshots_process_patches.first_video.return_value = 'path/to/foo/bar.mkv' screenshots_process_patches.shall_terminate.return_value = True _screenshots_process( output_queue=screenshots_process_patches.output_queue, input_queue=screenshots_process_patches.input_queue, content_path='path/to/foo', timestamps=(10 * 60, '20:00'), count=2, output_dir='path/to/destination', overwrite=False, ) assert screenshots_process_patches.mock_calls == [ call.first_video('path/to/foo'), call.shall_terminate(screenshots_process_patches.input_queue), ]
def test_screenshots_process_fails_to_find_first_video( tmp_path, screenshots_process_patches): screenshots_process_patches.first_video.side_effect = errors.ContentError( 'No video found') _screenshots_process( output_queue=screenshots_process_patches.output_queue, input_queue=screenshots_process_patches.input_queue, content_path='path/to/foo', timestamps=(10 * 60, '20:00'), count=2, output_dir='path/to/destination', overwrite=False, ) assert screenshots_process_patches.mock_calls == [ call.first_video('path/to/foo'), call.output_queue.put((MsgType.error, 'No video found')), ]