| 
					
				 | 
			
			
				@@ -11,7 +11,7 @@ try: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 except ImportError: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     attic = None 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 pytestmark = pytest.mark.skipif(attic is None, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                reason = 'cannot find an attic install') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                reason='cannot find an attic install') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from ..converter import AtticRepositoryConverter, AtticKeyfileKey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from ..helpers import get_keys_dir 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -19,17 +19,18 @@ from ..key import KeyfileKey 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from ..repository import Repository, MAGIC 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 from . import BaseTestCase 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class ConversionTestCase(BaseTestCase): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    def open(self, path, repo_type  = Repository, create=False): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return repo_type(os.path.join(path, 'repository'), create = create) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    def open(self, path, repo_type=Repository, create=False): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return repo_type(os.path.join(path, 'repository'), create=create) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def setUp(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.tmppath = tempfile.mkdtemp() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.attic_repo = self.open(self.tmppath, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    repo_type = attic.repository.Repository, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    create = True) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        # throw some stuff in that repo, copied from `RepositoryTestCase.test1`_ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    repo_type=attic.repository.Repository, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    create=True) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # throw some stuff in that repo, copied from `RepositoryTestCase.test1` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for x in range(100): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             self.attic_repo.put(('%-32d' % x).encode('ascii'), b'SOMEDATA') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         self.attic_repo.close() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -39,7 +40,8 @@ class ConversionTestCase(BaseTestCase): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def repo_valid(self,): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         repository = self.open(self.tmppath) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        state = repository.check() # can't check raises() because check() handles the error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        # can't check raises() because check() handles the error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        state = repository.check() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         repository.close() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return state 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -47,12 +49,13 @@ class ConversionTestCase(BaseTestCase): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # check should fail because of magic number 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         assert not self.repo_valid() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         print("opening attic repository with borg and converting") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        repo = self.open(self.tmppath, repo_type = AtticRepositoryConverter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        segments = [ filename for i, filename in repo.io.segment_iterator() ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        repo = self.open(self.tmppath, repo_type=AtticRepositoryConverter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        segments = [filename for i, filename in repo.io.segment_iterator()] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         repo.close() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         repo.convert_segments(segments, dryrun=False) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         assert self.repo_valid() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 class EncryptedConversionTestCase(ConversionTestCase): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     class MockArgs: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         def __init__(self, path): 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -70,10 +73,12 @@ class EncryptedConversionTestCase(ConversionTestCase): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # about anyways. in real runs, the original key will be retained. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         os.environ['BORG_KEYS_DIR'] = self.tmppath 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         os.environ['ATTIC_PASSPHRASE'] = 'test' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        self.key = attic.key.KeyfileKey.create(self.attic_repo, self.MockArgs(self.tmppath)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        self.key = attic.key.KeyfileKey.create(self.attic_repo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                               self.MockArgs(self.tmppath)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     def test_keys(self): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        repository = self.open(self.tmppath, repo_type = AtticRepositoryConverter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        repository = self.open(self.tmppath, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                               repo_type=AtticRepositoryConverter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         keyfile = AtticKeyfileKey.find_key_file(repository) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         AtticRepositoryConverter.convert_keyfiles(keyfile, dryrun=False) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -87,8 +92,9 @@ class EncryptedConversionTestCase(ConversionTestCase): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # check should fail because of magic number 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         assert not self.repo_valid() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         print("opening attic repository with borg and converting") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        repo = self.open(self.tmppath, repo_type=AtticRepositoryConverter) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         with pytest.raises(NotImplementedError): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            self.open(self.tmppath, repo_type = AtticRepositoryConverter).convert(dryrun=False) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            repo.convert(dryrun=False) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         # check that the new keyfile is alright 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         keyfile = os.path.join(get_keys_dir(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                os.path.basename(self.key.path)) 
			 |