Merge "Refactor existing context attributes to base class"

This commit is contained in:
Jenkins 2017-05-18 03:46:16 +00:00 committed by Gerrit Code Review
commit def9c0b715
2 changed files with 9 additions and 15 deletions

View File

@ -24,13 +24,10 @@ class RequestContext(context.RequestContext):
as well as additional request information.
"""
def __init__(self, session=None,
roles=None, is_admin=None, service_catalog=None,
def __init__(self, session=None, service_catalog=None,
**kwargs):
super(RequestContext, self).__init__(**kwargs)
self.session = session
self.roles = roles or []
self.service_catalog = service_catalog
self.is_admin = is_admin
if self.is_admin is None:
self.is_admin = policy.check_is_admin(self)

View File

@ -18,20 +18,17 @@ from murano.db import session
def dummy_context(user='test_username', tenant_id='test_tenant_id',
password='password', roles=None, user_id=None,
is_admin=False, request_id='dummy-request'):
if roles is None:
roles = []
# NOTE(kzaitsev) passing non-False value by default to request_id, to
# prevent generation during tests.
return context.RequestContext.from_dict({
request_id='dummy-request', **kwargs):
# NOTE(kzaitsev) we need to pass non-False value to request_id, to
# prevent it being generated by oslo during tests.
params = {
'request_id': request_id,
'tenant': tenant_id,
'user': user,
# 'roles': roles, # Commented until policy check changes land
'is_admin': is_admin,
})
}
params.update(kwargs)
return context.RequestContext.from_dict(params)
def save_models(*models):