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))
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))
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))
def test_decompress_negtive_wrong_file_format(self): """Test wrong target format""" with self.assertRaises(Exception): archive.decompress(self.wrong_format_file, 'bz2')
def test_decompress_negtive_wrong_compress_format(self): """Test wrong decompress format""" with self.assertRaises(ValueError): archive.decompress(self.relative_file, 'bzip2')
def test_decompress_negtive_path_is_dir(self): """Test decompress target is a directory""" with self.assertRaises(OSError): archive.decompress(self.relative_dir, 'bz2')
def test_decompress_negtive_file_not_exist(self): """Test decompress target does not exist""" with self.assertRaises(OSError): archive.decompress('tresa.py', 'bz2')
def test_decompress_negtive_parameters_are_empty(self): """Test if two parameters are both empty string""" with self.assertRaises(OSError): archive.decompress('', '')
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')