|
@@ -49,8 +49,61 @@ def test_get_subvolume_mount_points_with_findmnt_json_missing_filesystems_errors
|
|
|
module.get_subvolume_mount_points('findmnt')
|
|
|
|
|
|
|
|
|
+def test_get_subvolume_property_with_invalid_btrfs_output_errors():
|
|
|
+ flexmock(module.borgmatic.execute).should_receive(
|
|
|
+ 'execute_command_and_capture_output'
|
|
|
+ ).and_return('invalid')
|
|
|
+
|
|
|
+ with pytest.raises(ValueError):
|
|
|
+ module.get_subvolume_property('btrfs', '/foo', 'ro')
|
|
|
+
|
|
|
+
|
|
|
+def test_get_subvolume_property_with_true_output_returns_true_bool():
|
|
|
+ flexmock(module.borgmatic.execute).should_receive(
|
|
|
+ 'execute_command_and_capture_output'
|
|
|
+ ).and_return('ro=true')
|
|
|
+
|
|
|
+ assert module.get_subvolume_property('btrfs', '/foo', 'ro') == True
|
|
|
+
|
|
|
+
|
|
|
+def test_get_subvolume_property_with_false_output_returns_false_bool():
|
|
|
+ flexmock(module.borgmatic.execute).should_receive(
|
|
|
+ 'execute_command_and_capture_output'
|
|
|
+ ).and_return('ro=false')
|
|
|
+
|
|
|
+ assert module.get_subvolume_property('btrfs', '/foo', 'ro') == False
|
|
|
+
|
|
|
+
|
|
|
+def test_get_subvolume_property_passes_through_general_value():
|
|
|
+ flexmock(module.borgmatic.execute).should_receive(
|
|
|
+ 'execute_command_and_capture_output'
|
|
|
+ ).and_return('thing=value')
|
|
|
+
|
|
|
+ assert module.get_subvolume_property('btrfs', '/foo', 'thing') == 'value'
|
|
|
+
|
|
|
+
|
|
|
+def test_omit_read_only_subvolume_mount_points_filters_out_read_only():
|
|
|
+ flexmock(module).should_receive('get_subvolume_property').with_args(
|
|
|
+ 'btrfs', '/foo', 'ro'
|
|
|
+ ).and_return(False)
|
|
|
+ flexmock(module).should_receive('get_subvolume_property').with_args(
|
|
|
+ 'btrfs', '/bar', 'ro'
|
|
|
+ ).and_return(True)
|
|
|
+ flexmock(module).should_receive('get_subvolume_property').with_args(
|
|
|
+ 'btrfs', '/baz', 'ro'
|
|
|
+ ).and_return(False)
|
|
|
+
|
|
|
+ assert module.omit_read_only_subvolume_mount_points('btrfs', ('/foo', '/bar', '/baz')) == (
|
|
|
+ '/foo',
|
|
|
+ '/baz',
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
def test_get_subvolumes_collects_subvolumes_matching_patterns():
|
|
|
flexmock(module).should_receive('get_subvolume_mount_points').and_return(('/mnt1', '/mnt2'))
|
|
|
+ flexmock(module).should_receive('omit_read_only_subvolume_mount_points').and_return(
|
|
|
+ ('/mnt1', '/mnt2')
|
|
|
+ )
|
|
|
|
|
|
contained_pattern = Pattern(
|
|
|
'/mnt1',
|
|
@@ -76,6 +129,9 @@ def test_get_subvolumes_collects_subvolumes_matching_patterns():
|
|
|
|
|
|
def test_get_subvolumes_skips_non_root_patterns():
|
|
|
flexmock(module).should_receive('get_subvolume_mount_points').and_return(('/mnt1', '/mnt2'))
|
|
|
+ flexmock(module).should_receive('omit_read_only_subvolume_mount_points').and_return(
|
|
|
+ ('/mnt1', '/mnt2')
|
|
|
+ )
|
|
|
|
|
|
flexmock(module.borgmatic.hooks.data_source.snapshot).should_receive(
|
|
|
'get_contained_patterns'
|
|
@@ -107,6 +163,9 @@ def test_get_subvolumes_skips_non_root_patterns():
|
|
|
|
|
|
def test_get_subvolumes_skips_non_config_patterns():
|
|
|
flexmock(module).should_receive('get_subvolume_mount_points').and_return(('/mnt1', '/mnt2'))
|
|
|
+ flexmock(module).should_receive('omit_read_only_subvolume_mount_points').and_return(
|
|
|
+ ('/mnt1', '/mnt2')
|
|
|
+ )
|
|
|
|
|
|
flexmock(module.borgmatic.hooks.data_source.snapshot).should_receive(
|
|
|
'get_contained_patterns'
|
|
@@ -138,6 +197,9 @@ def test_get_subvolumes_skips_non_config_patterns():
|
|
|
|
|
|
def test_get_subvolumes_without_patterns_collects_all_subvolumes():
|
|
|
flexmock(module).should_receive('get_subvolume_mount_points').and_return(('/mnt1', '/mnt2'))
|
|
|
+ flexmock(module).should_receive('omit_read_only_subvolume_mount_points').and_return(
|
|
|
+ ('/mnt1', '/mnt2')
|
|
|
+ )
|
|
|
|
|
|
flexmock(module.borgmatic.hooks.data_source.snapshot).should_receive(
|
|
|
'get_contained_patterns'
|