|
|
@@ -360,6 +360,9 @@ def test_dump_data_sources_snapshots_and_mounts_and_replaces_patterns():
|
|
|
logical_volumes[1],
|
|
|
'/run/borgmatic',
|
|
|
).and_return(Pattern('/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume2'))
|
|
|
+ flexmock(module.borgmatic.hooks.data_source.config).should_receive(
|
|
|
+ 'get_last_pattern_index'
|
|
|
+ ).and_return(0)
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').with_args(
|
|
|
object,
|
|
|
Pattern('/mnt/lvolume1/subdir'),
|
|
|
@@ -367,6 +370,7 @@ def test_dump_data_sources_snapshots_and_mounts_and_replaces_patterns():
|
|
|
'/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume1/subdir',
|
|
|
source=module.borgmatic.borg.pattern.Pattern_source.HOOK,
|
|
|
),
|
|
|
+ 0,
|
|
|
).once()
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').with_args(
|
|
|
object,
|
|
|
@@ -375,6 +379,7 @@ def test_dump_data_sources_snapshots_and_mounts_and_replaces_patterns():
|
|
|
'/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume2',
|
|
|
source=module.borgmatic.borg.pattern.Pattern_source.HOOK,
|
|
|
),
|
|
|
+ 0,
|
|
|
).once()
|
|
|
|
|
|
assert (
|
|
|
@@ -396,6 +401,9 @@ def test_dump_data_sources_with_no_logical_volumes_skips_snapshots():
|
|
|
flexmock(module).should_receive('get_logical_volumes').and_return(())
|
|
|
flexmock(module).should_receive('snapshot_logical_volume').never()
|
|
|
flexmock(module).should_receive('mount_snapshot').never()
|
|
|
+ flexmock(module.borgmatic.hooks.data_source.config).should_receive(
|
|
|
+ 'get_last_pattern_index'
|
|
|
+ ).and_return(0)
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').never()
|
|
|
|
|
|
assert (
|
|
|
@@ -477,6 +485,9 @@ def test_dump_data_sources_uses_snapshot_size_for_snapshot():
|
|
|
logical_volumes[1],
|
|
|
'/run/borgmatic',
|
|
|
).and_return(Pattern('/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume2'))
|
|
|
+ flexmock(module.borgmatic.hooks.data_source.config).should_receive(
|
|
|
+ 'get_last_pattern_index'
|
|
|
+ ).and_return(0)
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').with_args(
|
|
|
object,
|
|
|
Pattern('/mnt/lvolume1/subdir'),
|
|
|
@@ -484,6 +495,7 @@ def test_dump_data_sources_uses_snapshot_size_for_snapshot():
|
|
|
'/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume1/subdir',
|
|
|
source=module.borgmatic.borg.pattern.Pattern_source.HOOK,
|
|
|
),
|
|
|
+ 0,
|
|
|
).once()
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').with_args(
|
|
|
object,
|
|
|
@@ -492,6 +504,7 @@ def test_dump_data_sources_uses_snapshot_size_for_snapshot():
|
|
|
'/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume2',
|
|
|
source=module.borgmatic.borg.pattern.Pattern_source.HOOK,
|
|
|
),
|
|
|
+ 0,
|
|
|
).once()
|
|
|
|
|
|
assert (
|
|
|
@@ -580,6 +593,9 @@ def test_dump_data_sources_uses_custom_commands():
|
|
|
logical_volumes[1],
|
|
|
'/run/borgmatic',
|
|
|
).and_return(Pattern('/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume2'))
|
|
|
+ flexmock(module.borgmatic.hooks.data_source.config).should_receive(
|
|
|
+ 'get_last_pattern_index'
|
|
|
+ ).and_return(0)
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').with_args(
|
|
|
object,
|
|
|
Pattern('/mnt/lvolume1/subdir'),
|
|
|
@@ -587,6 +603,7 @@ def test_dump_data_sources_uses_custom_commands():
|
|
|
'/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume1/subdir',
|
|
|
source=module.borgmatic.borg.pattern.Pattern_source.HOOK,
|
|
|
),
|
|
|
+ 0,
|
|
|
).once()
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').with_args(
|
|
|
object,
|
|
|
@@ -595,6 +612,7 @@ def test_dump_data_sources_uses_custom_commands():
|
|
|
'/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume2',
|
|
|
source=module.borgmatic.borg.pattern.Pattern_source.HOOK,
|
|
|
),
|
|
|
+ 0,
|
|
|
).once()
|
|
|
|
|
|
assert (
|
|
|
@@ -633,6 +651,9 @@ def test_dump_data_sources_with_dry_run_skips_snapshots_and_does_not_touch_patte
|
|
|
flexmock(module).should_receive('snapshot_logical_volume').never()
|
|
|
flexmock(module).should_receive('get_snapshots').never()
|
|
|
flexmock(module).should_receive('mount_snapshot').never()
|
|
|
+ flexmock(module.borgmatic.hooks.data_source.config).should_receive(
|
|
|
+ 'get_last_pattern_index'
|
|
|
+ ).never()
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').never()
|
|
|
|
|
|
assert (
|
|
|
@@ -714,6 +735,9 @@ def test_dump_data_sources_ignores_mismatch_between_given_patterns_and_contained
|
|
|
logical_volumes[1],
|
|
|
'/run/borgmatic',
|
|
|
).and_return(Pattern('/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume2'))
|
|
|
+ flexmock(module.borgmatic.hooks.data_source.config).should_receive(
|
|
|
+ 'get_last_pattern_index'
|
|
|
+ ).and_return(0)
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').with_args(
|
|
|
object,
|
|
|
Pattern('/mnt/lvolume1/subdir'),
|
|
|
@@ -721,6 +745,7 @@ def test_dump_data_sources_ignores_mismatch_between_given_patterns_and_contained
|
|
|
'/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume1/subdir',
|
|
|
source=module.borgmatic.borg.pattern.Pattern_source.HOOK,
|
|
|
),
|
|
|
+ 0,
|
|
|
).once()
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').with_args(
|
|
|
object,
|
|
|
@@ -729,6 +754,7 @@ def test_dump_data_sources_ignores_mismatch_between_given_patterns_and_contained
|
|
|
'/run/borgmatic/lvm_snapshots/b33f/./mnt/lvolume2',
|
|
|
source=module.borgmatic.borg.pattern.Pattern_source.HOOK,
|
|
|
),
|
|
|
+ 0,
|
|
|
).once()
|
|
|
|
|
|
assert (
|
|
|
@@ -785,6 +811,9 @@ def test_dump_data_sources_with_missing_snapshot_errors():
|
|
|
snapshot_name='lvolume2_borgmatic-1234',
|
|
|
).never()
|
|
|
flexmock(module).should_receive('mount_snapshot').never()
|
|
|
+ flexmock(module.borgmatic.hooks.data_source.config).should_receive(
|
|
|
+ 'get_last_pattern_index'
|
|
|
+ ).never()
|
|
|
flexmock(module.borgmatic.hooks.data_source.config).should_receive('replace_pattern').never()
|
|
|
|
|
|
with pytest.raises(ValueError):
|