Skip to content

Commit

Permalink
Merge "Override client() for RoleAssignment resources" into stable/mi…
Browse files Browse the repository at this point in the history
…taka
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 25, 2016
2 parents 0fa75da + 55fc41a commit c01e360
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 21 deletions.
6 changes: 6 additions & 0 deletions heat/engine/resources/openstack/keystone/role_assignments.py
Expand Up @@ -345,6 +345,9 @@ class KeystoneUserRoleAssignment(resource.Resource,
def __init__(self, *args, **kwargs):
super(KeystoneUserRoleAssignment, self).__init__(*args, **kwargs)

def client(self):
return super(KeystoneUserRoleAssignment, self).client().client

@property
def user_id(self):
return (self.client_plugin().get_user_id(
Expand Down Expand Up @@ -399,6 +402,9 @@ class KeystoneGroupRoleAssignment(resource.Resource,
def __init__(self, *args, **kwargs):
super(KeystoneGroupRoleAssignment, self).__init__(*args, **kwargs)

def client(self):
return super(KeystoneGroupRoleAssignment, self).client().client

@property
def group_id(self):
return (self.client_plugin().get_group_id(
Expand Down
3 changes: 2 additions & 1 deletion heat/tests/fakes.py
Expand Up @@ -95,7 +95,7 @@ def __init__(self, username='test_username', password='password',
user_id='1234', access='4567', secret='8901',
credential_id='abcdxyz', auth_token='abcd1234',
context=None, stack_domain_id='4321', roles=None,
user_domain_id=None, project_domain_id=None):
user_domain_id=None, project_domain_id=None, client=None):
self.username = username
self.password = password
self.user_id = user_id
Expand All @@ -110,6 +110,7 @@ def __init__(self, username='test_username', password='password',
self.roles = roles or []
self.user_domain_id = user_domain_id
self.project_domain_id = project_domain_id
self.client = client

class FakeCred(object):
id = self.credential_id
Expand Down
7 changes: 6 additions & 1 deletion heat/tests/openstack/keystone/test_endpoint.py
Expand Up @@ -15,10 +15,12 @@

from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.openstack.keystone import endpoint
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils

keystone_endpoint_template = {
Expand Down Expand Up @@ -48,7 +50,10 @@ def setUp(self):
self.ctx = utils.dummy_context()

# Mock client
self.keystoneclient = mock.MagicMock()
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.endpoints = self.keystoneclient.endpoints

# Mock client plugin
Expand Down
9 changes: 6 additions & 3 deletions heat/tests/openstack/keystone/test_group.py
Expand Up @@ -15,10 +15,12 @@

from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.openstack.keystone import group
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils

keystone_group_template = {
Expand Down Expand Up @@ -52,9 +54,10 @@ def setUp(self):
self.test_group = self.stack['test_group']

# Mock client
self.keystoneclient = mock.MagicMock()
self.test_group.client = mock.MagicMock()
self.test_group.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.groups = self.keystoneclient.groups

# Mock client plugin
Expand Down
9 changes: 6 additions & 3 deletions heat/tests/openstack/keystone/test_region.py
Expand Up @@ -14,10 +14,12 @@
import mock
from six.moves.urllib import parse

from heat.engine import resource
from heat.engine.resources.openstack.keystone import region
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils

KEYSTONE_REGION_TEMPLATE = {
Expand Down Expand Up @@ -52,9 +54,10 @@ def setUp(self):
self.test_region = self.stack['test_region']

# Mock client
self.keystoneclient = mock.MagicMock()
self.test_region.client = mock.MagicMock()
self.test_region.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.regions = self.keystoneclient.regions

keystone_client_plugin = mock.MagicMock()
Expand Down
10 changes: 7 additions & 3 deletions heat/tests/openstack/keystone/test_role.py
Expand Up @@ -13,10 +13,12 @@

import mock

from heat.engine import resource
from heat.engine.resources.openstack.keystone import role
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils

keystone_role_template = {
Expand Down Expand Up @@ -47,9 +49,11 @@ def setUp(self):

self.test_role = self.stack['test_role']

self.keystoneclient = mock.MagicMock()
self.test_role.client = mock.MagicMock()
self.test_role.client.return_value = self.keystoneclient
# Mock client
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.roles = self.keystoneclient.roles

def _get_mock_role(self):
Expand Down
15 changes: 9 additions & 6 deletions heat/tests/openstack/keystone/test_role_assignments.py
Expand Up @@ -21,6 +21,7 @@
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import generic_resource
from heat.tests import utils

Expand Down Expand Up @@ -415,9 +416,10 @@ def setUp(self):
self.test_role_assignment = self.stack['test_role_assignment']

# Mock client
self.keystoneclient = mock.MagicMock()
self.test_role_assignment.client = mock.MagicMock()
self.test_role_assignment.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.roles = self.keystoneclient.roles

# Mock client plugin
Expand Down Expand Up @@ -553,9 +555,10 @@ def setUp(self):
self.test_role_assignment = self.stack['test_role_assignment']

# Mock client
self.keystoneclient = mock.MagicMock()
self.test_role_assignment.client = mock.MagicMock()
self.test_role_assignment.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.roles = self.keystoneclient.roles

# Mock client plugin
Expand Down
7 changes: 6 additions & 1 deletion heat/tests/openstack/keystone/test_service.py
Expand Up @@ -14,10 +14,12 @@
import mock

from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.openstack.keystone import service
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils

keystone_service_template = {
Expand Down Expand Up @@ -45,7 +47,10 @@ def setUp(self):
self.ctx = utils.dummy_context()

# Mock client
self.keystoneclient = mock.MagicMock()
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.services = self.keystoneclient.services

# Mock client plugin
Expand Down
9 changes: 6 additions & 3 deletions heat/tests/openstack/keystone/test_user.py
Expand Up @@ -13,10 +13,12 @@

import mock

from heat.engine import resource
from heat.engine.resources.openstack.keystone import user
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import fakes
from heat.tests import utils

keystone_user_template = {
Expand Down Expand Up @@ -56,9 +58,10 @@ def setUp(self):
self.test_user = self.stack['test_user']

# Mock client
self.keystoneclient = mock.MagicMock()
self.test_user.client = mock.MagicMock()
self.test_user.client.return_value = self.keystoneclient
self.keystoneclient = mock.Mock()
self.patchobject(resource.Resource, 'client',
return_value=fakes.FakeKeystoneClient(
client=self.keystoneclient))
self.users = self.keystoneclient.users

# Mock client plugin
Expand Down

0 comments on commit c01e360

Please sign in to comment.