Getting additional tests passing (#962).

This commit is contained in:
Dan Helfman
2025-01-13 20:51:27 -08:00
parent 661041da04
commit ca54da1067
6 changed files with 379 additions and 563 deletions
+1 -1
View File
@@ -178,7 +178,7 @@ def check_all_root_patterns_exist(patterns):
'''
missing_paths = [
pattern.path
for pattern in pattern
for pattern in patterns
if pattern.type == borgmatic.borg.pattern.Pattern_type.ROOT
if not os.path.exists(pattern.path)
]
+45 -35
View File
@@ -558,13 +558,15 @@ def test_collect_spot_check_source_paths_parses_borg_output():
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return(
{'hook1': False, 'hook2': True}
)
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'collect_patterns'
).and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'process_patterns'
).and_return([Pattern('foo'), Pattern('bar')])
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('collect_patterns').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('process_patterns').and_return(
[Pattern('foo'), Pattern('bar')]
)
flexmock(module.borgmatic.borg.create).should_receive('make_base_create_command').with_args(
dry_run=True,
repository_path='repo',
@@ -604,13 +606,15 @@ def test_collect_spot_check_source_paths_passes_through_stream_processes_false()
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return(
{'hook1': False, 'hook2': False}
)
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'collect_patterns'
).and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'process_patterns'
).and_return([Pattern('foo'), Pattern('bar')])
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('collect_patterns').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('process_patterns').and_return(
[Pattern('foo'), Pattern('bar')]
)
flexmock(module.borgmatic.borg.create).should_receive('make_base_create_command').with_args(
dry_run=True,
repository_path='repo',
@@ -650,13 +654,15 @@ def test_collect_spot_check_source_paths_without_working_directory_parses_borg_o
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return(
{'hook1': False, 'hook2': True}
)
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'collect_patterns'
).and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'process_patterns'
).and_return([Pattern('foo'), Pattern('bar')])
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('collect_patterns').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('process_patterns').and_return(
[Pattern('foo'), Pattern('bar')]
)
flexmock(module.borgmatic.borg.create).should_receive('make_base_create_command').with_args(
dry_run=True,
repository_path='repo',
@@ -696,13 +702,15 @@ def test_collect_spot_check_source_paths_skips_directories():
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return(
{'hook1': False, 'hook2': True}
)
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'collect_patterns'
).and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'process_patterns'
).and_return([Pattern('foo'), Pattern('bar')])
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('collect_patterns').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('process_patterns').and_return(
[Pattern('foo'), Pattern('bar')]
)
flexmock(module.borgmatic.borg.create).should_receive('make_base_create_command').with_args(
dry_run=True,
repository_path='repo',
@@ -840,13 +848,15 @@ def test_collect_spot_check_source_paths_uses_working_directory():
flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return(
{'hook1': False, 'hook2': True}
)
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'collect_patterns'
).and_return(flexmock())
flexmock(module.borgmatic.actions.create).should_receive(
'process_patterns'
).and_return([Pattern('foo'), Pattern('bar')])
flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('collect_patterns').and_return(
flexmock()
)
flexmock(module.borgmatic.actions.create).should_receive('process_patterns').and_return(
[Pattern('foo'), Pattern('bar')]
)
flexmock(module.borgmatic.borg.create).should_receive('make_base_create_command').with_args(
dry_run=True,
repository_path='repo',
File diff suppressed because it is too large Load Diff
+7 -6
View File
@@ -100,14 +100,16 @@ def test_get_subvolumes_collects_subvolumes_matching_patterns_from_all_filesyste
).with_args(path, object).and_return(())
assert module.get_subvolumes(
'btrfs', 'findmnt', patterns=[
'btrfs',
'findmnt',
patterns=[
Pattern('/one'),
Pattern('/four'),
Pattern('/five'),
Pattern('/six'),
Pattern('/mnt2'),
Pattern('/mnt3'),
]
],
) == (
module.Subvolume('/four', contained_patterns=(Pattern('/four'),)),
module.Subvolume('/one', contained_patterns=(Pattern('/one'),)),
@@ -165,9 +167,8 @@ def test_make_borg_snapshot_pattern_includes_slashdot_hack_and_stripped_pattern_
):
flexmock(module.os).should_receive('getpid').and_return(1234)
assert (
module.make_borg_snapshot_pattern(subvolume_path, Pattern(pattern_path))
== Pattern(expected_path)
assert module.make_borg_snapshot_pattern(subvolume_path, Pattern(pattern_path)) == Pattern(
expected_path
)
@@ -351,7 +352,7 @@ def test_dump_data_sources_uses_custom_findmnt_command_in_commands():
'/mnt/subvol1/.borgmatic-1234/mnt/subvol1/.borgmatic-1234',
Pattern_type.EXCLUDE,
Pattern_style.FNMATCH,
)
),
]
assert config == {
'btrfs': {
+3 -1
View File
@@ -43,7 +43,9 @@ def test_get_logical_volumes_filters_by_patterns():
).with_args(None, contained).never()
flexmock(module.borgmatic.hooks.data_source.snapshot).should_receive(
'get_contained_patterns'
).with_args('/mnt/lvolume', contained).and_return((Pattern('/mnt/lvolume'), Pattern('/mnt/lvolume/subdir')))
).with_args('/mnt/lvolume', contained).and_return(
(Pattern('/mnt/lvolume'), Pattern('/mnt/lvolume/subdir'))
)
flexmock(module.borgmatic.hooks.data_source.snapshot).should_receive(
'get_contained_patterns'
).with_args('/mnt/other', contained).and_return(())
+3 -1
View File
@@ -246,7 +246,9 @@ def test_dump_data_sources_ignores_mismatch_between_given_patterns_and_contained
full_snapshot_name,
module.os.path.normpath(snapshot_mount_path),
).once()
patterns = [Pattern('/hmm'),]
patterns = [
Pattern('/hmm'),
]
assert (
module.dump_data_sources(