def test09_build(self): """Test write method.""" tempdir = tempfile.mkdtemp(prefix='test_write') oo = Object() self.assertRaises(ObjectException, oo.build, srcdir='fixtures/1.0/content/spec-ex-full') oo.id = 'uri:firkin' objdir = os.path.join(tempdir, '1') oo.build(srcdir='fixtures/1.0/content/spec-ex-full', metadata=VersionMetadata(), objdir=objdir) self.assertEqual( set(os.listdir(objdir)), set([ '0=ocfl_object_1.0', 'inventory.json', 'inventory.json.sha512', 'v1', 'v2', 'v3' ])) # If objdir is None the output is just a log saying what would have been written log_io = io.StringIO() oo.log.addHandler(logging.StreamHandler(log_io)) oo.build(srcdir='fixtures/1.0/content/spec-ex-full', metadata=VersionMetadata(), objdir=None) log_out = log_io.getvalue() self.assertIn('### Inventory for v1', log_out) self.assertIn('"id": "uri:firkin",', log_out) self.assertIn('### Inventory for v2', log_out) self.assertIn('### Inventory for v3', log_out)
def test09_build(self): """Test write method.""" tempdir = tempfile.mkdtemp(prefix='test_write') oo = Object() self.assertRaises(ObjectException, oo.build, srcdir='fixtures/1.0/content/spec-ex-full') oo.identifier = 'uri:firkin' objdir = os.path.join(tempdir, '1') oo.build(srcdir='fixtures/1.0/content/spec-ex-full', metadata=VersionMetadata(), objdir=objdir) self.assertEqual( set(os.listdir(objdir)), set([ '0=ocfl_object_1.0', 'inventory.json', 'inventory.json.sha512', 'v1', 'v2', 'v3' ]))