コード例 #1
0
    def test_tarSupport(self):
        files_created = 0
        while not (files_created == self.number_of_files):
            path = create_temp_file(file_dir=self.working_dir)
            md5sum = extract_md5(path)
            self.files.append({"path": path, "md5sum" : md5sum})
            files_created += 1

        archive_file = self.create_archive()
        self.extract_archive(archive_file)
        files = os.listdir(self.extract_dir)
        msg = "The number of files in the extract directory does not equal the number of files add to the archive."
        self.assertTrue(len(files) == len(self.files), msg)

        extract_files = []
        for f in files:
            md5sum = extract_md5("%s/%s" % (self.extract_dir, f))
            extract_files.append({"path": "%s/%s" % (self.extract_dir, f), "md5sum" : md5sum})

        for file_dict in self.files:
            for extract_dict in extract_files:
                if (os.path.basename(file_dict["path"]) == os.path.basename(extract_dict["path"])) and \
                   (file_dict["md5sum"] == extract_dict["md5sum"]):
                    extract_files.remove(extract_dict)
                    break
        self.assertTrue(len(extract_files) == 0, "At least one original file's md5sum did not match the extracted file's md5sum")
コード例 #2
0
ファイル: test_tarSupport.py プロジェクト: djw8605/glideinWMS
 def setUp(self):
     self.extract_dir = tempfile.mkdtemp()
     self.working_dir = tempfile.mkdtemp()
     self.number_of_files = 5
     self.files = []
     self.strings = {"string1": "Why did the chicken cross the road?", "string2": "To get to the other side."}
     files_created = 0
     while not (files_created == self.number_of_files):
         path = create_temp_file(file_dir=self.working_dir)
         md5sum = extract_md5(path)
         self.files.append({"path": path, "md5sum": md5sum})
         files_created += 1