|
@@ -135,32 +135,6 @@ def test_make_prune_flags_without_prefix_uses_archive_name_format_instead():
|
|
|
assert result == expected
|
|
|
|
|
|
|
|
|
-def test_make_prune_flags_without_prefix_uses_match_archives_flag_instead_of_option():
|
|
|
- config = {
|
|
|
- 'archive_name_format': 'bar-{now}', # noqa: FS003
|
|
|
- 'match_archives': 'foo*',
|
|
|
- 'keep_daily': 1,
|
|
|
- 'prefix': None,
|
|
|
- }
|
|
|
- flexmock(module.feature).should_receive('available').and_return(True)
|
|
|
- flexmock(module.flags).should_receive('make_match_archives_flags').with_args(
|
|
|
- 'baz*', 'bar-{now}', '1.2.3' # noqa: FS003
|
|
|
- ).and_return(('--match-archives', 'sh:bar-*')).once()
|
|
|
-
|
|
|
- result = module.make_prune_flags(
|
|
|
- config, flexmock(match_archives='baz*'), local_borg_version='1.2.3'
|
|
|
- )
|
|
|
-
|
|
|
- expected = (
|
|
|
- '--keep-daily',
|
|
|
- '1',
|
|
|
- '--match-archives',
|
|
|
- 'sh:bar-*', # noqa: FS003
|
|
|
- )
|
|
|
-
|
|
|
- assert result == expected
|
|
|
-
|
|
|
-
|
|
|
def test_make_prune_flags_without_prefix_uses_match_archives_option():
|
|
|
config = {
|
|
|
'archive_name_format': 'bar-{now}', # noqa: FS003
|
|
@@ -215,7 +189,7 @@ def test_prune_archives_calls_borg_with_flags():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('repo',), logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -237,7 +211,7 @@ def test_prune_archives_with_log_info_calls_borg_with_info_flag():
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--info', 'repo'), logging.INFO)
|
|
|
insert_logging_mock(logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
repository_path='repo',
|
|
|
config={},
|
|
@@ -259,7 +233,7 @@ def test_prune_archives_with_log_debug_calls_borg_with_debug_flag():
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--debug', '--show-rc', 'repo'), logging.INFO)
|
|
|
insert_logging_mock(logging.DEBUG)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
repository_path='repo',
|
|
|
config={},
|
|
@@ -280,7 +254,7 @@ def test_prune_archives_with_dry_run_calls_borg_with_dry_run_flag():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--dry-run', 'repo'), logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
repository_path='repo',
|
|
|
config={},
|
|
@@ -301,7 +275,7 @@ def test_prune_archives_with_local_path_calls_borg_via_local_path():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(('borg1',) + PRUNE_COMMAND[1:] + ('repo',), logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -328,7 +302,7 @@ def test_prune_archives_with_exit_codes_calls_borg_using_them():
|
|
|
borg_exit_codes=borg_exit_codes,
|
|
|
)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -349,7 +323,7 @@ def test_prune_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--remote-path', 'borg1', 'repo'), logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -361,7 +335,7 @@ def test_prune_archives_with_remote_path_calls_borg_with_remote_path_flags():
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_prune_archives_favors_stats_flag_over_config():
|
|
|
+def test_prune_archives_with_stats_config_calls_borg_with_stats_flag():
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
|
flexmock(module).should_receive('make_prune_flags').and_return(BASE_PRUNE_FLAGS)
|
|
@@ -371,28 +345,7 @@ def test_prune_archives_favors_stats_flag_over_config():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--stats', 'repo'), module.borgmatic.logger.ANSWER)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=True, list_archives=False)
|
|
|
- module.prune_archives(
|
|
|
- dry_run=False,
|
|
|
- repository_path='repo',
|
|
|
- config={'statistics': False},
|
|
|
- local_borg_version='1.2.3',
|
|
|
- global_arguments=flexmock(log_json=False),
|
|
|
- prune_arguments=prune_arguments,
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-def test_prune_archives_defaults_to_stats_config():
|
|
|
- flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
- flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
|
- flexmock(module).should_receive('make_prune_flags').and_return(BASE_PRUNE_FLAGS)
|
|
|
- flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
- flexmock(module.feature).should_receive('available').with_args(
|
|
|
- module.feature.Feature.NO_PRUNE_STATS, '1.2.3'
|
|
|
- ).and_return(False)
|
|
|
- insert_execute_command_mock(PRUNE_COMMAND + ('--stats', 'repo'), module.borgmatic.logger.ANSWER)
|
|
|
-
|
|
|
- prune_arguments = flexmock(stats=None, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=None, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -403,28 +356,7 @@ def test_prune_archives_defaults_to_stats_config():
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_prune_archives_favors_list_flag_over_config():
|
|
|
- flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
- flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
|
- flexmock(module).should_receive('make_prune_flags').and_return(BASE_PRUNE_FLAGS)
|
|
|
- flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
|
|
|
- flexmock(module.feature).should_receive('available').with_args(
|
|
|
- module.feature.Feature.NO_PRUNE_STATS, '1.2.3'
|
|
|
- ).and_return(False)
|
|
|
- insert_execute_command_mock(PRUNE_COMMAND + ('--list', 'repo'), module.borgmatic.logger.ANSWER)
|
|
|
-
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=True)
|
|
|
- module.prune_archives(
|
|
|
- dry_run=False,
|
|
|
- repository_path='repo',
|
|
|
- config={'list_details': False},
|
|
|
- local_borg_version='1.2.3',
|
|
|
- global_arguments=flexmock(log_json=False),
|
|
|
- prune_arguments=prune_arguments,
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-def test_prune_archives_defaults_to_list_config():
|
|
|
+def test_prune_archives_with_list_config_calls_borg_with_list_flag():
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
|
flexmock(module).should_receive('make_prune_flags').and_return(BASE_PRUNE_FLAGS)
|
|
@@ -434,7 +366,7 @@ def test_prune_archives_defaults_to_list_config():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--list', 'repo'), module.borgmatic.logger.ANSWER)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=None)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=None)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -456,7 +388,7 @@ def test_prune_archives_with_umask_calls_borg_with_umask_flags():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--umask', '077', 'repo'), logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -477,7 +409,7 @@ def test_prune_archives_with_log_json_calls_borg_with_log_json_flag():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--log-json', 'repo'), logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -499,7 +431,7 @@ def test_prune_archives_with_lock_wait_calls_borg_with_lock_wait_flags():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--lock-wait', '5', 'repo'), logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -520,7 +452,7 @@ def test_prune_archives_with_extra_borg_options_calls_borg_with_extra_options():
|
|
|
).and_return(False)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('--extra', '--options', 'repo'), logging.INFO)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -588,7 +520,7 @@ def test_prune_archives_with_date_based_matching_calls_borg_with_date_based_flag
|
|
|
)
|
|
|
|
|
|
prune_arguments = flexmock(
|
|
|
- stats=False, list_archives=False, newer='1d', newest='1y', older='1m', oldest='1w'
|
|
|
+ statistics=False, list_details=False, newer='1d', newest='1y', older='1m', oldest='1w'
|
|
|
)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
@@ -612,7 +544,7 @@ def test_prune_archives_calls_borg_with_working_directory():
|
|
|
PRUNE_COMMAND + ('repo',), logging.INFO, working_directory='/working/dir'
|
|
|
)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=False, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=False, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
@@ -623,7 +555,7 @@ def test_prune_archives_calls_borg_with_working_directory():
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_prune_archives_calls_borg_with_flags_and_when_feature_available():
|
|
|
+def test_prune_archives_calls_borg_without_stats_when_feature_is_not_available():
|
|
|
flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
|
|
|
flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
|
|
|
flexmock(module).should_receive('make_prune_flags').and_return(BASE_PRUNE_FLAGS)
|
|
@@ -633,11 +565,11 @@ def test_prune_archives_calls_borg_with_flags_and_when_feature_available():
|
|
|
).and_return(True)
|
|
|
insert_execute_command_mock(PRUNE_COMMAND + ('repo',), logging.ANSWER)
|
|
|
|
|
|
- prune_arguments = flexmock(stats=True, list_archives=False)
|
|
|
+ prune_arguments = flexmock(statistics=True, list_details=False)
|
|
|
module.prune_archives(
|
|
|
dry_run=False,
|
|
|
repository_path='repo',
|
|
|
- config={},
|
|
|
+ config={'statistics': True},
|
|
|
local_borg_version='2.0.0b10',
|
|
|
global_arguments=flexmock(log_json=False),
|
|
|
prune_arguments=prune_arguments,
|