Пример #1
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))
Пример #2
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))
Пример #3
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))
Пример #4
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))
Пример #5
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))
Пример #6
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))
Пример #7
0
 def test_decompress_negtive_wrong_file_format(self):
     """Test wrong target format"""
     with self.assertRaises(Exception):
         archive.decompress(self.wrong_format_file, 'bz2')
Пример #8
0
 def test_decompress_negtive_wrong_compress_format(self):
     """Test wrong decompress format"""
     with self.assertRaises(ValueError):
         archive.decompress(self.relative_file, 'bzip2')
Пример #9
0
 def test_decompress_negtive_path_is_dir(self):
     """Test decompress target is a directory"""
     with self.assertRaises(OSError):
         archive.decompress(self.relative_dir, 'bz2')
Пример #10
0
 def test_decompress_negtive_file_not_exist(self):
     """Test decompress target does not exist"""
     with self.assertRaises(OSError):
         archive.decompress('tresa.py', 'bz2')
Пример #11
0
 def test_decompress_negtive_parameters_are_empty(self):
     """Test if two parameters are both empty string"""
     with self.assertRaises(OSError):
         archive.decompress('', '')
Пример #12
0
 def test_decompress_negtive_file_path_is_required(self):
     """Test if the first parameter: file to be uncompressed is empty"""
     with self.assertRaises(OSError):
         archive.decompress('', 'bz')