|
|
|
@ -8,8 +8,6 @@ from borgmatic.borg import list as module
|
|
|
|
|
from ..test_verbosity import insert_logging_mock
|
|
|
|
|
|
|
|
|
|
BORG_LIST_LATEST_ARGUMENTS = (
|
|
|
|
|
'--glob-archives',
|
|
|
|
|
module.BORG_EXCLUDE_CHECKPOINTS_GLOB,
|
|
|
|
|
'--last',
|
|
|
|
|
'1',
|
|
|
|
|
'--short',
|
|
|
|
@ -116,7 +114,7 @@ def test_list_archives_calls_borg_with_parameters():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -129,7 +127,7 @@ def test_list_archives_with_log_info_calls_borg_with_info_parameter():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -142,7 +140,7 @@ def test_list_archives_with_log_info_and_json_suppresses_most_borg_output():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=True, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=True),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -157,7 +155,7 @@ def test_list_archives_with_log_debug_calls_borg_with_debug_parameter():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -170,7 +168,7 @@ def test_list_archives_with_log_debug_and_json_suppresses_most_borg_output():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=True, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=True),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -185,7 +183,7 @@ def test_list_archives_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config=storage_config,
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -198,7 +196,7 @@ def test_list_archives_with_archive_calls_borg_with_archive_parameter():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config=storage_config,
|
|
|
|
|
list_arguments=flexmock(archive='archive', paths=None, json=False, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive='archive', paths=None, json=False),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -213,7 +211,7 @@ def test_list_archives_with_path_calls_borg_with_path_parameter():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config=storage_config,
|
|
|
|
|
list_arguments=flexmock(archive='archive', paths=['var/lib'], json=False, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive='archive', paths=['var/lib'], json=False),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -225,7 +223,7 @@ def test_list_archives_with_local_path_calls_borg_via_local_path():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False),
|
|
|
|
|
local_path='borg1',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -240,7 +238,7 @@ def test_list_archives_with_remote_path_calls_borg_with_remote_path_parameters()
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False),
|
|
|
|
|
remote_path='borg1',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -255,7 +253,7 @@ def test_list_archives_with_short_calls_borg_with_short_parameter():
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, successful=False, short=True),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, short=True),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -283,23 +281,7 @@ def test_list_archives_passes_through_arguments_to_borg(argument_name):
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(
|
|
|
|
|
archive=None, paths=None, json=False, successful=False, **{argument_name: 'value'}
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_archives_with_successful_calls_borg_to_exclude_checkpoints():
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
|
|
('borg', 'list', '--glob-archives', module.BORG_EXCLUDE_CHECKPOINTS_GLOB, 'repo'),
|
|
|
|
|
output_log_level=logging.WARNING,
|
|
|
|
|
borg_local_path='borg',
|
|
|
|
|
).and_return('[]')
|
|
|
|
|
|
|
|
|
|
module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, successful=True),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=False, **{argument_name: 'value'}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -311,7 +293,7 @@ def test_list_archives_with_json_calls_borg_with_json_parameter():
|
|
|
|
|
json_output = module.list_archives(
|
|
|
|
|
repository='repo',
|
|
|
|
|
storage_config={},
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=True, successful=False),
|
|
|
|
|
list_arguments=flexmock(archive=None, paths=None, json=True),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert json_output == '[]'
|
|
|
|
|