def test_output_happy_path(mocked_dir_check, mocked_file_check, mocked_user_input): ''' Test get_output_video_name happy path ''' mocked_user_input.return_value = _EXPECTED_VIDEO_NAME mocked_file_check.return_value = False mocked_dir_check.return_value = True output_video_name = cli_helpers.get_output_video_name() assert output_video_name == _EXPECTED_VIDEO_NAME
def test_output_empty(mocked_dir_check, mocked_file_check, mocked_user_input): ''' Verify that get_output_video_name does not fail if empty answer is passed ''' mocked_user_input.side_effect = [None, _EXPECTED_VIDEO_NAME] mocked_dir_check.return_value = True mocked_file_check.return_value = False user_input = cli_helpers.get_output_video_name() assert user_input == _EXPECTED_VIDEO_NAME assert mocked_user_input.call_count == 2
def test_output_already_exists(mocked_file_check, mocked_user_input, mocked_confirm): ''' Verify that get_output_video_name does not fail if an output video already exists ''' mocked_user_input.side_effect = [_EXPECTED_VIDEO_NAME, _EXPECTED_VIDEO_NAME] mocked_file_check.path.dirname.side_effct = [None, None] mocked_file_check.side_effect = [True, True] mocked_confirm.side_effect = [False, True] user_input = cli_helpers.get_output_video_name() assert user_input == _EXPECTED_VIDEO_NAME assert mocked_user_input.call_count == 2 assert mocked_confirm.call_count == 2
def test_output_directory_not_exist(mocked_dir_check, mocked_file_check, mocked_user_input, mocked_warning): ''' Verify that get_output_video_name does not fail if a name of output video containe a non-existent directory ''' output_path = 'somepath/' + _EXPECTED_VIDEO_NAME mocked_user_input.side_effect = ['nonexistent_dir/video.mp4', output_path] mocked_dir_check.side_effect = [False, True] mocked_file_check.side_effect = [False, False] user_input = cli_helpers.get_output_video_name() assert user_input == output_path assert mocked_user_input.call_count == 2 assert mocked_warning.call_count == 1