示例#1
0
 def test_restore_raw_quote_vs_unquote(self):
     # Define path to be archived
     filename = tempfile.mktemp(prefix='rdiffweb_test_restore_archiver_')
     try:
         # Run archiver
         with open(filename, 'wb') as f:
             restore(os.path.join(self.path, b'Char ;090 to quote',
                                  b'Data'),
                     restore_as_of=1454448640,
                     dest=f,
                     encoding='utf-8',
                     kind='raw')
         # Check result.
         with open(filename, 'rb') as f:
             self.assertEqual(f.read(), b"Bring me some Data !\n")
         # Run archiver
         with open(filename, 'wb') as f:
             restore(os.path.join(self.path, b'Char Z to quote', b'Data'),
                     restore_as_of=1414921853,
                     dest=f,
                     encoding='utf-8',
                     kind='raw')
         # Check result.
         with open(filename, 'rb') as f:
             self.assertEqual(f.read(), b"Bring me some Data !\n")
     finally:
         os.remove(filename)
示例#2
0
 def test_restore_raw_singlefile(self):
     # Define path to be archived
     filename = tempfile.mktemp(prefix='rdiffweb_test_restore_archiver_')
     try:
         # Run archiver
         with open(filename, 'wb') as f:
             restore(os.path.join(self.path, b'Fichier @ <root>'),
                     restore_as_of=1454448640,
                     dest=f,
                     encoding='utf-8',
                     kind='raw')
         # Check result.
         with open(filename, 'rb') as f:
             self.assertEqual(f.read(), b"Ajout d'info\n")
     finally:
         os.remove(filename)
示例#3
0
 def test_restore_tar_bz2_file(self):
     """
     Check creation of tar.bz2.
     """
     filename = tempfile.mktemp(prefix='rdiffweb_test_restore_archiver_',
                                suffix='.tar.bz2')
     try:
         # Run archiver
         with open(filename, 'wb') as f:
             restore(self.path,
                     restore_as_of=1454448640,
                     dest=f,
                     encoding='utf-8',
                     kind='tar.bz2')
         # Check result.
         self.assertInTar(TAR_EXPECTED, filename)
     finally:
         os.remove(filename)
示例#4
0
 def test_restore_zip_file(self):
     """
     Check creation of a zipfile.
     """
     # Define path to be archived
     filename = tempfile.mktemp(prefix='rdiffweb_test_restore_archiver_',
                                suffix='.zip')
     try:
         # Run archiver
         with open(filename, 'wb') as f:
             restore(self.path,
                     restore_as_of=1454448640,
                     dest=f,
                     encoding='utf-8',
                     kind='zip')
         # Check result.
         self.assertInZip(ZIP_EXPECTED, filename)
     finally:
         os.remove(filename)
示例#5
0
 def test_restore_tar_file_cp1252(self):
     """
     Check if archiver support different encoding.
     """
     filename = tempfile.mktemp(prefix='rdiffweb_test_restore_archiver_',
                                suffix='.tar')
     try:
         # Run archiver
         with open(filename, 'wb') as f:
             restore(self.path,
                     restore_as_of=1454448640,
                     dest=f,
                     encoding='cp1252',
                     kind='tar')
         # Check result.
         expected = {
             "Fichier avec non asci char Évelyne Mère.txt": 18,
         }
         self.assertInTar(expected, filename, equal=False)
     finally:
         os.remove(filename)