|
|
@@ -121,7 +121,7 @@ def test_validate_planned_backup_paths_skips_borgmatic_runtime_directory():
|
|
|
) == ('/foo', '/baz')
|
|
|
|
|
|
|
|
|
-def test_validate_planned_backup_paths_with_borgmatic_runtime_directory_missing_from_paths_output_errors():
|
|
|
+def test_validate_planned_backup_paths_with_borgmatic_runtime_directory_missing_from_paths_output_warns():
|
|
|
flexmock(module.flags).should_receive('omit_flag').replace_with(
|
|
|
lambda arguments, flag: arguments,
|
|
|
)
|
|
|
@@ -136,26 +136,26 @@ def test_validate_planned_backup_paths_with_borgmatic_runtime_directory_missing_
|
|
|
flexmock(module).should_receive('any_parent_directories').replace_with(
|
|
|
lambda path, candidates: any(path.startswith(parent) for parent in candidates)
|
|
|
)
|
|
|
+ flexmock(module.logger).should_receive('warning').once()
|
|
|
|
|
|
- with pytest.raises(ValueError):
|
|
|
- module.validate_planned_backup_paths(
|
|
|
- dry_run=False,
|
|
|
- create_command=('borg', 'create'),
|
|
|
- config={},
|
|
|
- patterns=(
|
|
|
- module.borgmatic.borg.pattern.Pattern('/foo'),
|
|
|
- module.borgmatic.borg.pattern.Pattern(
|
|
|
- '/run/borgmatic/bar', module.borgmatic.borg.pattern.Pattern_type.ROOT
|
|
|
- ),
|
|
|
- module.borgmatic.borg.pattern.Pattern('/baz'),
|
|
|
+ assert module.validate_planned_backup_paths(
|
|
|
+ dry_run=False,
|
|
|
+ create_command=('borg', 'create'),
|
|
|
+ config={},
|
|
|
+ patterns=(
|
|
|
+ module.borgmatic.borg.pattern.Pattern('/foo'),
|
|
|
+ module.borgmatic.borg.pattern.Pattern(
|
|
|
+ '/run/borgmatic/bar', module.borgmatic.borg.pattern.Pattern_type.ROOT
|
|
|
),
|
|
|
- local_path=None,
|
|
|
- working_directory=None,
|
|
|
- borgmatic_runtime_directory='/run/borgmatic',
|
|
|
- )
|
|
|
+ module.borgmatic.borg.pattern.Pattern('/baz'),
|
|
|
+ ),
|
|
|
+ local_path=None,
|
|
|
+ working_directory=None,
|
|
|
+ borgmatic_runtime_directory='/run/borgmatic',
|
|
|
+ ) == ('/foo', '/bar', '/baz')
|
|
|
|
|
|
|
|
|
-def test_validate_planned_backup_paths_with_borgmatic_runtime_directory_partially_excluded_from_paths_output_errors():
|
|
|
+def test_validate_planned_backup_paths_with_borgmatic_runtime_directory_partially_excluded_from_paths_output_does_not_warn():
|
|
|
flexmock(module.flags).should_receive('omit_flag').replace_with(
|
|
|
lambda arguments, flag: arguments,
|
|
|
)
|
|
|
@@ -172,26 +172,63 @@ def test_validate_planned_backup_paths_with_borgmatic_runtime_directory_partiall
|
|
|
flexmock(module).should_receive('any_parent_directories').replace_with(
|
|
|
lambda path, candidates: any(path.startswith(parent) for parent in candidates)
|
|
|
)
|
|
|
+ flexmock(module.logger).should_receive('warning').never()
|
|
|
|
|
|
- with pytest.raises(ValueError):
|
|
|
- module.validate_planned_backup_paths(
|
|
|
- dry_run=False,
|
|
|
- create_command=('borg', 'create'),
|
|
|
- config={},
|
|
|
- patterns=(
|
|
|
- module.borgmatic.borg.pattern.Pattern('/foo'),
|
|
|
- module.borgmatic.borg.pattern.Pattern(
|
|
|
- '/run/borgmatic/bar', module.borgmatic.borg.pattern.Pattern_type.ROOT
|
|
|
- ),
|
|
|
- module.borgmatic.borg.pattern.Pattern('/baz'),
|
|
|
- module.borgmatic.borg.pattern.Pattern(
|
|
|
- '/run/borgmatic/quux', module.borgmatic.borg.pattern.Pattern_type.ROOT
|
|
|
- ),
|
|
|
+ assert module.validate_planned_backup_paths(
|
|
|
+ dry_run=False,
|
|
|
+ create_command=('borg', 'create'),
|
|
|
+ config={},
|
|
|
+ patterns=(
|
|
|
+ module.borgmatic.borg.pattern.Pattern('/foo'),
|
|
|
+ module.borgmatic.borg.pattern.Pattern(
|
|
|
+ '/run/borgmatic/bar', module.borgmatic.borg.pattern.Pattern_type.ROOT
|
|
|
),
|
|
|
- local_path=None,
|
|
|
- working_directory=None,
|
|
|
- borgmatic_runtime_directory='/run/borgmatic',
|
|
|
- )
|
|
|
+ module.borgmatic.borg.pattern.Pattern('/baz'),
|
|
|
+ module.borgmatic.borg.pattern.Pattern(
|
|
|
+ '/run/borgmatic/quux', module.borgmatic.borg.pattern.Pattern_type.ROOT
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ local_path=None,
|
|
|
+ working_directory=None,
|
|
|
+ borgmatic_runtime_directory='/run/borgmatic',
|
|
|
+ ) == ('/foo', '/baz')
|
|
|
+
|
|
|
+
|
|
|
+def test_validate_planned_backup_paths_with_borgmatic_runtime_directory_with_corresponding_include_and_missing_from_paths_output_does_not_warn():
|
|
|
+ flexmock(module.flags).should_receive('omit_flag').replace_with(
|
|
|
+ lambda arguments, flag: arguments,
|
|
|
+ )
|
|
|
+ flexmock(module.flags).should_receive('omit_flag_and_value').replace_with(
|
|
|
+ lambda arguments, flag: arguments,
|
|
|
+ )
|
|
|
+ flexmock(module.environment).should_receive('make_environment').and_return(None)
|
|
|
+ flexmock(module).should_receive('execute_command_and_capture_output').and_return(
|
|
|
+ '+ /foo\n- /bar\n- /baz',
|
|
|
+ )
|
|
|
+ flexmock(module.os.path).should_receive('exists').and_return(True)
|
|
|
+ flexmock(module).should_receive('any_parent_directories').replace_with(
|
|
|
+ lambda path, candidates: any(path.startswith(parent) for parent in candidates)
|
|
|
+ )
|
|
|
+ flexmock(module.logger).should_receive('warning').never()
|
|
|
+
|
|
|
+ assert module.validate_planned_backup_paths(
|
|
|
+ dry_run=False,
|
|
|
+ create_command=('borg', 'create'),
|
|
|
+ config={},
|
|
|
+ patterns=(
|
|
|
+ module.borgmatic.borg.pattern.Pattern('/foo'),
|
|
|
+ module.borgmatic.borg.pattern.Pattern(
|
|
|
+ '/run/borgmatic/bar', module.borgmatic.borg.pattern.Pattern_type.ROOT
|
|
|
+ ),
|
|
|
+ module.borgmatic.borg.pattern.Pattern(
|
|
|
+ '/run/borgmatic/bar', module.borgmatic.borg.pattern.Pattern_type.INCLUDE
|
|
|
+ ),
|
|
|
+ module.borgmatic.borg.pattern.Pattern('/baz'),
|
|
|
+ ),
|
|
|
+ local_path=None,
|
|
|
+ working_directory=None,
|
|
|
+ borgmatic_runtime_directory='/run/borgmatic',
|
|
|
+ ) == ('/foo', '/bar', '/baz')
|
|
|
|
|
|
|
|
|
def test_validate_planned_backup_paths_with_borgmatic_runtime_directory_missing_from_patterns_does_not_raise():
|