Fix end-to-end tests for Btrfs (#1023).

This commit is contained in:
Dan Helfman
2025-03-10 10:15:23 -07:00
parent 4ee7f72696
commit bec5a0c0ca
2 changed files with 17 additions and 4 deletions
+15 -2
View File
@@ -24,7 +24,14 @@ def parse_arguments(*unparsed_arguments):
delete_parser = subvolume_subparser.add_parser('delete')
delete_parser.add_argument('snapshot_path')
return global_parser.parse_args(unparsed_arguments)
property_parser = action_parsers.add_parser('property')
property_subparser = property_parser.add_subparsers(dest='subaction')
get_parser = property_subparser.add_parser('get')
get_parser.add_argument('-t', dest='type')
get_parser.add_argument('subvolume_path')
get_parser.add_argument('property_name')
return (global_parser, global_parser.parse_args(unparsed_arguments))
BUILTIN_SUBVOLUME_LIST_LINES = (
@@ -60,9 +67,13 @@ def print_subvolume_list(arguments, snapshot_paths):
def main():
arguments = parse_arguments(*sys.argv[1:])
(global_parser, arguments) = parse_arguments(*sys.argv[1:])
snapshot_paths = load_snapshots()
if not hasattr(arguments, 'subaction'):
global_parser.print_help()
sys.exit(1)
if arguments.subaction == 'list':
print_subvolume_list(arguments, snapshot_paths)
elif arguments.subaction == 'snapshot':
@@ -84,6 +95,8 @@ def main():
if snapshot_path.endswith('/' + arguments.snapshot_path)
]
save_snapshots(snapshot_paths)
elif arguments.action == 'property' and arguments.subaction == 'get':
print(f'{arguments.property_name}=false')
if __name__ == '__main__':
+2 -2
View File
@@ -63,7 +63,7 @@ def test_get_subvolume_property_with_true_output_returns_true_bool():
'execute_command_and_capture_output'
).and_return('ro=true')
assert module.get_subvolume_property('btrfs', '/foo', 'ro') == True
assert module.get_subvolume_property('btrfs', '/foo', 'ro') is True
def test_get_subvolume_property_with_false_output_returns_false_bool():
@@ -71,7 +71,7 @@ def test_get_subvolume_property_with_false_output_returns_false_bool():
'execute_command_and_capture_output'
).and_return('ro=false')
assert module.get_subvolume_property('btrfs', '/foo', 'ro') == False
assert module.get_subvolume_property('btrfs', '/foo', 'ro') is False
def test_get_subvolume_property_passes_through_general_value():