예제 #1
0
파일: test_object.py 프로젝트: kbg/ocfl-py
 def test11_update(self):
     """Test update method."""
     tempdir = tempfile.mkdtemp(prefix='test_update')
     oo = Object()
     # First create and object
     oo.id = 'uri:wumpus'
     objdir = os.path.join(tempdir, '1')
     oo.digest_algorithm = 'sha256'
     oo.create(srcdir='fixtures/1.0/content/spec-ex-minimal/v1',
               metadata=VersionMetadata(),
               objdir=objdir)
     self.assertEqual(
         set(os.listdir(objdir)),
         set([
             '0=ocfl_object_1.0', 'inventory.json', 'inventory.json.sha256',
             'v1'
         ]))
     # Now update
     oo.digest_algorithm = 'sha512'
     oo.update(objdir=objdir, metadata=VersionMetadata())
     self.assertEqual(
         set(os.listdir(objdir)),
         set([
             '0=ocfl_object_1.0', 'inventory.json', 'inventory.json.sha512',
             'v1', 'v2'
         ]))
예제 #2
0
 def test10_create(self):
     """Test create method."""
     tempdir = tempfile.mkdtemp(prefix='test_create')
     oo = Object()
     self.assertRaises(ObjectException, oo.create, srcdir='fixtures/1.0/content/spec-ex-full/v1')
     oo.id = 'uri:kliderkin'
     objdir = os.path.join(tempdir, '1')
     oo.create(srcdir='fixtures/1.0/content/spec-ex-full/v1',
               metadata=VersionMetadata(),
               objdir=objdir)
     self.assertEqual(set(os.listdir(objdir)),
                      set(['0=ocfl_object_1.0',
                           'inventory.json', 'inventory.json.sha512',
                           'v1']))