add extract volume test - not implemented yet (test driven development)
authorEduardo Robles Elvira <edulix@wadobo.com>
Tue, 18 Jun 2013 10:40:51 +0000 (12:40 +0200)
committerEduardo Robles Elvira <edulix@wadobo.com>
Tue, 18 Jun 2013 10:42:48 +0000 (12:42 +0200)
testing/test_multivol.py

index 08b1f1e..254f111 100644 (file)
@@ -157,3 +157,41 @@ class MultivolTest(unittest.TestCase):
         for key, value in hash.iteritems():
             assert os.path.exists(key)
             assert value == self.md5sum(key)
+
+    def test_volume_extract1(self):
+        '''
+        Create a volume and extract it
+        '''
+        # create the content of the file to compress and hash it
+        self.create_random_file("big", 50000)
+        hash = self.md5sum("big")
+
+        # create the tar file with volumes
+        tarobj = TarFile.open("sample.tar",
+                              mode="w",
+                              max_volume_size=30000,
+                              new_volume_handler=new_volume_handler)
+        tarobj.add("big")
+        tarobj.close()
+
+        # check that the tar volumes were correctly created
+        assert os.path.exists("sample.tar")
+        assert os.path.exists("sample.tar.1")
+        assert not os.path.exists("sample.tar.2")
+
+        os.unlink("big")
+        assert not os.path.exists("big")
+
+        # extract and check output
+        tarobj = TarFile.open("sample.tar",
+                              mode="w",
+                              max_volume_size=30000,
+                              new_volume_handler=new_volume_handler)
+        tarobj.extractall()
+        tarobj.close()
+        assert os.path.exists("big")
+        assert hash == self.md5sum("big")
+
+    # TODO: test_volume_extract2
+    # TODO: test_volume_extract3
+    # TODO: test creating a volume with gnu tar cmd and extract it with our tool
\ No newline at end of file