|
|
@@ -45,7 +45,7 @@ def _makeuuid(s): |
|
|
|
if isinstance(s, uuid.UUID): |
|
|
|
return s |
|
|
|
|
|
|
|
return uuid.UUID(s) |
|
|
|
return uuid.UUID(bytes=s) |
|
|
|
|
|
|
|
# XXX - known issue, store is not atomic/safe, overwrites in place instead of renames |
|
|
|
|
|
|
@@ -188,7 +188,7 @@ class Identity(MDBase): |
|
|
|
|
|
|
|
def _trytodict(o): |
|
|
|
if isinstance(o, uuid.UUID): |
|
|
|
return 'unicode', str(o) |
|
|
|
return 'bytes', o.bytes |
|
|
|
try: |
|
|
|
return 'dict', o.__to_dict__() |
|
|
|
except Exception: # pragma: no cover |
|
|
@@ -688,6 +688,15 @@ class _TestCases(unittest.TestCase): |
|
|
|
# and that they are equal |
|
|
|
self.assertEqual(obj, decobj) |
|
|
|
|
|
|
|
# and in the encoded object |
|
|
|
eobj = _asn1coder.loads(coded) |
|
|
|
|
|
|
|
# the uuid property is a str instance |
|
|
|
self.assertIsInstance(eobj['uuid'], str) |
|
|
|
|
|
|
|
# and has the length of 16 |
|
|
|
self.assertEqual(len(eobj['uuid']), 16) |
|
|
|
|
|
|
|
def test_mdbase_wrong_type(self): |
|
|
|
# that created_by_ref can be passed by kw |
|
|
|
obj = MetaData(created_by_ref=self.created_by_ref) |
|
|
@@ -855,7 +864,7 @@ class _TestCases(unittest.TestCase): |
|
|
|
|
|
|
|
objst.loadobj({ |
|
|
|
'type': 'metadata', |
|
|
|
'uuid': 'c9a1d1e2-3109-4efd-8948-577dc15e44e7', |
|
|
|
'uuid': uuid.UUID('c9a1d1e2-3109-4efd-8948-577dc15e44e7'), |
|
|
|
'modified': datetime.datetime(2019, 5, 31, 14, 3, 10), |
|
|
|
'created_by_ref': self.created_by_ref, |
|
|
|
'hashes': [ 'sha256:91751cee0a1ab8414400238a761411daa29643ab4b8243e9a91649e25be53ada' ], |
|
|
@@ -885,11 +894,11 @@ class _TestCases(unittest.TestCase): |
|
|
|
|
|
|
|
self.assertEqual(len(objs), len(objst)) |
|
|
|
|
|
|
|
self.assertEqual(objs['created_by_ref'], str(self.created_by_ref)) |
|
|
|
self.assertEqual(objs['created_by_ref'], self.created_by_ref.bytes) |
|
|
|
|
|
|
|
for i in objs['objects']: |
|
|
|
i['created_by_ref'] = uuid.UUID(i['created_by_ref']) |
|
|
|
i['uuid'] = uuid.UUID(i['uuid']) |
|
|
|
i['created_by_ref'] = uuid.UUID(bytes=i['created_by_ref']) |
|
|
|
i['uuid'] = uuid.UUID(bytes=i['uuid']) |
|
|
|
self.assertEqual(objst.by_id(i['uuid']), i) |
|
|
|
|
|
|
|
testfname = os.path.join(self.tempdir, 'test.txt') |
|
|
|