Explorar el Código

Error if --list is used with --json for create action (#680).

Dan Helfman hace 2 años
padre
commit
359afe5318
Se han modificado 2 ficheros con 11 adiciones y 0 borrados
  1. 4 0
      borgmatic/commands/arguments.py
  2. 7 0
      tests/integration/commands/test_arguments.py

+ 4 - 0
borgmatic/commands/arguments.py

@@ -878,6 +878,10 @@ def parse_arguments(*unparsed_arguments):
         raise ValueError(
             'With the create action, only one of --list (--files) and --progress flags can be used.'
         )
+    if 'create' in arguments and arguments['create'].list_files and arguments['create'].json:
+        raise ValueError(
+            'With the create action, only one of --list (--files) and --json flags can be used.'
+        )
 
     if (
         ('list' in arguments and 'rinfo' in arguments and arguments['list'].json)

+ 7 - 0
tests/integration/commands/test_arguments.py

@@ -422,6 +422,13 @@ def test_parse_arguments_disallows_list_with_progress_for_create_action():
         module.parse_arguments('create', '--list', '--progress')
 
 
+def test_parse_arguments_disallows_list_with_json_for_create_action():
+    flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
+
+    with pytest.raises(ValueError):
+        module.parse_arguments('create', '--list', '--json')
+
+
 def test_parse_arguments_allows_json_with_list_or_info():
     flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])