def test_extract(self): """Test extract method.""" tempdir = tempfile.mkdtemp(prefix='test_extract') oo = Object() dstdir = os.path.join(tempdir, 'vvv1') oo.extract('fixtures/1.0/good-objects/minimal_one_version_one_file', 'v1', dstdir) self.assertEqual(os.listdir(tempdir), ['vvv1']) self.assertEqual(os.listdir(dstdir), ['a_file.txt']) # Specify "head" and expect v3 oo = Object() dstdir = os.path.join(tempdir, 'vvv2') oo.extract('fixtures/1.0/good-objects/spec-ex-full', 'head', dstdir) self.assertEqual(set(os.listdir(dstdir)), set(["foo", "empty2.txt", "image.tiff"])) # Error, no v4 self.assertRaises(ObjectException, oo.extract, 'fixtures/1.0/good-objects/spec-ex-full', 'v4', dstdir) # Error, dstdir already exists self.assertRaises(ObjectException, oo.extract, 'fixtures/1.0/good-objects/spec-ex-full', 'head', tempdir) # Error, parent dir does not exist dstdir = os.path.join(tempdir, 'intermediate/vvv3') self.assertRaises(ObjectException, oo.extract, 'fixtures/1.0/good-objects/spec-ex-full', 'head', dstdir)
def test16_extract(self): """Test extract method.""" tempdir = tempfile.mkdtemp(prefix='test_extract') oo = Object() dstdir = os.path.join(tempdir, 'vvv1') oo.extract('fixtures/1.0/good-objects/minimal_one_version_one_file', 'v1', dstdir) self.assertEqual(os.listdir(tempdir), ['vvv1']) self.assertEqual(os.listdir(dstdir), ['a_file.txt'])