예제 #1
0
    def test_tarSupport_file(self):
        archive_file = self.create_archive_file()
        self.extract_archive_file(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"
        )
        # clean up for next test
        for f in files:
            os.remove("%s/%s" % (self.extract_dir, f))
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
    def test_tarSupport_file(self):
        archive_file = self.create_archive_file()
        self.extract_archive_file(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")
        # clean up for next test
        for f in files:
            os.remove("%s/%s" % (self.extract_dir, f))