| 
					
				 | 
			
			
				@@ -48,16 +48,6 @@ def insert_subprocess_mock(check_call_command, **kwargs): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     subprocess.should_receive('check_call').with_args(check_call_command, **kwargs).once() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def insert_platform_mock(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    flexmock(module.platform).should_receive('node').and_return('host') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-def insert_datetime_mock(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    flexmock(module).datetime = flexmock().should_receive('now').and_return( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        flexmock().should_receive('isoformat').and_return('now').mock 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    ).mock 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_make_exclude_flags_includes_exclude_patterns_filename_when_given(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     exclude_flags = module._make_exclude_flags( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         location_config={'exclude_patterns': ['*.pyc', '/var']}, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -128,15 +118,14 @@ def test_make_exclude_flags_is_empty_when_config_has_no_excludes(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     assert exclude_flags == () 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-CREATE_COMMAND = ('borg', 'create', 'repo::host-now', 'foo', 'bar') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+DEFAULT_ARCHIVE_NAME = '{hostname}-{now:%Y-%m-%dT%H:%M:%S.%f}' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CREATE_COMMAND = ('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo', 'bar') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_create_archive_should_call_borg_with_parameters(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     insert_subprocess_mock(CREATE_COMMAND) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verbosity=None, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -155,8 +144,6 @@ def test_create_archive_with_exclude_patterns_should_call_borg_with_excludes(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(flexmock(name='/tmp/excludes')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(exclude_flags) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     insert_subprocess_mock(CREATE_COMMAND + exclude_flags) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verbosity=None, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -174,8 +161,6 @@ def test_create_archive_with_verbosity_some_should_call_borg_with_info_parameter 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     insert_subprocess_mock(CREATE_COMMAND + ('--info', '--stats',)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verbosity=VERBOSITY_SOME, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -193,8 +178,6 @@ def test_create_archive_with_verbosity_lots_should_call_borg_with_debug_paramete 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     insert_subprocess_mock(CREATE_COMMAND + ('--debug', '--list', '--stats')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verbosity=VERBOSITY_LOTS, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -212,8 +195,6 @@ def test_create_archive_with_compression_should_call_borg_with_compression_param 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     insert_subprocess_mock(CREATE_COMMAND + ('--compression', 'rle')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verbosity=None, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -231,8 +212,6 @@ def test_create_archive_with_one_file_system_should_call_borg_with_one_file_syst 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     insert_subprocess_mock(CREATE_COMMAND + ('--one-file-system',)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verbosity=None, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -251,8 +230,6 @@ def test_create_archive_with_remote_path_should_call_borg_with_remote_path_param 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     insert_subprocess_mock(CREATE_COMMAND + ('--remote-path', 'borg1')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verbosity=None, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -271,8 +248,6 @@ def test_create_archive_with_umask_should_call_borg_with_umask_parameters(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     insert_subprocess_mock(CREATE_COMMAND + ('--umask', '740')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         verbosity=None, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -289,9 +264,7 @@ def test_create_archive_with_umask_should_call_borg_with_umask_parameters(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_create_archive_with_source_directories_glob_expands(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_subprocess_mock(('borg', 'create', 'repo::host-now', 'foo', 'food')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    insert_subprocess_mock(('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo', 'food')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module.glob).should_receive('glob').with_args('foo*').and_return(['foo', 'food']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -309,9 +282,7 @@ def test_create_archive_with_source_directories_glob_expands(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_create_archive_with_non_matching_source_directories_glob_passes_through(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_subprocess_mock(('borg', 'create', 'repo::host-now', 'foo*')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    insert_subprocess_mock(('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo*')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module.glob).should_receive('glob').with_args('foo*').and_return([]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -329,9 +300,7 @@ def test_create_archive_with_non_matching_source_directories_glob_passes_through 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 def test_create_archive_with_glob_should_call_borg_with_expanded_directories(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_subprocess_mock(('borg', 'create', 'repo::host-now', 'foo', 'food')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_platform_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    insert_datetime_mock() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    insert_subprocess_mock(('borg', 'create', 'repo::{}'.format(DEFAULT_ARCHIVE_NAME), 'foo', 'food')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     flexmock(module.glob).should_receive('glob').with_args('foo*').and_return(['foo', 'food']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     module.create_archive( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -344,3 +313,41 @@ def test_create_archive_with_glob_should_call_borg_with_expanded_directories(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         storage_config={}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def test_create_archive_with_archive_name_format_without_placeholders(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    insert_subprocess_mock(('borg', 'create', 'repo::ARCHIVE_NAME', 'foo', 'bar')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        verbosity=None, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        repository='repo', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        location_config={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'source_directories': ['foo', 'bar'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'repositories': ['repo'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'exclude_patterns': None, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        storage_config={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'archive_name_format': 'ARCHIVE_NAME', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def test_create_archive_with_archive_name_format_accepts_borg_placeholders(): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    flexmock(module).should_receive('_write_exclude_file').and_return(None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    flexmock(module).should_receive('_make_exclude_flags').and_return(()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    insert_subprocess_mock(('borg', 'create', 'repo::Documents_{hostname}-{now}', 'foo', 'bar')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    module.create_archive( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        verbosity=None, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        repository='repo', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        location_config={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'source_directories': ['foo', 'bar'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'repositories': ['repo'], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'exclude_patterns': None, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        storage_config={ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'archive_name_format': 'Documents_{hostname}-{now}', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ) 
			 |