Esempio n. 1
0
    def test_write_multi_folder_multi_files_multi_cabs(self):
        """
        Multi folder - Multi files - Multi Cabs
        """

        folder1 = CABFolderUnit(name="folder1", filename_list=[r"./TestsFiles/pe101.jpg", r"./TestsFiles/andy_C.mp3"])
        folder2 = CABFolderUnit(name="folder2", filename_list=[r"./TestsFiles/super_saiyajin.jpg"])

        manager = CABManager()
        manager.create_cab(cab_folders=[folder1, folder2], cab_name="my_cab_[x].cab", cab_size=(1474*1024))

        manager.flush_cabset_to_disk(output_dir=r"./TestsFiles/")

        # Perform in memory extraction
        extractor = CabExtractor()
        extractor.extract(r"./TestsFiles/my_cab_0.cab")

        # Check hashes
        extracted_hash_set = set([v for k, v in extractor.get_hashes_of_files().items()])
        files_hash_set = set([v for k, v in Utils.get_hashes_of_files(folder1.filename_list + folder2.filename_list).items()])

        # Check hashes
        self.assertEquals(extracted_hash_set, files_hash_set)
        # Cleanup
        os.unlink(r"./TestsFiles/my_cab_0.cab")
        os.unlink(r"./TestsFiles/my_cab_1.cab")
        os.unlink(r"./TestsFiles/my_cab_2.cab")
        os.unlink(r"./TestsFiles/my_cab_3.cab")
Esempio n. 2
0
    def test_write_single_folder_multi_files_single_cab(self):
        """
        Single Folder - Multiple files - Single Cab
        """
        folder1 = CABFolderUnit()
        folder1.name = "folder1"
        folder1.filename_list = [r"./TestsFiles/pe101.jpg",
                                 r"./TestsFiles/andy_C.mp3",
                                 r"./TestsFiles/super_saiyajin.jpg"
                                ]

        manager = CABManager()
        manager.create_cab(cab_folders=[folder1], cab_name="my_cab_[x].cab", cab_size=1474*1024*16)
        manager.flush_cabset_to_disk(output_dir=r"./TestsFiles/")

        # Perform in memory extraction
        extractor = CabExtractor()
        extractor.extract(r"./TestsFiles/my_cab_0.cab")

        # Check hashes
        extracted_hash_set = set([v for k, v in extractor.get_hashes_of_files().items()])
        files_hash_set = set([v for k, v in Utils.get_hashes_of_files(folder1.filename_list).items()])

        self.assertEquals(extracted_hash_set, files_hash_set)
        # Cleanup
        os.unlink(r"./TestsFiles/my_cab_0.cab")