| @@ -194,7 +194,7 @@ def _trytodict(o): | |||||
| except Exception: # pragma: no cover | except Exception: # pragma: no cover | ||||
| raise TypeError('unable to find __to_dict__ on %s: %s' % (type(o), `o`)) | raise TypeError('unable to find __to_dict__ on %s: %s' % (type(o), `o`)) | ||||
| class CononicalCoder(pasn1.ASN1DictCoder): | |||||
| class CanonicalCoder(pasn1.ASN1DictCoder): | |||||
| def enc_dict(self, obj, **kwargs): | def enc_dict(self, obj, **kwargs): | ||||
| class FakeIter: | class FakeIter: | ||||
| def iteritems(self): | def iteritems(self): | ||||
| @@ -205,7 +205,7 @@ class CononicalCoder(pasn1.ASN1DictCoder): | |||||
| return pasn1.ASN1DictCoder.enc_dict(self, FakeIter(), **kwargs) | return pasn1.ASN1DictCoder.enc_dict(self, FakeIter(), **kwargs) | ||||
| _asn1coder = CononicalCoder(coerce=_trytodict) | |||||
| _asn1coder = CanonicalCoder(coerce=_trytodict) | |||||
| class Persona(object): | class Persona(object): | ||||
| '''The object that represents a persona, or identity. It will | '''The object that represents a persona, or identity. It will | ||||
| @@ -227,6 +227,12 @@ class Persona(object): | |||||
| self._created_by_ref = self._identity.uuid | self._created_by_ref = self._identity.uuid | ||||
| @property | |||||
| def uuid(self): | |||||
| '''Return the UUID of the identity represented.''' | |||||
| return self._identity.uuid | |||||
| def __repr__(self): # pragma: no cover | def __repr__(self): # pragma: no cover | ||||
| r = '<Persona: has key: %s, has pubkey: %s, identity: %s>' % \ | r = '<Persona: has key: %s, has pubkey: %s, identity: %s>' % \ | ||||
| (self._key is not None, self._pubkey is not None, | (self._key is not None, self._pubkey is not None, | ||||
| @@ -771,6 +777,9 @@ class _TestCases(unittest.TestCase): | |||||
| # has an identity object | # has an identity object | ||||
| idobj = persona.get_identity() | idobj = persona.get_identity() | ||||
| # and that it has a uuid attribute that matches | |||||
| self.assertEqual(persona.uuid, idobj['uuid']) | |||||
| # that a key can be generated | # that a key can be generated | ||||
| persona.generate_key() | persona.generate_key() | ||||
| @@ -779,7 +788,7 @@ class _TestCases(unittest.TestCase): | |||||
| self.assertIsInstance(idobj['pubkey'], str) | self.assertIsInstance(idobj['pubkey'], str) | ||||
| # that get_pubkey returns the correct thing | # that get_pubkey returns the correct thing | ||||
| pubstr = _asn1coder.dumps([ idobj['uuid'], idobj['pubkey'] ]) | |||||
| pubstr = _asn1coder.dumps([ idobj.uuid, idobj['pubkey'] ]) | |||||
| self.assertEqual(persona.get_pubkey(), | self.assertEqual(persona.get_pubkey(), | ||||
| base58.b58encode_check(pubstr)) | base58.b58encode_check(pubstr)) | ||||