assert os.path.exists("big")
assert hash == self.md5sum("big")
- def test_multiple_files_volume(self):
+ def test_multiple_files_volumes(self):
# create the content of the file to compress and hash it
# create sample data
assert hash == self.md5sum("big")
- def test_multiple_files_volume(self):
- # create the content of the file to compress and hash it
+ def test_multiple_files_volumes_extract(self):
+ # creates a multivolume tar file with multiple files and extracts it
# create sample data
hash = dict()
new_volume_handler=new_volume_handler)
tarobj.extractall()
tarobj.close()
+
+ for key, value in hash.iteritems():
+ assert os.path.exists(key)
+ assert value == self.md5sum(key)
+
+ def test_multiple_files_extract(self):
+ # creates a simple tar file with multiple files and extracts it
+
+ # create sample data
+ hash = dict()
+ self.create_random_file("big", 50000)
+ hash["big"] = self.md5sum("big")
+ self.create_random_file("small", 100)
+ hash["small"] = self.md5sum("small")
+ self.create_random_file("small2", 354)
+ hash["small2"] = self.md5sum("small2")
+
+ # create the tar file with volumes
+ tarobj = TarFile.open("sample.tar",
+ mode="w")
+ tarobj.add("big")
+ tarobj.add("small")
+ tarobj.add("small2")
+ tarobj.close()
+
+ # check that the tar volumes were correctly created
+ assert os.path.exists("sample.tar")
+ assert not os.path.exists("sample.tar.1")
+
+ os.unlink("big")
+ os.unlink("small")
+ os.unlink("small2")
+
+ # extract and check output
+ tarobj = TarFile.open("sample.tar",
+ mode="r",
+ new_volume_handler=new_volume_handler)
+ tarobj.extractall()
+ tarobj.close()
+
for key, value in hash.iteritems():
assert os.path.exists(key)
assert value == self.md5sum(key)
\ No newline at end of file