Переглянути джерело

Merge branch 'main' into config-command-line.

Dan Helfman 2 місяців тому
батько
коміт
92de539bf9
2 змінених файлів з 13 додано та 12 видалено
  1. 1 3
      borgmatic/commands/borgmatic.py
  2. 12 9
      tests/unit/commands/test_borgmatic.py

+ 1 - 3
borgmatic/commands/borgmatic.py

@@ -965,9 +965,7 @@ def check_and_show_help_on_no_args(configs):
     default backup behavior.
     default backup behavior.
     """
     """
     if len(sys.argv) == 1:  # No arguments provided
     if len(sys.argv) == 1:  # No arguments provided
-        default_actions = any(
-            config.get('default_actions', True) for config in configs.values()
-        )
+        default_actions = any(config.get('default_actions', True) for config in configs.values())
         if not default_actions:
         if not default_actions:
             parse_arguments('--help')
             parse_arguments('--help')
             sys.exit(0)
             sys.exit(0)

+ 12 - 9
tests/unit/commands/test_borgmatic.py

@@ -2125,6 +2125,8 @@ def test_collect_configuration_run_summary_logs_outputs_merged_json_results():
             arguments=arguments,
             arguments=arguments,
         )
         )
     )
     )
+
+
 def test_check_and_show_help_on_no_args_shows_help_when_no_args_and_default_actions_false():
 def test_check_and_show_help_on_no_args_shows_help_when_no_args_and_default_actions_false():
     flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
     flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
     flexmock(module).should_receive('parse_arguments').with_args('--help').once()
     flexmock(module).should_receive('parse_arguments').with_args('--help').once()
@@ -2145,33 +2147,34 @@ def test_check_and_show_help_on_no_args_does_not_show_help_when_args_provided():
     flexmock(module.sys).should_receive('exit').never()
     flexmock(module.sys).should_receive('exit').never()
     module.check_and_show_help_on_no_args({'test.yaml': {'default_actions': False}})
     module.check_and_show_help_on_no_args({'test.yaml': {'default_actions': False}})
 
 
+
 def test_check_and_show_help_on_no_args_with_no_default_actions_in_all_configs():
 def test_check_and_show_help_on_no_args_with_no_default_actions_in_all_configs():
     flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
     flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
-    
+
     # Both configs have default_actions set to False, so help should be shown
     # Both configs have default_actions set to False, so help should be shown
     configs = {
     configs = {
         'config1.yaml': {'default_actions': False},
         'config1.yaml': {'default_actions': False},
-        'config2.yaml': {'default_actions': False}
+        'config2.yaml': {'default_actions': False},
     }
     }
-    
+
     # Expect help to be shown
     # Expect help to be shown
     flexmock(module).should_receive('parse_arguments').with_args('--help').once()
     flexmock(module).should_receive('parse_arguments').with_args('--help').once()
     flexmock(module.sys).should_receive('exit').with_args(0).once()
     flexmock(module.sys).should_receive('exit').with_args(0).once()
-    
+
     module.check_and_show_help_on_no_args(configs)
     module.check_and_show_help_on_no_args(configs)
 
 
+
 def test_check_and_show_help_on_no_args_with_conflicting_configs():
 def test_check_and_show_help_on_no_args_with_conflicting_configs():
     flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
     flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
-    
+
     # Simulate two config files with conflicting 'default_actions' values
     # Simulate two config files with conflicting 'default_actions' values
     configs = {
     configs = {
         'config1.yaml': {'default_actions': True},
         'config1.yaml': {'default_actions': True},
-        'config2.yaml': {'default_actions': False}
+        'config2.yaml': {'default_actions': False},
     }
     }
-    
+
     # Expect help not to be shown because at least one config enables default actions
     # Expect help not to be shown because at least one config enables default actions
     flexmock(module).should_receive('parse_arguments').never()
     flexmock(module).should_receive('parse_arguments').never()
     flexmock(module.sys).should_receive('exit').never()
     flexmock(module.sys).should_receive('exit').never()
-    
-    module.check_and_show_help_on_no_args(configs)
 
 
+    module.check_and_show_help_on_no_args(configs)