示例#1
0
 def test_gz_unpack(self):
     """unpack gz file"""
     with self.assertRaises(UnpackError):
         Unpack.dispatch(".gz",
                         file_path=os.path.join(self.path, "gz_error.txt"),
                         save_file=os.path.join(self.path,
                                                "bz2_unpack.sqlite"))
示例#2
0
 def test_error_tar(self):
     """error tar file"""
     with self.assertRaises(IOError):
         Unpack.dispatch(".tar",
                         file_path=os.path.join(self.path, "tar_error.txt"),
                         save_file=os.path.join(self.path,
                                                "bz2_unpack.sqlite"))
示例#3
0
 def test_many_zip_file(self):
     """Multiple compressed files"""
     with self.assertRaises(IOError):
         Unpack.dispatch(".zip",
                         file_path=os.path.join(self.path,
                                                "many-error.zip"),
                         save_file=os.path.join(self.path,
                                                "zip_file.sqlite"))
示例#4
0
    def test_file_path_none(self):
        """unpack xz file"""

        with self.assertRaises(ValueError):
            Unpack.dispatch(".xz",
                            file_path=None,
                            save_file=os.path.join(self.path, "xz.sqlite"))
        with self.assertRaises(ValueError):
            Unpack.dispatch(".xz", file_path=None, save_file=None)
示例#5
0
 def test_mkdir_error(self, mock_makedirs, mock_exists):
     """Folder creation error"""
     mock_exists.return_value = False
     mock_makedirs.side_effect = IOError("")
     with self.assertRaises(IOError):
         Unpack.dispatch(".zip",
                         file_path=os.path.join(self.path, "zip_file.zip"),
                         save_file=os.path.join(self.path,
                                                "zip_file.sqlite"))
示例#6
0
 def test_error_zip_unpack(self):
     """unpack error zip file"""
     file = os.path.join(self.path, "zip_error.txt")
     with open(file, "w", encoding="utf-8") as f:
         f.write("error zip file")
     with self.assertRaises(IOError):
         Unpack.dispatch(".zip",
                         file_path=file,
                         save_file=os.path.join(self.path,
                                                "zip_file.sqlite"))
     if os.path.exists(file):
         os.remove(file)
示例#7
0
    def test_many_tar_file(self):
        """many tar file"""
        with self.assertRaises(IOError):
            Unpack.dispatch(".tar",
                            file_path=os.path.join(self.path,
                                                   "many-tar.tar.gz"),
                            save_file=os.path.join(self.path,
                                                   "zip_file.sqlite"))

        with self.assertRaises(IOError):
            Unpack.dispatch(".tar",
                            file_path=os.path.join(self.path,
                                                   "many-tar.tar.gz"),
                            save_file=os.path.join(self.path,
                                                   "zip_file.sqlite"))
示例#8
0
    def test_zip_unpack(self):
        """unpack zip file"""

        self.assertEqual(
            None,
            Unpack.dispatch(".zip",
                            file_path=os.path.join(self.path, "zip_file.zip"),
                            save_file=os.path.join(self.path,
                                                   "zip_file.sqlite")))
示例#9
0
 def test_dispatch_not_params(self):
     """not params"""
     with self.assertRaises(TypeError):
         Unpack.dispatch(".xz")
示例#10
0
 def test_tar_unpack(self):
     """unpack tar file"""
     Unpack.dispatch(".tar",
                     file_path=os.path.join(self.path, "test_tar.tar.gz"),
                     save_file=os.path.join(self.path, "bz2_unpack.sqlite"))
示例#11
0
 def test_unpack_file_is_none(self):
     """file path is empty"""
     with self.assertRaises(ValueError):
         Unpack.dispatch(".xz", file_path=None, save_file=None)
示例#12
0
 def test_not_support(self):
     """Unsupported compression format"""
     with self.assertRaises(UnpackError):
         Unpack.dispatch(".rar", file_path=None, save_file=None)