From 1af95714c2569086c415b901d544907d42bf8349 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 12 Jun 2019 12:11:36 -0700 Subject: [PATCH] Collapse two execute_command() parameters into one output log level parameter. --- borgmatic/borg/create.py | 9 +++- borgmatic/borg/execute.py | 17 ++++--- borgmatic/borg/info.py | 2 +- borgmatic/borg/list.py | 2 +- tests/unit/borg/test_create.py | 82 +++++++++++++-------------------- tests/unit/borg/test_execute.py | 6 ++- tests/unit/borg/test_info.py | 16 ++++--- tests/unit/borg/test_list.py | 18 ++++---- 8 files changed, 73 insertions(+), 79 deletions(-) diff --git a/borgmatic/borg/create.py b/borgmatic/borg/create.py index 80665ca0b..0e816ee10 100644 --- a/borgmatic/borg/create.py +++ b/borgmatic/borg/create.py @@ -162,4 +162,11 @@ def create_archive( + (('--json',) if json else ()) ) - return execute_command(full_command, capture_output=json, output_as_warning=stats and not json) + if json: + output_log_level = None + elif stats: + output_log_level = logging.WARNING + else: + output_log_level = logging.INFO + + return execute_command(full_command, output_log_level) diff --git a/borgmatic/borg/execute.py b/borgmatic/borg/execute.py index fb9319eae..3ca9f6007 100644 --- a/borgmatic/borg/execute.py +++ b/borgmatic/borg/execute.py @@ -1,3 +1,4 @@ +import logging import subprocess from borgmatic.logger import get_logger @@ -5,17 +6,15 @@ from borgmatic.logger import get_logger logger = get_logger(__name__) -def execute_and_log_output(full_command, output_as_warning=False): +def execute_and_log_output(full_command, output_log_level): process = subprocess.Popen(full_command, stdout=None, stderr=subprocess.PIPE) while process.poll() is None: line = process.stderr.readline().rstrip().decode() if line.startswith('borg: error:'): logger.error(line) - elif output_as_warning: - logger.warning(line) else: - logger.info(line) + logger.log(output_log_level, line) remaining_output = process.stderr.read().rstrip().decode() if remaining_output: @@ -26,15 +25,15 @@ def execute_and_log_output(full_command, output_as_warning=False): raise subprocess.CalledProcessError(exit_code, full_command) -def execute_command(full_command, capture_output=False, output_as_warning=False): +def execute_command(full_command, output_log_level=logging.INFO): ''' - Execute the given command (a sequence of command/argument strings). If capture output is True, - then return the command's output as a string. + Execute the given command (a sequence of command/argument strings) and log its output at the + given log level. If output log level is None, instead capture and return the output. ''' logger.debug(' '.join(full_command)) - if capture_output: + if output_log_level is None: output = subprocess.check_output(full_command) return output.decode() if output is not None else None else: - execute_and_log_output(full_command, output_as_warning) + execute_and_log_output(full_command, output_log_level) diff --git a/borgmatic/borg/info.py b/borgmatic/borg/info.py index 87193911d..3e526503e 100644 --- a/borgmatic/borg/info.py +++ b/borgmatic/borg/info.py @@ -24,4 +24,4 @@ def display_archives_info( + (('--json',) if json else ()) ) - return execute_command(full_command, capture_output=json) + return execute_command(full_command, output_log_level=None if json else logging.INFO) diff --git a/borgmatic/borg/list.py b/borgmatic/borg/list.py index 4f35f1c04..4b28fd9cc 100644 --- a/borgmatic/borg/list.py +++ b/borgmatic/borg/list.py @@ -25,4 +25,4 @@ def list_archives( + (('--json',) if json else ()) ) - return execute_command(full_command, capture_output=json) + return execute_command(full_command, output_log_level=None if json else logging.INFO) diff --git a/tests/unit/borg/test_create.py b/tests/unit/borg/test_create.py index bb13d75e3..8aed05dbe 100644 --- a/tests/unit/borg/test_create.py +++ b/tests/unit/borg/test_create.py @@ -166,7 +166,7 @@ def test_create_archive_calls_borg_with_parameters(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND, capture_output=False, output_as_warning=False + CREATE_COMMAND, output_log_level=logging.INFO ) module.create_archive( @@ -191,7 +191,7 @@ def test_create_archive_with_patterns_calls_borg_with_patterns(): flexmock(module).should_receive('_make_pattern_flags').and_return(pattern_flags) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + pattern_flags, capture_output=False, output_as_warning=False + CREATE_COMMAND + pattern_flags, output_log_level=logging.INFO ) module.create_archive( @@ -216,7 +216,7 @@ def test_create_archive_with_exclude_patterns_calls_borg_with_excludes(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(exclude_flags) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + exclude_flags, capture_output=False, output_as_warning=False + CREATE_COMMAND + exclude_flags, output_log_level=logging.INFO ) module.create_archive( @@ -240,8 +240,7 @@ def test_create_archive_with_log_info_calls_borg_with_info_parameter(): flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( CREATE_COMMAND + ('--list', '--filter', 'AME-', '--info', '--stats'), - capture_output=False, - output_as_warning=False, + output_log_level=logging.INFO, ) insert_logging_mock(logging.INFO) @@ -265,7 +264,7 @@ def test_create_archive_with_log_info_and_json_suppresses_most_borg_output(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--json',), capture_output=True, output_as_warning=False + CREATE_COMMAND + ('--json',), output_log_level=None ) insert_logging_mock(logging.INFO) @@ -290,8 +289,7 @@ def test_create_archive_with_log_debug_calls_borg_with_debug_parameter(): flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( CREATE_COMMAND + ('--list', '--filter', 'AME-', '--stats', '--debug', '--show-rc'), - capture_output=False, - output_as_warning=False, + output_log_level=logging.INFO, ) insert_logging_mock(logging.DEBUG) @@ -314,7 +312,7 @@ def test_create_archive_with_log_debug_and_json_suppresses_most_borg_output(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--json',), capture_output=True, output_as_warning=False + CREATE_COMMAND + ('--json',), output_log_level=None ) insert_logging_mock(logging.DEBUG) @@ -339,7 +337,7 @@ def test_create_archive_with_dry_run_calls_borg_with_dry_run_parameter(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--dry-run',), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--dry-run',), output_log_level=logging.INFO ) module.create_archive( @@ -365,8 +363,7 @@ def test_create_archive_with_dry_run_and_log_info_calls_borg_without_stats_param flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( CREATE_COMMAND + ('--list', '--filter', 'AME-', '--info', '--dry-run'), - capture_output=False, - output_as_warning=False, + output_log_level=logging.INFO, ) insert_logging_mock(logging.INFO) @@ -393,8 +390,7 @@ def test_create_archive_with_dry_run_and_log_debug_calls_borg_without_stats_para flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( CREATE_COMMAND + ('--list', '--filter', 'AME-', '--debug', '--show-rc', '--dry-run'), - capture_output=False, - output_as_warning=False, + output_log_level=logging.INFO, ) insert_logging_mock(logging.DEBUG) @@ -417,9 +413,7 @@ def test_create_archive_with_checkpoint_interval_calls_borg_with_checkpoint_inte flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--checkpoint-interval', '600'), - capture_output=False, - output_as_warning=False, + CREATE_COMMAND + ('--checkpoint-interval', '600'), output_log_level=logging.INFO ) module.create_archive( @@ -441,9 +435,7 @@ def test_create_archive_with_chunker_params_calls_borg_with_chunker_params_param flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--chunker-params', '1,2,3,4'), - capture_output=False, - output_as_warning=False, + CREATE_COMMAND + ('--chunker-params', '1,2,3,4'), output_log_level=logging.INFO ) module.create_archive( @@ -465,7 +457,7 @@ def test_create_archive_with_compression_calls_borg_with_compression_parameters( flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--compression', 'rle'), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--compression', 'rle'), output_log_level=logging.INFO ) module.create_archive( @@ -487,9 +479,7 @@ def test_create_archive_with_remote_rate_limit_calls_borg_with_remote_ratelimit_ flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--remote-ratelimit', '100'), - capture_output=False, - output_as_warning=False, + CREATE_COMMAND + ('--remote-ratelimit', '100'), output_log_level=logging.INFO ) module.create_archive( @@ -511,7 +501,7 @@ def test_create_archive_with_one_file_system_calls_borg_with_one_file_system_par flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--one-file-system',), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--one-file-system',), output_log_level=logging.INFO ) module.create_archive( @@ -534,7 +524,7 @@ def test_create_archive_with_numeric_owner_calls_borg_with_numeric_owner_paramet flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--numeric-owner',), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--numeric-owner',), output_log_level=logging.INFO ) module.create_archive( @@ -557,7 +547,7 @@ def test_create_archive_with_read_special_calls_borg_with_read_special_parameter flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--read-special',), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--read-special',), output_log_level=logging.INFO ) module.create_archive( @@ -580,7 +570,7 @@ def test_create_archive_with_bsd_flags_true_calls_borg_without_nobsdflags_parame flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND, capture_output=False, output_as_warning=False + CREATE_COMMAND, output_log_level=logging.INFO ) module.create_archive( @@ -603,7 +593,7 @@ def test_create_archive_with_bsd_flags_false_calls_borg_with_nobsdflags_paramete flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--nobsdflags',), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--nobsdflags',), output_log_level=logging.INFO ) module.create_archive( @@ -626,9 +616,7 @@ def test_create_archive_with_files_cache_calls_borg_with_files_cache_parameters( flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--files-cache', 'ctime,size'), - capture_output=False, - output_as_warning=False, + CREATE_COMMAND + ('--files-cache', 'ctime,size'), output_log_level=logging.INFO ) module.create_archive( @@ -651,7 +639,7 @@ def test_create_archive_with_local_path_calls_borg_via_local_path(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - ('borg1',) + CREATE_COMMAND[1:], capture_output=False, output_as_warning=False + ('borg1',) + CREATE_COMMAND[1:], output_log_level=logging.INFO ) module.create_archive( @@ -674,7 +662,7 @@ def test_create_archive_with_remote_path_calls_borg_with_remote_path_parameters( flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--remote-path', 'borg1'), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--remote-path', 'borg1'), output_log_level=logging.INFO ) module.create_archive( @@ -697,7 +685,7 @@ def test_create_archive_with_umask_calls_borg_with_umask_parameters(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--umask', '740'), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--umask', '740'), output_log_level=logging.INFO ) module.create_archive( @@ -719,7 +707,7 @@ def test_create_archive_with_lock_wait_calls_borg_with_lock_wait_parameters(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--lock-wait', '5'), capture_output=False, output_as_warning=False + CREATE_COMMAND + ('--lock-wait', '5'), output_log_level=logging.INFO ) module.create_archive( @@ -741,7 +729,7 @@ def test_create_archive_with_stats_calls_borg_with_stats_parameter(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--stats',), capture_output=False, output_as_warning=True + CREATE_COMMAND + ('--stats',), output_log_level=logging.WARNING ) module.create_archive( @@ -764,7 +752,7 @@ def test_create_archive_with_json_calls_borg_with_json_parameter(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--json',), capture_output=True, output_as_warning=False + CREATE_COMMAND + ('--json',), output_log_level=None ).and_return('[]') json_output = module.create_archive( @@ -789,7 +777,7 @@ def test_create_archive_with_stats_and_json_calls_borg_without_stats_parameter() flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - CREATE_COMMAND + ('--json',), capture_output=True, output_as_warning=False + CREATE_COMMAND + ('--json',), output_log_level=None ).and_return('[]') json_output = module.create_archive( @@ -816,8 +804,7 @@ def test_create_archive_with_source_directories_glob_expands(): flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( ('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo', 'food'), - capture_output=False, - output_as_warning=False, + output_log_level=logging.INFO, ) flexmock(module.glob).should_receive('glob').with_args('foo*').and_return(['foo', 'food']) @@ -841,8 +828,7 @@ def test_create_archive_with_non_matching_source_directories_glob_passes_through flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( ('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo*'), - capture_output=False, - output_as_warning=False, + output_log_level=logging.INFO, ) flexmock(module.glob).should_receive('glob').with_args('foo*').and_return([]) @@ -866,8 +852,7 @@ def test_create_archive_with_glob_calls_borg_with_expanded_directories(): flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( ('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo', 'food'), - capture_output=False, - output_as_warning=False, + output_log_level=logging.INFO, ) module.create_archive( @@ -889,9 +874,7 @@ def test_create_archive_with_archive_name_format_calls_borg_with_archive_name(): flexmock(module).should_receive('_make_pattern_flags').and_return(()) flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( - ('borg', 'create', 'repo::ARCHIVE_NAME', 'foo', 'bar'), - capture_output=False, - output_as_warning=False, + ('borg', 'create', 'repo::ARCHIVE_NAME', 'foo', 'bar'), output_log_level=logging.INFO ) module.create_archive( @@ -914,8 +897,7 @@ def test_create_archive_with_archive_name_format_accepts_borg_placeholders(): flexmock(module).should_receive('_make_exclude_flags').and_return(()) flexmock(module).should_receive('execute_command').with_args( ('borg', 'create', 'repo::Documents_{hostname}-{now}', 'foo', 'bar'), - capture_output=False, - output_as_warning=False, + output_log_level=logging.INFO, ) module.create_archive( diff --git a/tests/unit/borg/test_execute.py b/tests/unit/borg/test_execute.py index de9ae6626..272e4020c 100644 --- a/tests/unit/borg/test_execute.py +++ b/tests/unit/borg/test_execute.py @@ -1,3 +1,5 @@ +import logging + from flexmock import flexmock from borgmatic.borg import execute as module @@ -6,7 +8,7 @@ from borgmatic.borg import execute as module def test_execute_command_calls_full_command(): full_command = ['foo', 'bar'] flexmock(module).should_receive('execute_and_log_output').with_args( - full_command, output_as_warning=False + full_command, output_log_level=logging.INFO ).once() output = module.execute_command(full_command) @@ -21,6 +23,6 @@ def test_execute_command_captures_output(): flexmock(decode=lambda: expected_output) ).once() - output = module.execute_command(full_command, capture_output=True) + output = module.execute_command(full_command, output_log_level=None) assert output == expected_output diff --git a/tests/unit/borg/test_info.py b/tests/unit/borg/test_info.py index bf11e9281..b600ff2f5 100644 --- a/tests/unit/borg/test_info.py +++ b/tests/unit/borg/test_info.py @@ -10,14 +10,16 @@ INFO_COMMAND = ('borg', 'info', 'repo') def test_display_archives_info_calls_borg_with_parameters(): - flexmock(module).should_receive('execute_command').with_args(INFO_COMMAND, capture_output=False) + flexmock(module).should_receive('execute_command').with_args( + INFO_COMMAND, output_log_level=logging.INFO + ) module.display_archives_info(repository='repo', storage_config={}) def test_display_archives_info_with_log_info_calls_borg_with_info_parameter(): flexmock(module).should_receive('execute_command').with_args( - INFO_COMMAND + ('--info',), capture_output=False + INFO_COMMAND + ('--info',), output_log_level=logging.INFO ) insert_logging_mock(logging.INFO) module.display_archives_info(repository='repo', storage_config={}) @@ -25,7 +27,7 @@ def test_display_archives_info_with_log_info_calls_borg_with_info_parameter(): def test_display_archives_info_with_log_debug_calls_borg_with_debug_parameter(): flexmock(module).should_receive('execute_command').with_args( - INFO_COMMAND + ('--debug', '--show-rc'), capture_output=False + INFO_COMMAND + ('--debug', '--show-rc'), output_log_level=logging.INFO ) insert_logging_mock(logging.DEBUG) @@ -34,7 +36,7 @@ def test_display_archives_info_with_log_debug_calls_borg_with_debug_parameter(): def test_display_archives_info_with_json_calls_borg_with_json_parameter(): flexmock(module).should_receive('execute_command').with_args( - INFO_COMMAND + ('--json',), capture_output=True + INFO_COMMAND + ('--json',), output_log_level=None ).and_return('[]') json_output = module.display_archives_info(repository='repo', storage_config={}, json=True) @@ -44,7 +46,7 @@ def test_display_archives_info_with_json_calls_borg_with_json_parameter(): def test_display_archives_info_with_local_path_calls_borg_via_local_path(): flexmock(module).should_receive('execute_command').with_args( - ('borg1',) + INFO_COMMAND[1:], capture_output=False + ('borg1',) + INFO_COMMAND[1:], output_log_level=logging.INFO ) module.display_archives_info(repository='repo', storage_config={}, local_path='borg1') @@ -52,7 +54,7 @@ def test_display_archives_info_with_local_path_calls_borg_via_local_path(): def test_display_archives_info_with_remote_path_calls_borg_with_remote_path_parameters(): flexmock(module).should_receive('execute_command').with_args( - INFO_COMMAND + ('--remote-path', 'borg1'), capture_output=False + INFO_COMMAND + ('--remote-path', 'borg1'), output_log_level=logging.INFO ) module.display_archives_info(repository='repo', storage_config={}, remote_path='borg1') @@ -61,7 +63,7 @@ def test_display_archives_info_with_remote_path_calls_borg_with_remote_path_para def test_display_archives_info_with_lock_wait_calls_borg_with_lock_wait_parameters(): storage_config = {'lock_wait': 5} flexmock(module).should_receive('execute_command').with_args( - INFO_COMMAND + ('--lock-wait', '5'), capture_output=False + INFO_COMMAND + ('--lock-wait', '5'), output_log_level=logging.INFO ) module.display_archives_info(repository='repo', storage_config=storage_config) diff --git a/tests/unit/borg/test_list.py b/tests/unit/borg/test_list.py index fedc92b90..2b12e3887 100644 --- a/tests/unit/borg/test_list.py +++ b/tests/unit/borg/test_list.py @@ -10,14 +10,16 @@ LIST_COMMAND = ('borg', 'list', 'repo') def test_list_archives_calls_borg_with_parameters(): - flexmock(module).should_receive('execute_command').with_args(LIST_COMMAND, capture_output=False) + flexmock(module).should_receive('execute_command').with_args( + LIST_COMMAND, output_log_level=logging.INFO + ) module.list_archives(repository='repo', storage_config={}) def test_list_archives_with_log_info_calls_borg_with_info_parameter(): flexmock(module).should_receive('execute_command').with_args( - LIST_COMMAND + ('--info',), capture_output=False + LIST_COMMAND + ('--info',), output_log_level=logging.INFO ) insert_logging_mock(logging.INFO) @@ -26,7 +28,7 @@ def test_list_archives_with_log_info_calls_borg_with_info_parameter(): def test_list_archives_with_log_debug_calls_borg_with_debug_parameter(): flexmock(module).should_receive('execute_command').with_args( - LIST_COMMAND + ('--debug', '--show-rc'), capture_output=False + LIST_COMMAND + ('--debug', '--show-rc'), output_log_level=logging.INFO ) insert_logging_mock(logging.DEBUG) @@ -36,7 +38,7 @@ def test_list_archives_with_log_debug_calls_borg_with_debug_parameter(): def test_list_archives_with_lock_wait_calls_borg_with_lock_wait_parameters(): storage_config = {'lock_wait': 5} flexmock(module).should_receive('execute_command').with_args( - LIST_COMMAND + ('--lock-wait', '5'), capture_output=False + LIST_COMMAND + ('--lock-wait', '5'), output_log_level=logging.INFO ) module.list_archives(repository='repo', storage_config=storage_config) @@ -45,7 +47,7 @@ def test_list_archives_with_lock_wait_calls_borg_with_lock_wait_parameters(): def test_list_archives_with_archive_calls_borg_with_archive_parameter(): storage_config = {} flexmock(module).should_receive('execute_command').with_args( - ('borg', 'list', 'repo::archive'), capture_output=False + ('borg', 'list', 'repo::archive'), output_log_level=logging.INFO ) module.list_archives(repository='repo', storage_config=storage_config, archive='archive') @@ -53,7 +55,7 @@ def test_list_archives_with_archive_calls_borg_with_archive_parameter(): def test_list_archives_with_local_path_calls_borg_via_local_path(): flexmock(module).should_receive('execute_command').with_args( - ('borg1',) + LIST_COMMAND[1:], capture_output=False + ('borg1',) + LIST_COMMAND[1:], output_log_level=logging.INFO ) module.list_archives(repository='repo', storage_config={}, local_path='borg1') @@ -61,7 +63,7 @@ def test_list_archives_with_local_path_calls_borg_via_local_path(): def test_list_archives_with_remote_path_calls_borg_with_remote_path_parameters(): flexmock(module).should_receive('execute_command').with_args( - LIST_COMMAND + ('--remote-path', 'borg1'), capture_output=False + LIST_COMMAND + ('--remote-path', 'borg1'), output_log_level=logging.INFO ) module.list_archives(repository='repo', storage_config={}, remote_path='borg1') @@ -69,7 +71,7 @@ def test_list_archives_with_remote_path_calls_borg_with_remote_path_parameters() def test_list_archives_with_json_calls_borg_with_json_parameter(): flexmock(module).should_receive('execute_command').with_args( - LIST_COMMAND + ('--json',), capture_output=True + LIST_COMMAND + ('--json',), output_log_level=None ).and_return('[]') json_output = module.list_archives(repository='repo', storage_config={}, json=True)