Browse Source

add overlay support

main
John-Mark Gurney 5 years ago
parent
commit
a892b7273a
1 changed files with 37 additions and 1 deletions
  1. +37
    -1
      ui/cli.py

+ 37
- 1
ui/cli.py View File

@@ -45,6 +45,7 @@ class MDBase(object):
'modified': datetime.datetime.utcnow
}
_common_properties = [ 'type', 'created_by_ref' ] # XXX - add lang?
_common_optional = [ 'overlay_refs' ]
_common_names = set(_common_properties + _generated_properties.keys())

def __init__(self, obj):
@@ -64,7 +65,7 @@ class MDBase(object):

@classmethod
def create_obj(cls, obj):
'''Using obj as a base, create an instead of MDBase of the
'''Using obj as a base, create an instance of MDBase of the
correct type.

If the correct type is not found, a ValueError is raised.'''
@@ -422,6 +423,41 @@ class _TestCases(unittest.TestCase):
self.created_by_ref)
self.assertEqual(oldid, files[0].id)

def test_mdbaseoverlay(self):
objst = ObjectStore(self.created_by_ref)

# that a base object
bid = uuid.uuid4()
objst.loadobj({
'type': 'metadata',
'uuid': bid,
'modified': datetime.datetime(2019, 6, 10, 14, 3, 10),
'created_by_ref': self.created_by_ref,
'hashes': [ 'sha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ada' ],
'someprop': [ 'somevalue' ],
'lang': 'en',
})

# can have an overlay object
oid = uuid.uuid4()
dhash = 'sha256:a7c96262c21db9a06fd49e307d694fd95f624569f9b35bb3ffacd880440f9787'
objst.loadobj({
'type': 'metadata',
'uuid': oid,
'modified': datetime.datetime(2019, 6, 10, 18, 3, 10),
'created_by_ref': self.created_by_ref,
'hashes': [ dhash ],
'overlay_refs': [ bid ],
'lang': 'en',
})

# and that when you get it's properties
oobj = objst.by_id(oid)
oitems = oobj.items()

# that is has the overlays property
print `oitems`

def test_objectstore(self):
objst = ObjectStore.load(os.path.join('fixtures', 'sample.data.pasn1'))



Loading…
Cancel
Save