Ejemplo n.º 1
0
 def test_decopmression_wrong_password(self):
     compression.compress_recursively(
         _CASE_PATH, _CASE_SRC, _CASE_DEST, password="******", encryption_method=compression.ENCRYPTION_AES_256
     )
     # Wrong password
     self.assertRaises(
         compression.CompressionWrongPassword,
         compression.decompress_recursively,
         _CASE_PATH,
         _CASE_DEST,
         _CASE_OUT,
         _CASE_TMP,
         password="******",
     )
Ejemplo n.º 2
0
 def test_copmression(self):
     compression.compress_recursively(
         _CASE_PATH, _CASE_SRC, _CASE_DEST, password=None, encryption_method=compression.ENCRYPTION_AES_256
     )
     src = os.path.join(_CASE_SRC, _CASE_PATH)
     dest = os.path.join(_CASE_DEST, _CASE_PATH)
     for path, dirs, files in os.walk(src):
         rel_path = os.path.relpath(path, src)
         dest_path = os.path.join(dest, rel_path)
         for f in files:
             self.assertTrue(
                 "Compressed file %s is not found for %s"
                 % (os.path.join(dest_path, compression.get_compressed_filename(f)), os.path.join(path, f)),
                 os.path.exists(os.path.join(dest_path, compression.get_compressed_filename(f))),
             )
Ejemplo n.º 3
0
 def test_decopmression_correct_password(self):
     compression.compress_recursively(
         _CASE_PATH, _CASE_SRC, _CASE_DEST, password="******", encryption_method=compression.ENCRYPTION_AES_256
     )
     compression.decompress_recursively(_CASE_PATH, _CASE_DEST, _CASE_OUT, _CASE_TMP, password="******")
     src = os.path.join(_CASE_SRC, _CASE_PATH)
     out = os.path.join(_CASE_OUT, _CASE_PATH)
     for path, dirs, files in os.walk(src):
         rel_path = os.path.relpath(path, src)
         out_path = os.path.join(out, rel_path)
         for f in files:
             self.assertTrue(
                 "Decompressed file %s is not found for %s" % (os.path.join(out_path, f), os.path.join(path, f)),
                 os.path.exists(os.path.join(out_path, f)),
             )
             self.assertTrue(
                 "Decompressed file %s is not identical to %s" % (os.path.join(out_path, f), os.path.join(path, f)),
                 filecmp.cmp(os.path.join(path, f), os.path.join(out_path, f)),
             )