Use flag-related utility functions in info action (#557).
This commit is contained in:
parent
3ab7a3b64a
commit
57009e22b5
2 changed files with 21 additions and 45 deletions
|
@ -44,15 +44,13 @@ def display_archives_info(
|
|||
info_arguments, excludes=('repository', 'archive', 'prefix')
|
||||
)
|
||||
+ (
|
||||
(
|
||||
flags.make_flags('repo', repository)
|
||||
+ flags.make_flags('glob-archives', info_arguments.archive)
|
||||
)
|
||||
if feature.available(feature.Feature.SEPARATE_REPOSITORY_ARCHIVE, local_borg_version)
|
||||
else (
|
||||
'::'.join((repository, info_arguments.archive))
|
||||
if info_arguments.archive
|
||||
else repository,
|
||||
flags.make_repository_flags(repository, local_borg_version)
|
||||
+ (
|
||||
flags.make_flags('glob-archives', info_arguments.archive)
|
||||
if feature.available(
|
||||
feature.Feature.SEPARATE_REPOSITORY_ARCHIVE, local_borg_version
|
||||
)
|
||||
else ()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -10,10 +10,8 @@ from ..test_verbosity import insert_logging_mock
|
|||
|
||||
def test_display_archives_info_calls_borg_with_parameters():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -34,6 +32,7 @@ def test_display_archives_info_calls_borg_with_parameters():
|
|||
def test_display_archives_info_without_borg_features_calls_borg_without_repo_flag():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -53,10 +52,8 @@ def test_display_archives_info_without_borg_features_calls_borg_without_repo_fla
|
|||
|
||||
def test_display_archives_info_with_log_info_calls_borg_with_info_parameter():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -76,10 +73,8 @@ def test_display_archives_info_with_log_info_calls_borg_with_info_parameter():
|
|||
|
||||
def test_display_archives_info_with_log_info_and_json_suppresses_most_borg_output():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -102,10 +97,8 @@ def test_display_archives_info_with_log_info_and_json_suppresses_most_borg_outpu
|
|||
|
||||
def test_display_archives_info_with_log_debug_calls_borg_with_debug_parameter():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -126,10 +119,8 @@ def test_display_archives_info_with_log_debug_calls_borg_with_debug_parameter():
|
|||
|
||||
def test_display_archives_info_with_log_debug_and_json_suppresses_most_borg_output():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -152,10 +143,8 @@ def test_display_archives_info_with_log_debug_and_json_suppresses_most_borg_outp
|
|||
|
||||
def test_display_archives_info_with_json_calls_borg_with_json_parameter():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -177,13 +166,11 @@ def test_display_archives_info_with_json_calls_borg_with_json_parameter():
|
|||
|
||||
def test_display_archives_info_with_archive_calls_borg_with_glob_archives_parameter():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
||||
'glob-archives', 'archive'
|
||||
).and_return(('--glob-archives', 'archive'))
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -204,6 +191,7 @@ def test_display_archives_info_with_archive_calls_borg_with_glob_archives_parame
|
|||
def test_display_archives_info_with_archive_and_without_borg_features_calls_borg_with_repo_archive_parameter():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo::archive',))
|
||||
flexmock(module.feature).should_receive('available').and_return(False)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -223,11 +211,9 @@ def test_display_archives_info_with_archive_and_without_borg_features_calls_borg
|
|||
|
||||
def test_display_archives_info_with_local_path_calls_borg_via_local_path():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
('borg1', 'info', '--repo', 'repo'),
|
||||
|
@ -247,13 +233,11 @@ 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.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
||||
'remote-path', 'borg1'
|
||||
).and_return(('--remote-path', 'borg1'))
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -274,13 +258,11 @@ 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():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('lock-wait', 5).and_return(
|
||||
('--lock-wait', '5')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
storage_config = {'lock_wait': 5}
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
|
@ -301,13 +283,11 @@ def test_display_archives_info_with_lock_wait_calls_borg_with_lock_wait_paramete
|
|||
|
||||
def test_display_archives_info_with_prefix_calls_borg_with_glob_archives_parameters():
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags').with_args(
|
||||
'glob-archives', 'foo*'
|
||||
).and_return(('--glob-archives', 'foo*'))
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
@ -329,12 +309,10 @@ def test_display_archives_info_with_prefix_calls_borg_with_glob_archives_paramet
|
|||
def test_display_archives_info_passes_through_arguments_to_borg(argument_name):
|
||||
flag_name = f"--{argument_name.replace('_', ' ')}"
|
||||
flexmock(module.flags).should_receive('make_flags').and_return(())
|
||||
flexmock(module.flags).should_receive('make_flags').with_args('repo', 'repo').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(
|
||||
(flag_name, 'value')
|
||||
)
|
||||
flexmock(module.flags).should_receive('make_repository_flags').and_return(('--repo', 'repo'))
|
||||
flexmock(module.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
|
|
Loading…
Reference in a new issue