Fix compatibility with oslo.context >= 4.0.0 (one more again)
This change fixes the remaining issue with oslo.context >= 4.0.0. In oslo.context < 4.0, RequestContext.from_dict looks up 'tenant' key from dict to set project_id while the method looks up 'project_id' key since oslo.context 4.0. This change implements a logic to make unit tests compatible with the both behavior, but the one for older version can be removed once we get oslo.context >= 4.0.0 in upper-constraints. Change-Id: I463e34ef36891c5ef29e88cb645c38a6cccac2f2
This commit is contained in:
parent
1a67234757
commit
2c7d40360b
|
@ -130,6 +130,7 @@ class ContextTestCase(test.NoDBTestCase):
|
|||
self.assertDictContainsSubset(expected_values, values2)
|
||||
|
||||
def test_convert_from_dict_then_to_dict(self):
|
||||
# TODO(tkajiam): Remove tenant once oslo.context is bumped to >= 4.0
|
||||
values = {'is_admin': True,
|
||||
'tenant': '222',
|
||||
'project_id': '222',
|
||||
|
@ -149,4 +150,6 @@ class ContextTestCase(test.NoDBTestCase):
|
|||
self.assertEqual('111', ctx.user_id)
|
||||
self.assertEqual('222', ctx.project_id)
|
||||
values2 = ctx.to_dict()
|
||||
# TODO(tkajiam): Remove this once oslo.context is bumped to >= 4.0
|
||||
values2.setdefault('tenant', values2.get('project_id'))
|
||||
self.assertDictContainsSubset(values, values2)
|
||||
|
|
Loading…
Reference in New Issue