|
@@ -8,6 +8,8 @@ from ..test_verbosity import insert_logging_mock
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_calls_borg_with_parameters():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'break-lock', 'repo'),
|
|
@@ -17,11 +19,13 @@ def test_run_arbitrary_borg_calls_borg_with_parameters():
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['break-lock'],
|
|
|
+ repository='repo', storage_config={}, local_borg_version='1.2.3', options=['break-lock'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_with_log_info_calls_borg_with_info_parameter():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'break-lock', 'repo', '--info'),
|
|
@@ -32,11 +36,13 @@ def test_run_arbitrary_borg_with_log_info_calls_borg_with_info_parameter():
|
|
|
insert_logging_mock(logging.INFO)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['break-lock'],
|
|
|
+ repository='repo', storage_config={}, local_borg_version='1.2.3', options=['break-lock'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_with_log_debug_calls_borg_with_debug_parameter():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'break-lock', 'repo', '--debug', '--show-rc'),
|
|
@@ -47,12 +53,16 @@ def test_run_arbitrary_borg_with_log_debug_calls_borg_with_debug_parameter():
|
|
|
insert_logging_mock(logging.DEBUG)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['break-lock'],
|
|
|
+ repository='repo', storage_config={}, local_borg_version='1.2.3', options=['break-lock'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
|
|
storage_config = {'lock_wait': 5}
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(
|
|
|
+ ('--lock-wait', '5')
|
|
|
+ )
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'break-lock', 'repo', '--lock-wait', '5'),
|
|
@@ -62,12 +72,18 @@ def test_run_arbitrary_borg_with_lock_wait_calls_borg_with_lock_wait_parameters(
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config=storage_config, options=['break-lock'],
|
|
|
+ repository='repo',
|
|
|
+ storage_config=storage_config,
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ options=['break-lock'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_with_archive_calls_borg_with_archive_parameter():
|
|
|
- storage_config = {}
|
|
|
+ flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
|
|
+ ('repo::archive',)
|
|
|
+ )
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'break-lock', 'repo::archive'),
|
|
@@ -77,11 +93,17 @@ def test_run_arbitrary_borg_with_archive_calls_borg_with_archive_parameter():
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config=storage_config, options=['break-lock'], archive='archive',
|
|
|
+ repository='repo',
|
|
|
+ storage_config={},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ options=['break-lock'],
|
|
|
+ archive='archive',
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_with_local_path_calls_borg_via_local_path():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg1', 'break-lock', 'repo'),
|
|
@@ -91,11 +113,19 @@ def test_run_arbitrary_borg_with_local_path_calls_borg_via_local_path():
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['break-lock'], local_path='borg1',
|
|
|
+ repository='repo',
|
|
|
+ storage_config={},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ options=['break-lock'],
|
|
|
+ local_path='borg1',
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_with_remote_path_calls_borg_with_remote_path_parameters():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(
|
|
|
+ ('--remote-path', 'borg1')
|
|
|
+ ).and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'break-lock', 'repo', '--remote-path', 'borg1'),
|
|
@@ -105,11 +135,17 @@ def test_run_arbitrary_borg_with_remote_path_calls_borg_with_remote_path_paramet
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['break-lock'], remote_path='borg1',
|
|
|
+ repository='repo',
|
|
|
+ storage_config={},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ options=['break-lock'],
|
|
|
+ remote_path='borg1',
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_passes_borg_specific_parameters_to_borg():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'list', 'repo', '--progress'),
|
|
@@ -119,11 +155,16 @@ def test_run_arbitrary_borg_passes_borg_specific_parameters_to_borg():
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['list', '--progress'],
|
|
|
+ repository='repo',
|
|
|
+ storage_config={},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ options=['list', '--progress'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_omits_dash_dash_in_parameters_passed_to_borg():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'break-lock', 'repo'),
|
|
@@ -133,22 +174,29 @@ def test_run_arbitrary_borg_omits_dash_dash_in_parameters_passed_to_borg():
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['--', 'break-lock'],
|
|
|
+ repository='repo',
|
|
|
+ storage_config={},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ options=['--', 'break-lock'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_without_borg_specific_parameters_does_not_raise():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').never()
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg',), output_log_level=logging.WARNING, borg_local_path='borg', extra_environment=None,
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=[],
|
|
|
+ repository='repo', storage_config={}, local_borg_version='1.2.3', options=[],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_passes_key_sub_command_to_borg_before_repository():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'key', 'export', 'repo'),
|
|
@@ -158,11 +206,13 @@ def test_run_arbitrary_borg_passes_key_sub_command_to_borg_before_repository():
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['key', 'export'],
|
|
|
+ repository='repo', storage_config={}, local_borg_version='1.2.3', options=['key', 'export'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_passes_debug_sub_command_to_borg_before_repository():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'debug', 'dump-manifest', 'repo', 'path'),
|
|
@@ -172,11 +222,16 @@ def test_run_arbitrary_borg_passes_debug_sub_command_to_borg_before_repository()
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['debug', 'dump-manifest', 'path'],
|
|
|
+ repository='repo',
|
|
|
+ storage_config={},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ options=['debug', 'dump-manifest', 'path'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_with_debug_info_command_does_not_pass_borg_repository():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').never()
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'debug', 'info'),
|
|
@@ -186,11 +241,13 @@ def test_run_arbitrary_borg_with_debug_info_command_does_not_pass_borg_repositor
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['debug', 'info'],
|
|
|
+ repository='repo', storage_config={}, local_borg_version='1.2.3', options=['debug', 'info'],
|
|
|
)
|
|
|
|
|
|
|
|
|
def test_run_arbitrary_borg_with_debug_convert_profile_command_does_not_pass_borg_repository():
|
|
|
+ flexmock(module.flags).should_receive('make_repository_flags').never()
|
|
|
+ flexmock(module.flags).should_receive('make_flags').and_return(())
|
|
|
flexmock(module.environment).should_receive('make_environment')
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('borg', 'debug', 'convert-profile', 'in', 'out'),
|
|
@@ -200,5 +257,8 @@ def test_run_arbitrary_borg_with_debug_convert_profile_command_does_not_pass_bor
|
|
|
)
|
|
|
|
|
|
module.run_arbitrary_borg(
|
|
|
- repository='repo', storage_config={}, options=['debug', 'convert-profile', 'in', 'out'],
|
|
|
+ repository='repo',
|
|
|
+ storage_config={},
|
|
|
+ local_borg_version='1.2.3',
|
|
|
+ options=['debug', 'convert-profile', 'in', 'out'],
|
|
|
)
|