Browse Source

Fix line wrapping / code style (#837).

Dan Helfman 2 tháng trước cách đây
mục cha
commit
23efbb8df3

+ 8 - 7
borgmatic/config/schema.yaml

@@ -1729,20 +1729,21 @@ properties:
                 mongodump_command:
                 mongodump_command:
                     type: string
                     type: string
                     description: |
                     description: |
-                        Command to use instead of "mongodump". This can be used to
-                        run a specific mongodump version (e.g., one inside a
+                        Command to use instead of "mongodump". This can be used
+                        to run a specific mongodump version (e.g., one inside a
                         running container). If you run it from within a
                         running container). If you run it from within a
                         container, make sure to mount the path in the
                         container, make sure to mount the path in the
                         "user_runtime_directory" option from the host into the
                         "user_runtime_directory" option from the host into the
-                        container at the same location.  Defaults to "mongodump".
+                        container at the same location.  Defaults to
+                        "mongodump".
                     example: docker exec mongodb_container mongodump
                     example: docker exec mongodb_container mongodump
                 mongorestore_command:
                 mongorestore_command:
                     type: string
                     type: string
                     description: |
                     description: |
-                        Command to run when restoring a database instead
-                        of "mongorestore". This can be used to run a specific 
-                        mongorestore version (e.g., one inside a running container). 
-                        Defaults to "mongorestore".
+                        Command to run when restoring a database instead of
+                        "mongorestore". This can be used to run a specific
+                        mongorestore version (e.g., one inside a running
+                        container). Defaults to "mongorestore".
                     example: docker exec mongodb_container mongorestore
                     example: docker exec mongodb_container mongorestore
         description: |
         description: |
             List of one or more MongoDB databases to dump before creating a
             List of one or more MongoDB databases to dump before creating a

+ 12 - 8
tests/unit/hooks/data_source/test_mongodb.py

@@ -681,6 +681,8 @@ def test_restore_data_source_dump_without_extract_process_restores_from_disk():
         },
         },
         borgmatic_runtime_directory='/run/borgmatic',
         borgmatic_runtime_directory='/run/borgmatic',
     )
     )
+
+
 def test_dump_data_sources_uses_custom_mongodump_command():
 def test_dump_data_sources_uses_custom_mongodump_command():
     flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
     flexmock(module.borgmatic.hooks.command).should_receive('Before_after_hooks').and_return(
         flexmock()
         flexmock()
@@ -714,7 +716,8 @@ def test_dump_data_sources_uses_custom_mongodump_command():
         patterns=[],
         patterns=[],
         dry_run=False,
         dry_run=False,
     ) == [process]
     ) == [process]
-    
+
+
 def test_build_dump_command_prevents_shell_injection():
 def test_build_dump_command_prevents_shell_injection():
     database = {
     database = {
         'name': 'testdb; rm -rf /',  # Malicious input
         'name': 'testdb; rm -rf /',  # Malicious input
@@ -733,8 +736,11 @@ def test_build_dump_command_prevents_shell_injection():
 
 
     # Ensure the malicious input is properly escaped and does not execute
     # Ensure the malicious input is properly escaped and does not execute
     assert 'testdb; rm -rf /' not in command
     assert 'testdb; rm -rf /' not in command
-    assert any('testdb' in part for part in command)  # Check if 'testdb' is in any part of the tuple
-    
+    assert any(
+        'testdb' in part for part in command
+    )  # Check if 'testdb' is in any part of the tuple
+
+
 def test_restore_data_source_dump_uses_custom_mongorestore_command():
 def test_restore_data_source_dump_uses_custom_mongorestore_command():
     hook_config = [
     hook_config = [
         {
         {
@@ -777,7 +783,8 @@ def test_restore_data_source_dump_uses_custom_mongorestore_command():
         },
         },
         borgmatic_runtime_directory='/run/borgmatic',
         borgmatic_runtime_directory='/run/borgmatic',
     )
     )
-    
+
+
 def test_build_restore_command_prevents_shell_injection():
 def test_build_restore_command_prevents_shell_injection():
     database = {
     database = {
         'name': 'testdb; rm -rf /',  # Malicious input
         'name': 'testdb; rm -rf /',  # Malicious input
@@ -801,11 +808,8 @@ def test_build_restore_command_prevents_shell_injection():
     command = module.build_restore_command(
     command = module.build_restore_command(
         extract_process, database, config, dump_filename, connection_params
         extract_process, database, config, dump_filename, connection_params
     )
     )
-    
+
     # print(command)
     # print(command)
     # Ensure the malicious input is properly escaped and does not execute
     # Ensure the malicious input is properly escaped and does not execute
     assert 'rm -rf /' not in command
     assert 'rm -rf /' not in command
     assert ';' not in command
     assert ';' not in command
-
-
-