Return None for missing trust_id in fixture
If the trust_id is unset it raises a KeyError. This is unusual from a python perspective (if nothing else it should be AttributeError) and different to all the other attributes of the fixture. Return None if no trust_id is set on the fixture. Change-Id: I15d33d77027a188fa47df18387c4610908f8e2d2
This commit is contained in:
@@ -166,7 +166,7 @@ class Token(dict):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def trust_id(self):
|
def trust_id(self):
|
||||||
return self.root.setdefault('trust', {})['id']
|
return self.root.setdefault('trust', {}).get('id')
|
||||||
|
|
||||||
@trust_id.setter
|
@trust_id.setter
|
||||||
def trust_id(self, value):
|
def trust_id(self, value):
|
||||||
|
@@ -35,6 +35,7 @@ class V2TokenTests(utils.TestCase):
|
|||||||
self.assertEqual(user_id, token['access']['user']['id'])
|
self.assertEqual(user_id, token['access']['user']['id'])
|
||||||
self.assertEqual(user_name, token.user_name)
|
self.assertEqual(user_name, token.user_name)
|
||||||
self.assertEqual(user_name, token['access']['user']['name'])
|
self.assertEqual(user_name, token['access']['user']['name'])
|
||||||
|
self.assertIsNone(token.trust_id)
|
||||||
|
|
||||||
def test_tenant_scoped(self):
|
def test_tenant_scoped(self):
|
||||||
tenant_id = uuid.uuid4().hex
|
tenant_id = uuid.uuid4().hex
|
||||||
@@ -48,6 +49,7 @@ class V2TokenTests(utils.TestCase):
|
|||||||
self.assertEqual(tenant_name, token.tenant_name)
|
self.assertEqual(tenant_name, token.tenant_name)
|
||||||
tn = token['access']['token']['tenant']['name']
|
tn = token['access']['token']['tenant']['name']
|
||||||
self.assertEqual(tenant_name, tn)
|
self.assertEqual(tenant_name, tn)
|
||||||
|
self.assertIsNone(token.trust_id)
|
||||||
|
|
||||||
def test_trust_scoped(self):
|
def test_trust_scoped(self):
|
||||||
trust_id = uuid.uuid4().hex
|
trust_id = uuid.uuid4().hex
|
||||||
|
Reference in New Issue
Block a user