Ejemplo n.º 1
0
 def test_compress_bz2(self):
     """Test compress format: bz2"""
     for file_item in self.files:
         output_name = archive.compress(file_item, 'bz2')
         self.assertEqual('%s.bz2' % file_item, output_name)
         self.assertTrue(os.path.exists(output_name))
         os.remove(output_name)
Ejemplo n.º 2
0
 def _test_compress_lzo(self):
     """Test compress format: lzo"""
     for file_item in self.files:
         output_name = archive.compress(file_item, 'lzo')
         self.assertEqual('%s.lzo' % file_item, output_name)
         self.assertTrue(os.path.exists(output_name))
         os.remove(output_name)
Ejemplo n.º 3
0
 def _test_compress_lzo(self):
     """Test compress format: lzo"""
     for file_item in self.files:
         output_name = archive.compress(file_item, 'lzo')
         self.assertEqual('%s.lzo' % file_item, output_name)
         self.assertTrue(os.path.exists(output_name))
         os.remove(output_name)
Ejemplo n.º 4
0
 def test_compress_bz2(self):
     """Test compress format: bz2"""
     for file_item in self.files:
         output_name = archive.compress(file_item, 'bz2')
         self.assertEqual('%s.bz2' % file_item, output_name)
         self.assertTrue(os.path.exists(output_name))
         os.remove(output_name)
Ejemplo n.º 5
0
 def test_decompress_compress_format_is_empty(self):
     """Test if the second parameter: compress format is empty string"""
     output_name = archive.compress(self.relative_file, 'gz')
     self.assertEqual('%s.gz' % self.relative_file, output_name)
     self.assertTrue(os.path.exists(output_name))
     self.assertFalse(os.path.exists(self.relative_file))
     archive.decompress(output_name, '')
     self.assertTrue(os.path.exists(self.relative_file))
Ejemplo n.º 6
0
 def test_decompress_compress_format_is_empty(self):
     """Test if the second parameter: compress format is empty string"""
     output_name = archive.compress(self.relative_file, 'gz')
     self.assertEqual('%s.gz' % self.relative_file, output_name)
     self.assertTrue(os.path.exists(output_name))
     self.assertFalse(os.path.exists(self.relative_file))
     archive.decompress(output_name, '')
     self.assertTrue(os.path.exists(self.relative_file))
Ejemplo n.º 7
0
 def _test_decompress_lzo_no_compress_format(self):
     """Test decompress
         Format: lzo
         one parameters is given, only target file"""
     for file_item in self.files:
         output_name = archive.compress(file_item, 'lzo')
         self.assertEqual('%s.lzo' % file_item, output_name)
         self.assertTrue(os.path.exists(output_name))
         self.assertFalse(os.path.exists(file_item))
         archive.decompress(output_name)
         self.assertTrue(os.path.exists(file_item))
Ejemplo n.º 8
0
 def _test_decompress_lzo_no_compress_format(self):
     """Test decompress
         Format: lzo
         one parameters is given, only target file"""
     for file_item in self.files:
         output_name = archive.compress(file_item, 'lzo')
         self.assertEqual('%s.lzo' % file_item, output_name)
         self.assertTrue(os.path.exists(output_name))
         self.assertFalse(os.path.exists(file_item))
         archive.decompress(output_name)
         self.assertTrue(os.path.exists(file_item))
Ejemplo n.º 9
0
 def _test_decompress_lzo(self):
     """Test decompress
         Format: lzo
         both two parameters are given, one is target file,
         the other is corresponding compress format"""
     for file_item in self.files:
         output_name = archive.compress(file_item, 'lzo')
         self.assertEqual('%s.lzo' % file_item, output_name)
         self.assertTrue(os.path.exists(output_name))
         self.assertFalse(os.path.exists(file_item))
         archive.decompress(output_name, 'lzo')
         self.assertTrue(os.path.exists(file_item))
Ejemplo n.º 10
0
 def _test_decompress_lzo(self):
     """Test decompress
         Format: lzo
         both two parameters are given, one is target file,
         the other is corresponding compress format"""
     for file_item in self.files:
         output_name = archive.compress(file_item, 'lzo')
         self.assertEqual('%s.lzo' % file_item, output_name)
         self.assertTrue(os.path.exists(output_name))
         self.assertFalse(os.path.exists(file_item))
         archive.decompress(output_name, 'lzo')
         self.assertTrue(os.path.exists(file_item))
Ejemplo n.º 11
0
 def test_compress_negtive_wrong_compress_format(self):
     """Test wrong compress format"""
     with self.assertRaises(ValueError):
         archive.compress(self.relative_file, 'bzip2')
Ejemplo n.º 12
0
 def test_compress_negtive_file_is_dir(self):
     """Test target is one direcoty, which is not supported"""
     with self.assertRaises(OSError):
         archive.compress(self.relative_dir, 'bz2')
Ejemplo n.º 13
0
 def test_compress_negtive_file_not_exist(self):
     """Test target file does not exist"""
     with self.assertRaises(OSError):
         archive.compress('a.py', 'bz2')
Ejemplo n.º 14
0
 def test_compress_negtive_parameters_are_all_required(self):
     """Test if two parameters are both empty"""
     with self.assertRaises(OSError):
         archive.compress('', '')
Ejemplo n.º 15
0
 def test_compress_negtive_compress_format_is_required(self):
     """Test if the second parameter: compress format is empty"""
     with self.assertRaises(ValueError):
         archive.compress(self.relative_file, '')
Ejemplo n.º 16
0
 def test_compress_negtive_file_path_is_required(self):
     """Test if the first parameter: file path is empty"""
     with self.assertRaises(OSError):
         archive.compress('', 'bz2')