From f9d9fae2337354f37e948429a08584e7bc2d3ee0 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Mon, 16 Jun 2014 18:50:08 +0100 Subject: [PATCH] tests add stub_keystoneclient to base test class Add convenience function to allow easy stubbing of keystoneclient in all tests where explicit control and verification is not required. This is a precursor to making all clients use the auth_token property from keystoneclient (instead of using the context auth_token in preference) such that trust tokens can be refreshed before expiry. Partial-Bug: #1306294 Change-Id: I9ba4595b8750ff769e76972cc30b55a68253e76d --- .../extraroute/tests/test_extraroute.py | 6 +- heat/tests/common.py | 6 ++ heat/tests/test_autoscaling.py | 38 +----------- heat/tests/test_autoscaling_update_policy.py | 6 +- heat/tests/test_ceilometer_alarm.py | 8 +-- heat/tests/test_eip.py | 9 +-- heat/tests/test_heat_autoscaling_group.py | 18 ++---- heat/tests/test_loadbalancer.py | 8 +-- heat/tests/test_metadata_refresh.py | 8 +-- heat/tests/test_neutron.py | 61 ++----------------- heat/tests/test_neutron_autoscaling.py | 15 +---- heat/tests/test_neutron_firewall.py | 20 +----- heat/tests/test_neutron_loadbalancer.py | 39 ++---------- heat/tests/test_neutron_metering.py | 14 +---- heat/tests/test_neutron_network_gateway.py | 8 +-- heat/tests/test_neutron_security_group.py | 7 +-- heat/tests/test_neutron_vpnservice.py | 26 ++------ heat/tests/test_nova_floatingip.py | 2 +- heat/tests/test_parser.py | 16 ++--- heat/tests/test_s3.py | 21 +------ heat/tests/test_security_group.py | 7 +-- heat/tests/test_server.py | 9 +-- heat/tests/test_signal.py | 17 ++---- heat/tests/test_swift.py | 21 +------ heat/tests/test_vpc.py | 15 +---- heat/tests/test_waitcondition.py | 27 +------- 26 files changed, 60 insertions(+), 372 deletions(-) diff --git a/contrib/extraroute/extraroute/tests/test_extraroute.py b/contrib/extraroute/extraroute/tests/test_extraroute.py index 3c54999cf..545f270f2 100644 --- a/contrib/extraroute/extraroute/tests/test_extraroute.py +++ b/contrib/extraroute/extraroute/tests/test_extraroute.py @@ -14,13 +14,11 @@ from testtools import skipIf from heat.common import template_format -from heat.engine import clients from heat.engine import resource from heat.engine.resources.neutron import neutron_utils from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils from ..resources import extraroute # noqa @@ -65,7 +63,7 @@ class NeutronExtraRouteTest(HeatTestCase): super(NeutronExtraRouteTest, self).setUp() self.m.StubOutWithMock(neutronclient.Client, 'show_router') self.m.StubOutWithMock(neutronclient.Client, 'update_router') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() resource._register_class("OS::Neutron::ExtraRoute", extraroute.ExtraRoute) @@ -81,8 +79,6 @@ class NeutronExtraRouteTest(HeatTestCase): return rsrc def test_extraroute(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) # add first route neutronclient.Client.show_router( '3e46229d-8fce-4733-819a-b5fe630550f8')\ diff --git a/heat/tests/common.py b/heat/tests/common.py index 15bb9b861..387bc414e 100644 --- a/heat/tests/common.py +++ b/heat/tests/common.py @@ -24,9 +24,11 @@ from oslotest import mockpatch import testscenarios import testtools +from heat.engine import clients from heat.engine import environment from heat.engine import resources from heat.engine import scheduler +from heat.tests import fakes from heat.tests import utils @@ -109,3 +111,7 @@ class HeatTestCase(testscenarios.WithScenarios, def patchobject(self, obj, attr): mockfixture = self.useFixture(mockpatch.PatchObject(obj, attr)) return mockfixture.mock + + def stub_keystoneclient(self, **kwargs): + client = self.patchobject(clients.OpenStackClients, "keystone") + client.return_value = fakes.FakeKeystoneClient(**kwargs) diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py index bc2fdafb2..7a8b4d617 100644 --- a/heat/tests/test_autoscaling.py +++ b/heat/tests/test_autoscaling.py @@ -35,7 +35,6 @@ from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.openstack.common import timeutils from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils neutronclient = try_import('neutronclient.v2_0.client') @@ -130,7 +129,7 @@ class AutoScalingTest(HeatTestCase): super(AutoScalingTest, self).setUp() cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - self.fc = fakes.FakeKeystoneClient() + self.stub_keystoneclient() def create_scaling_group(self, t, stack, resource_name): # create the launch configuration resource @@ -1191,10 +1190,6 @@ class AutoScalingTest(HeatTestCase): t = template_format.parse(as_template_bad_group) stack = utils.parse_stack(t, params=self.params) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') @@ -1227,10 +1222,6 @@ class AutoScalingTest(HeatTestCase): self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2) self._stub_create(1) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') @@ -1273,10 +1264,6 @@ class AutoScalingTest(HeatTestCase): self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2) self._stub_create(1) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') @@ -1319,10 +1306,6 @@ class AutoScalingTest(HeatTestCase): self._stub_delete(1) self._stub_meta_expected(now, 'ChangeInCapacity : -1', 2) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.ReplayAll() down_policy = self.create_scaling_policy(t, stack, 'WebServerScaleDownPolicy') @@ -1351,10 +1334,6 @@ class AutoScalingTest(HeatTestCase): self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2) self._stub_create(1) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') @@ -1404,10 +1383,6 @@ class AutoScalingTest(HeatTestCase): self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2) self._stub_create(1) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') @@ -1462,10 +1437,6 @@ class AutoScalingTest(HeatTestCase): self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2) self._stub_create(1) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') @@ -1520,10 +1491,6 @@ class AutoScalingTest(HeatTestCase): self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2) self._stub_create(1) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') @@ -1563,9 +1530,6 @@ class AutoScalingTest(HeatTestCase): self._stub_meta_expected(now, 'ExactCapacity : 1') self._stub_create(1) - self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone') - asc.ScalingPolicy.keystone().MultipleTimes().AndReturn(self.fc) - self.m.ReplayAll() rsrc = self.create_scaling_group(t, stack, 'WebServerGroup') stack.resources['WebServerGroup'] = rsrc diff --git a/heat/tests/test_autoscaling_update_policy.py b/heat/tests/test_autoscaling_update_policy.py index b753debc6..782dd18b2 100644 --- a/heat/tests/test_autoscaling_update_policy.py +++ b/heat/tests/test_autoscaling_update_policy.py @@ -28,9 +28,7 @@ from heat.engine.resources import glance_utils from heat.engine.resources import instance from heat.engine.resources import loadbalancer as lb from heat.engine.resources import wait_condition as wc -from heat.engine import stack_user from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils from heat.tests.v1_1 import fakes as fakes11 @@ -208,7 +206,7 @@ class AutoScalingGroupTest(HeatTestCase): def setUp(self): super(AutoScalingGroupTest, self).setUp() self.fc = fakes11.FakeClient() - self.fkc = fakes.FakeKeystoneClient(username='test_stack.CfnLBUser') + self.stub_keystoneclient(username='test_stack.CfnLBUser') cfg.CONF.set_default('heat_waitcondition_server_url', 'http://127.0.0.1:8000/v1/waitcondition') @@ -230,8 +228,6 @@ class AutoScalingGroupTest(HeatTestCase): parser.Stack.validate().MultipleTimes() def _stub_lb_create(self): - self.m.StubOutWithMock(stack_user.StackUser, 'keystone') - stack_user.StackUser.keystone().MultipleTimes().AndReturn(self.fkc) self.m.StubOutWithMock(wc.WaitConditionHandle, 'get_status') wc.WaitConditionHandle.get_status().AndReturn(['SUCCESS']) diff --git a/heat/tests/test_ceilometer_alarm.py b/heat/tests/test_ceilometer_alarm.py index 1ce7e1dfa..3772ef2fe 100644 --- a/heat/tests/test_ceilometer_alarm.py +++ b/heat/tests/test_ceilometer_alarm.py @@ -27,10 +27,8 @@ from heat.engine import resource from heat.engine.resources.ceilometer import alarm from heat.engine import rsrc_defn from heat.engine import scheduler -from heat.engine import stack_user from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import generic_resource from heat.tests import utils @@ -139,7 +137,7 @@ class CeilometerAlarmTest(HeatTestCase): cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - self.fc = fakes.FakeKeystoneClient() + self.stub_keystoneclient() self.fa = FakeCeilometerClient() # Note tests creating a stack should be decorated with @stack_delete_after @@ -155,10 +153,6 @@ class CeilometerAlarmTest(HeatTestCase): disable_rollback=True) stack.store() - self.m.StubOutWithMock(stack_user.StackUser, 'keystone') - stack_user.StackUser.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.StubOutWithMock(alarm.CeilometerAlarm, 'ceilometer') alarm.CeilometerAlarm.ceilometer().MultipleTimes().AndReturn( self.fa) diff --git a/heat/tests/test_eip.py b/heat/tests/test_eip.py index d5ada4d16..fbbf75d29 100644 --- a/heat/tests/test_eip.py +++ b/heat/tests/test_eip.py @@ -21,7 +21,6 @@ from heat.engine import parser from heat.engine.resources import eip from heat.engine import scheduler from heat.tests.common import HeatTestCase -from heat.tests import fakes as fakec from heat.tests import utils from heat.tests.v1_1 import fakes @@ -305,7 +304,7 @@ class AllocTest(HeatTestCase): self.m.StubOutWithMock(clients.neutronclient.Client, 'list_routers') self.m.StubOutWithMock(clients.neutronclient.Client, 'remove_gateway_router') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def mock_show_network(self): vpc_name = utils.PhysName('test_stack', 'the_vpc') @@ -468,10 +467,6 @@ class AllocTest(HeatTestCase): "routers": [] }) - def mock_keystone(self): - clients.OpenStackClients.keystone().AndReturn( - fakec.FakeKeystoneClient()) - def test_neutron_eip(self): eip.ElasticIp.nova().MultipleTimes().AndReturn(self.fc) self.fc.servers.get('WebServer').AndReturn(self.fc.servers.list()[0]) @@ -500,7 +495,6 @@ class AllocTest(HeatTestCase): self.m.VerifyAll() def test_association_allocationid(self): - self.mock_keystone() self.mock_create_gateway_attachment() self.mock_show_network() self.mock_router_for_vpc() @@ -529,7 +523,6 @@ class AllocTest(HeatTestCase): self.m.VerifyAll() def test_association_allocationid_with_instance(self): - self.mock_keystone() self.mock_show_network() self.mock_create_floatingip() diff --git a/heat/tests/test_heat_autoscaling_group.py b/heat/tests/test_heat_autoscaling_group.py index 778b8b85c..754df11b2 100644 --- a/heat/tests/test_heat_autoscaling_group.py +++ b/heat/tests/test_heat_autoscaling_group.py @@ -20,14 +20,12 @@ from oslo.config import cfg from heat.common import exception from heat.common import short_id from heat.common import template_format -from heat.engine import clients from heat.engine import resource from heat.engine import rsrc_defn from heat.engine import scheduler from heat.engine import stack_resource from heat.openstack.common import timeutils from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import generic_resource from heat.tests import utils @@ -55,9 +53,7 @@ class AutoScalingGroupTest(HeatTestCase): generic_resource.ResourceWithProps) cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - self.fc = fakes.FakeKeystoneClient() - client = self.patchobject(clients.OpenStackClients, "keystone") - client.return_value = self.fc + self.stub_keystoneclient() self.parsed = template_format.parse(self.as_template) def create_stack(self, t): @@ -288,9 +284,7 @@ class HeatScalingGroupWithCFNScalingPolicyTest(HeatTestCase): generic_resource.ResourceWithProps) cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - self.fc = fakes.FakeKeystoneClient() - client = self.patchobject(clients.OpenStackClients, "keystone") - client.return_value = self.fc + self.stub_keystoneclient() self.parsed = template_format.parse(self.as_template) def create_stack(self, t): @@ -344,9 +338,7 @@ class ScalingPolicyTest(HeatTestCase): super(ScalingPolicyTest, self).setUp() resource._register_class('ResourceWithProps', generic_resource.ResourceWithProps) - self.fc = fakes.FakeKeystoneClient() - client = self.patchobject(clients.OpenStackClients, "keystone") - client.return_value = self.fc + self.stub_keystoneclient() self.parsed = template_format.parse(self.as_template) def test_alarm_attribute(self): @@ -418,9 +410,7 @@ class RollingUpdatesTest(HeatTestCase): generic_resource.ResourceWithProps) cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - self.fc = fakes.FakeKeystoneClient() - client = self.patchobject(clients.OpenStackClients, "keystone") - client.return_value = self.fc + self.stub_keystoneclient() self.parsed = template_format.parse(self.as_template) generate_id = self.patchobject(short_id, 'generate_id') generate_id.side_effect = ('id-%d' % (i,) diff --git a/heat/tests/test_loadbalancer.py b/heat/tests/test_loadbalancer.py index af491a737..b977e8afd 100644 --- a/heat/tests/test_loadbalancer.py +++ b/heat/tests/test_loadbalancer.py @@ -28,9 +28,7 @@ from heat.engine.resources import loadbalancer as lb from heat.engine.resources import wait_condition as wc from heat.engine import rsrc_defn from heat.engine import scheduler -from heat.engine import stack_user from heat.tests.common import HeatTestCase -from heat.tests import fakes as test_fakes from heat.tests import utils from heat.tests.v1_1 import fakes @@ -109,8 +107,7 @@ class LoadBalancerTest(HeatTestCase): self.m.StubOutWithMock(clients.OpenStackClients, 'nova') self.m.StubOutWithMock(self.fc.servers, 'create') self.m.StubOutWithMock(resource.Resource, 'metadata_set') - self.fkc = test_fakes.FakeKeystoneClient( - username='test_stack.CfnLBUser') + self.stub_keystoneclient(username='test_stack.CfnLBUser') cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') @@ -135,9 +132,6 @@ class LoadBalancerTest(HeatTestCase): MultipleTimes().AndReturn(imageId) def _create_stubs(self, key_name='test', stub_meta=True): - self.m.StubOutWithMock(stack_user.StackUser, 'keystone') - stack_user.StackUser.keystone().MultipleTimes().AndReturn(self.fkc) - server_name = utils.PhysName( utils.PhysName('test_stack', 'LoadBalancer'), 'LB_instance', diff --git a/heat/tests/test_metadata_refresh.py b/heat/tests/test_metadata_refresh.py index 4a021d718..7bd889db2 100644 --- a/heat/tests/test_metadata_refresh.py +++ b/heat/tests/test_metadata_refresh.py @@ -26,7 +26,6 @@ from heat.engine.resources import wait_condition as wc from heat.engine import scheduler from heat.engine import service from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils @@ -132,7 +131,7 @@ class MetadataRefreshTest(HeatTestCase): ''' def setUp(self): super(MetadataRefreshTest, self).setUp() - self.fc = fakes.FakeKeystoneClient() + self.stub_keystoneclient() # Note tests creating a stack should be decorated with @stack_delete_after # to ensure the stack is properly cleaned up @@ -198,7 +197,7 @@ class MetadataRefreshTest(HeatTestCase): class WaitCondMetadataUpdateTest(HeatTestCase): def setUp(self): super(WaitCondMetadataUpdateTest, self).setUp() - self.fc = fakes.FakeKeystoneClient() + self.stub_keystoneclient() self.man = service.EngineService('a-host', 'a-topic') cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') @@ -226,9 +225,6 @@ class WaitCondMetadataUpdateTest(HeatTestCase): instance.Instance.handle_create().AndReturn(cookie) instance.Instance.check_create_complete(cookie).AndReturn(True) - self.m.StubOutWithMock(wc.WaitConditionHandle, 'keystone') - wc.WaitConditionHandle.keystone().MultipleTimes().AndReturn(self.fc) - id = identifier.ResourceIdentifier('test_tenant_id', stack.name, stack.id, '', 'WH') self.m.StubOutWithMock(wc.WaitConditionHandle, 'identifier') diff --git a/heat/tests/test_neutron.py b/heat/tests/test_neutron.py index 872ea2f1e..2d2f46366 100644 --- a/heat/tests/test_neutron.py +++ b/heat/tests/test_neutron.py @@ -31,7 +31,6 @@ from heat.engine import rsrc_defn from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils neutronclient = try_import('neutronclient.v2_0.client') @@ -533,7 +532,7 @@ class NeutronNetTest(HeatTestCase): 'remove_network_from_dhcp_agent') self.m.StubOutWithMock(neutronclient.Client, 'list_dhcp_agent_hosting_networks') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_net(self, t, stack, resource_name): resource_defns = stack.t.resource_definitions(stack) @@ -543,9 +542,6 @@ class NeutronNetTest(HeatTestCase): return rsrc def test_net(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - # Create script neutronclient.Client.create_network({ 'network': { @@ -730,12 +726,9 @@ class NeutronProviderNetTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'show_network') self.m.StubOutWithMock(neutronclient.Client, 'delete_network') self.m.StubOutWithMock(neutronclient.Client, 'update_network') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_provider_net(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - # Create script neutronclient.Client.create_network({ 'network': { @@ -854,7 +847,7 @@ class NeutronSubnetTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'update_subnet') self.m.StubOutWithMock(neutron_utils.neutronV20, 'find_resourceid_by_name_or_id') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_subnet(self, t, stack, resource_name): resource_defns = stack.t.resource_definitions(stack) @@ -932,8 +925,6 @@ class NeutronSubnetTest(HeatTestCase): self.m.VerifyAll() def _test_subnet(self, resolve_neutron=True): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_subnet({ 'subnet': { 'name': utils.PhysName('test_stack', 'test_subnet'), @@ -1023,9 +1014,6 @@ class NeutronSubnetTest(HeatTestCase): return t def test_subnet_disable_dhcp(self): - - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -1172,7 +1160,7 @@ class NeutronRouterTest(HeatTestCase): 'list_l3_agent_hosting_routers') self.m.StubOutWithMock(neutron_utils.neutronV20, 'find_resourceid_by_name_or_id') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_router(self, t, stack, resource_name): resource_defns = stack.t.resource_definitions(stack) @@ -1204,8 +1192,6 @@ class NeutronRouterTest(HeatTestCase): return rsrc def test_router(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_router({ 'router': { 'name': utils.PhysName('test_stack', 'router'), @@ -1382,8 +1368,6 @@ class NeutronRouterTest(HeatTestCase): self._test_router_interface(resolve_neutron=False) def _test_router_interface(self, resolve_neutron=True): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.add_interface_router( '3e46229d-8fce-4733-819a-b5fe630550f8', {'subnet_id': '91e47a57-7508-46fe-afc9-fc454e8580e1'} @@ -1423,8 +1407,6 @@ class NeutronRouterTest(HeatTestCase): self.m.VerifyAll() def test_router_interface_with_old_data(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.add_interface_router( '3e46229d-8fce-4733-819a-b5fe630550f8', {'subnet_id': '91e47a57-7508-46fe-afc9-fc454e8580e1'} @@ -1461,8 +1443,6 @@ class NeutronRouterTest(HeatTestCase): self.m.VerifyAll() def test_router_interface_with_port_id(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.add_interface_router( 'ae478782-53c0-4434-ab16-49900c88016c', {'port_id': '9577cafd-8e98-4059-a2e6-8a771b4d318e'} @@ -1533,8 +1513,6 @@ class NeutronRouterTest(HeatTestCase): str(ex)) def test_gateway_router(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -1566,9 +1544,6 @@ class NeutronRouterTest(HeatTestCase): self.m.VerifyAll() def _create_router_with_gateway(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -1648,9 +1623,6 @@ class NeutronRouterTest(HeatTestCase): self.m.VerifyAll() def test_create_router_gateway_enable_snat(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -1799,7 +1771,7 @@ class NeutronFloatingIPTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'show_port') self.m.StubOutWithMock(neutron_utils.neutronV20, 'find_resourceid_by_name_or_id') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def test_floating_ip(self): self._test_floating_ip() @@ -1808,9 +1780,6 @@ class NeutronFloatingIPTest(HeatTestCase): self._test_floating_ip(resolve_neutron=False) def _test_floating_ip(self, resolve_neutron=True): - - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_floatingip({ 'floatingip': {'floating_network_id': u'abcd1234'} }).AndReturn({'floatingip': { @@ -1875,9 +1844,6 @@ class NeutronFloatingIPTest(HeatTestCase): self.m.VerifyAll() def test_port(self): - - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -1973,9 +1939,6 @@ class NeutronFloatingIPTest(HeatTestCase): self.m.VerifyAll() def test_floatip_port(self): - - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -2183,11 +2146,9 @@ class NeutronPortTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'show_port') self.m.StubOutWithMock(neutron_utils.neutronV20, 'find_resourceid_by_name_or_id') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def test_missing_subnet_id(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -2224,8 +2185,6 @@ class NeutronPortTest(HeatTestCase): self.m.VerifyAll() def test_missing_ip_address(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -2267,8 +2226,6 @@ class NeutronPortTest(HeatTestCase): self.m.VerifyAll() def test_missing_fixed_ips(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -2305,8 +2262,6 @@ class NeutronPortTest(HeatTestCase): self.m.VerifyAll() def test_allowed_address_pair(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -2341,8 +2296,6 @@ class NeutronPortTest(HeatTestCase): self.m.VerifyAll() def test_missing_mac_address(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', @@ -2379,8 +2332,6 @@ class NeutronPortTest(HeatTestCase): self.m.VerifyAll() def test_security_groups(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'network', diff --git a/heat/tests/test_neutron_autoscaling.py b/heat/tests/test_neutron_autoscaling.py index 129fdcf2a..a02117520 100644 --- a/heat/tests/test_neutron_autoscaling.py +++ b/heat/tests/test_neutron_autoscaling.py @@ -29,7 +29,6 @@ from heat.engine.resources import nova_utils from heat.engine import template from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils from heat.tests.v1_1 import fakes as v1fakes @@ -116,7 +115,7 @@ class AutoScalingTest(HeatTestCase): cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() self.m.StubOutWithMock(clients.neutronclient.Client, 'create_health_monitor') @@ -255,9 +254,6 @@ class AutoScalingTest(HeatTestCase): instances = {} - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - clients.neutronclient.Client.create_health_monitor(mon_block).\ AndReturn(mon_ret_block) @@ -279,12 +275,6 @@ class AutoScalingTest(HeatTestCase): clients.neutronclient.Client.show_vip(vip_ret_block['vip']['id']).\ AndReturn(vip_ret_block) - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - parser.Stack.validate() instid = str(uuid.uuid4()) instance.Instance.handle_create().AndReturn(instid) @@ -306,9 +296,6 @@ class AutoScalingTest(HeatTestCase): instances[instid] = membera_ret_block['member']['id'] # Start of update - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - parser.Stack.validate() instid = str(uuid.uuid4()) instance.Instance.handle_create().AndReturn(instid) diff --git a/heat/tests/test_neutron_firewall.py b/heat/tests/test_neutron_firewall.py index b2214d60d..fa24b409d 100644 --- a/heat/tests/test_neutron_firewall.py +++ b/heat/tests/test_neutron_firewall.py @@ -17,12 +17,10 @@ from testtools import skipIf from heat.common import exception from heat.common import template_format -from heat.engine import clients from heat.engine.resources.neutron import firewall from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils neutronclient = try_import('neutronclient.v2_0.client') @@ -95,11 +93,9 @@ class FirewallTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'delete_firewall') self.m.StubOutWithMock(neutronclient.Client, 'show_firewall') self.m.StubOutWithMock(neutronclient.Client, 'update_firewall') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_firewall(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_firewall({ 'firewall': { 'name': 'test-firewall', 'admin_state_up': True, @@ -120,8 +116,6 @@ class FirewallTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_firewall({ 'firewall': { 'name': 'test-firewall', 'admin_state_up': True, @@ -227,11 +221,9 @@ class FirewallPolicyTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'delete_firewall_policy') self.m.StubOutWithMock(neutronclient.Client, 'show_firewall_policy') self.m.StubOutWithMock(neutronclient.Client, 'update_firewall_policy') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_firewall_policy(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_firewall_policy({ 'firewall_policy': { 'name': 'test-firewall-policy', 'shared': True, @@ -252,8 +244,6 @@ class FirewallPolicyTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_firewall_policy({ 'firewall_policy': { 'name': 'test-firewall-policy', 'shared': True, @@ -358,11 +348,9 @@ class FirewallRuleTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'delete_firewall_rule') self.m.StubOutWithMock(neutronclient.Client, 'show_firewall_rule') self.m.StubOutWithMock(neutronclient.Client, 'update_firewall_rule') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_firewall_rule(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_firewall_rule({ 'firewall_rule': { 'name': 'test-firewall-rule', 'shared': True, @@ -384,8 +372,6 @@ class FirewallRuleTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_firewall_rule({ 'firewall_rule': { 'name': 'test-firewall-rule', 'shared': True, diff --git a/heat/tests/test_neutron_loadbalancer.py b/heat/tests/test_neutron_loadbalancer.py index 92ace133f..92f7e4584 100644 --- a/heat/tests/test_neutron_loadbalancer.py +++ b/heat/tests/test_neutron_loadbalancer.py @@ -24,7 +24,6 @@ from heat.engine.resources.neutron import neutron_utils from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils from heat.tests.v1_1 import fakes as nova_fakes @@ -229,11 +228,9 @@ class HealthMonitorTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'delete_health_monitor') self.m.StubOutWithMock(neutronclient.Client, 'show_health_monitor') self.m.StubOutWithMock(neutronclient.Client, 'update_health_monitor') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_health_monitor(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_health_monitor({ 'health_monitor': { 'delay': 3, 'max_retries': 5, 'type': u'HTTP', @@ -254,8 +251,6 @@ class HealthMonitorTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_health_monitor({ 'health_monitor': { 'delay': 3, 'max_retries': 5, 'type': u'HTTP', @@ -368,11 +363,9 @@ class PoolTest(HeatTestCase): 'find_resourceid_by_name_or_id') self.m.StubOutWithMock(neutronclient.Client, 'delete_vip') self.m.StubOutWithMock(neutronclient.Client, 'show_vip') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_pool(self, resolve_neutron=True, with_vip_subnet=False): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_pool({ 'pool': { 'subnet_id': 'sub123', 'protocol': u'HTTP', @@ -447,8 +440,6 @@ class PoolTest(HeatTestCase): self.m.VerifyAll() def test_create_pending(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'subnet', @@ -487,8 +478,6 @@ class PoolTest(HeatTestCase): self.m.VerifyAll() def test_create_failed_unexpected_status(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'subnet', @@ -526,8 +515,6 @@ class PoolTest(HeatTestCase): self.m.VerifyAll() def test_create_failed_unexpected_vip_status(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'subnet', @@ -567,8 +554,6 @@ class PoolTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'subnet', @@ -597,8 +582,6 @@ class PoolTest(HeatTestCase): self.m.VerifyAll() def test_create_with_session_persistence(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'subnet', @@ -663,8 +646,6 @@ class PoolTest(HeatTestCase): self.assertIsNone(resource.validate()) def test_properties_are_prepared_for_session_persistence(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'subnet', @@ -816,8 +797,6 @@ class PoolTest(HeatTestCase): self.m.VerifyAll() def test_update_monitors(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'subnet', @@ -874,11 +853,9 @@ class PoolMemberTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'delete_member') self.m.StubOutWithMock(neutronclient.Client, 'update_member') self.m.StubOutWithMock(neutronclient.Client, 'show_member') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_member(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_member({ 'member': { 'pool_id': 'pool123', 'protocol_port': 8080, @@ -900,8 +877,6 @@ class PoolMemberTest(HeatTestCase): self.m.VerifyAll() def test_create_optional_parameters(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_member({ 'member': { 'pool_id': 'pool123', 'protocol_port': 8080, @@ -979,12 +954,10 @@ class LoadBalancerTest(HeatTestCase): self.fc = nova_fakes.FakeClient() self.m.StubOutWithMock(neutronclient.Client, 'create_member') self.m.StubOutWithMock(neutronclient.Client, 'delete_member') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() self.m.StubOutWithMock(clients.OpenStackClients, 'nova') def create_load_balancer(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) clients.OpenStackClients.nova().MultipleTimes().AndReturn(self.fc) neutronclient.Client.create_member({ 'member': { @@ -1080,11 +1053,9 @@ class PoolUpdateHealthMonitorsTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'create_vip') self.m.StubOutWithMock(neutronclient.Client, 'delete_vip') self.m.StubOutWithMock(neutronclient.Client, 'show_vip') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def _create_pool_with_health_monitors(self): - clients.OpenStackClients.keystone().MultipleTimes().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_health_monitor({ 'health_monitor': { 'delay': 3, 'max_retries': 5, 'type': u'HTTP', diff --git a/heat/tests/test_neutron_metering.py b/heat/tests/test_neutron_metering.py index 319477926..0358ced88 100644 --- a/heat/tests/test_neutron_metering.py +++ b/heat/tests/test_neutron_metering.py @@ -15,12 +15,10 @@ from testtools import skipIf from heat.common import exception from heat.common import template_format -from heat.engine import clients from heat.engine.resources.neutron import metering from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils neutronclient = try_import('neutronclient.v2_0.client') @@ -66,11 +64,9 @@ class MeteringLabelTest(HeatTestCase): 'delete_metering_label_rule') self.m.StubOutWithMock(neutronclient.Client, 'show_metering_label_rule') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_metering_label(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_metering_label({ 'metering_label': { 'name': 'TestLabel', @@ -91,8 +87,6 @@ class MeteringLabelTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_metering_label({ 'metering_label': { 'name': 'TestLabel', @@ -180,11 +174,9 @@ class MeteringRuleTest(HeatTestCase): 'delete_metering_label_rule') self.m.StubOutWithMock(neutronclient.Client, 'show_metering_label_rule') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_metering_label_rule(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_metering_label_rule({ 'metering_label_rule': { 'metering_label_id': 'None', @@ -207,8 +199,6 @@ class MeteringRuleTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_metering_label_rule({ 'metering_label_rule': { 'metering_label_id': 'None', diff --git a/heat/tests/test_neutron_network_gateway.py b/heat/tests/test_neutron_network_gateway.py index 872fe43ce..3d2386cb6 100644 --- a/heat/tests/test_neutron_network_gateway.py +++ b/heat/tests/test_neutron_network_gateway.py @@ -20,14 +20,12 @@ from testtools import skipIf from heat.common import exception from heat.common import template_format -from heat.engine import clients from heat.engine.resources.neutron import network_gateway from heat.engine.resources.neutron import neutron_utils from heat.engine import rsrc_defn from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils neutronclient = try_import('neutronclient.v2_0.client') @@ -113,11 +111,9 @@ class NeutronNetworkGatewayTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'list_networks') self.m.StubOutWithMock(neutron_utils.neutronV20, 'find_resourceid_by_name_or_id') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def prepare_create_network_gateway(self, resolve_neutron=True): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_network_gateway({ 'network_gateway': { 'name': u'NetworkGateway', @@ -445,8 +441,6 @@ class NeutronNetworkGatewayTest(HeatTestCase): self.m.VerifyAll() def test_network_gatway_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_network_gateway({ 'network_gateway': { 'name': u'NetworkGateway', diff --git a/heat/tests/test_neutron_security_group.py b/heat/tests/test_neutron_security_group.py index 9afafcb67..2236764f0 100644 --- a/heat/tests/test_neutron_security_group.py +++ b/heat/tests/test_neutron_security_group.py @@ -22,7 +22,6 @@ from heat.engine import clients from heat.engine import parser from heat.engine import scheduler from heat.tests.common import HeatTestCase -from heat.tests.fakes import FakeKeystoneClient from heat.tests import utils from heat.tests.v1_1 import fakes @@ -88,7 +87,7 @@ Resources: super(SecurityGroupTest, self).setUp() self.fc = fakes.FakeClient() self.m.StubOutWithMock(clients.OpenStackClients, 'nova') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'create') self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'delete') self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'create') @@ -200,8 +199,6 @@ Resources: } #create script - clients.OpenStackClients.keystone().AndReturn( - FakeKeystoneClient()) sg_name = utils.PhysName('test_stack', 'the_sg') neutronclient.Client.create_security_group({ 'security_group': { @@ -544,8 +541,6 @@ Resources: def test_security_group_exception(self): #create script - clients.OpenStackClients.keystone().AndReturn( - FakeKeystoneClient()) sg_name = utils.PhysName('test_stack', 'the_sg') neutronclient.Client.create_security_group({ 'security_group': { diff --git a/heat/tests/test_neutron_vpnservice.py b/heat/tests/test_neutron_vpnservice.py index 96f76ac89..7d319e299 100644 --- a/heat/tests/test_neutron_vpnservice.py +++ b/heat/tests/test_neutron_vpnservice.py @@ -18,13 +18,11 @@ from testtools import skipIf from heat.common import exception from heat.common import template_format -from heat.engine import clients from heat.engine.resources.neutron import neutron_utils from heat.engine.resources.neutron import vpnservice from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils @@ -176,11 +174,9 @@ class VPNServiceTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'update_vpnservice') self.m.StubOutWithMock(neutron_utils.neutronV20, 'find_resourceid_by_name_or_id') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_vpnservice(self, resolve_neutron=True): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) if resolve_neutron: neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), @@ -213,8 +209,6 @@ class VPNServiceTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutron_utils.neutronV20.find_resourceid_by_name_or_id( mox.IsA(neutronclient.Client), 'subnet', @@ -345,11 +339,9 @@ class IPsecSiteConnectionTest(HeatTestCase): 'show_ipsec_site_connection') self.m.StubOutWithMock(neutronclient.Client, 'update_ipsec_site_connection') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_ipsec_site_connection(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_ipsec_site_connection( self.IPSEC_SITE_CONNECTION_CONF).AndReturn( {'ipsec_site_connection': {'id': 'con123'}}) @@ -369,8 +361,6 @@ class IPsecSiteConnectionTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_ipsec_site_connection( self.IPSEC_SITE_CONNECTION_CONF).AndRaise( vpnservice.NeutronClientException()) @@ -497,11 +487,9 @@ class IKEPolicyTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'delete_ikepolicy') self.m.StubOutWithMock(neutronclient.Client, 'show_ikepolicy') self.m.StubOutWithMock(neutronclient.Client, 'update_ikepolicy') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_ikepolicy(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_ikepolicy( self.IKE_POLICY_CONF).AndReturn( {'ikepolicy': {'id': 'ike123'}}) @@ -520,8 +508,6 @@ class IKEPolicyTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_ikepolicy( self.IKE_POLICY_CONF).AndRaise( vpnservice.NeutronClientException()) @@ -643,11 +629,9 @@ class IPsecPolicyTest(HeatTestCase): self.m.StubOutWithMock(neutronclient.Client, 'delete_ipsecpolicy') self.m.StubOutWithMock(neutronclient.Client, 'show_ipsecpolicy') self.m.StubOutWithMock(neutronclient.Client, 'update_ipsecpolicy') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_ipsecpolicy(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_ipsecpolicy( self.IPSEC_POLICY_CONF).AndReturn( {'ipsecpolicy': {'id': 'ips123'}}) @@ -666,8 +650,6 @@ class IPsecPolicyTest(HeatTestCase): self.m.VerifyAll() def test_create_failed(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) neutronclient.Client.create_ipsecpolicy( self.IPSEC_POLICY_CONF).AndRaise( vpnservice.NeutronClientException()) diff --git a/heat/tests/test_nova_floatingip.py b/heat/tests/test_nova_floatingip.py index dc002df8e..e47b3995a 100644 --- a/heat/tests/test_nova_floatingip.py +++ b/heat/tests/test_nova_floatingip.py @@ -70,7 +70,7 @@ class NovaFloatingIPTest(HeatTestCase): self.m.StubOutWithMock(self.novaclient.servers, 'get') self.m.StubOutWithMock(self.novaclient.servers, 'add_floating_ip') self.m.StubOutWithMock(self.novaclient.servers, 'remove_floating_ip') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def _make_obj(self, **kwargs): mock = self.m.CreateMockAnything() diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index ebbb86cfd..6742427c8 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -951,9 +951,7 @@ class StackTest(HeatTestCase): def test_no_auth_token(self): ctx = utils.dummy_context() ctx.auth_token = None - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') - clients.OpenStackClients.keystone().MultipleTimes().AndReturn( - FakeKeystoneClient()) + self.stub_keystoneclient() self.m.ReplayAll() stack = parser.Stack(ctx, 'test_stack', self.tmpl) @@ -1325,11 +1323,7 @@ class StackTest(HeatTestCase): def test_delete_trust(self): cfg.CONF.set_override('deferred_auth_method', 'trusts') - - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') - clients.OpenStackClients.keystone().MultipleTimes().AndReturn( - FakeKeystoneClient()) - self.m.ReplayAll() + self.stub_keystoneclient() self.stack = parser.Stack( self.ctx, 'delete_trust', self.tmpl) @@ -3102,8 +3096,7 @@ class StackTest(HeatTestCase): self.assertIsNone(db_stack.stack_user_project_id) def test_stack_user_project_id_constructor(self): - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') - clients.OpenStackClients.keystone().AndReturn(FakeKeystoneClient()) + self.stub_keystoneclient() self.m.ReplayAll() self.stack = parser.Stack(self.ctx, 'user_project_init', @@ -3144,8 +3137,7 @@ class StackTest(HeatTestCase): self.m.VerifyAll() def test_stack_user_project_id_setter(self): - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') - clients.OpenStackClients.keystone().AndReturn(FakeKeystoneClient()) + self.stub_keystoneclient() self.m.ReplayAll() self.stack = parser.Stack(self.ctx, 'user_project_init', diff --git a/heat/tests/test_s3.py b/heat/tests/test_s3.py index b479edd81..dde54a8c3 100644 --- a/heat/tests/test_s3.py +++ b/heat/tests/test_s3.py @@ -16,12 +16,10 @@ from testtools import skipIf from heat.common import exception from heat.common import template_format -from heat.engine import clients from heat.engine.resources import s3 from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils swiftclient = try_import('swiftclient.client') @@ -74,7 +72,7 @@ class s3Test(HeatTestCase): self.m.StubOutWithMock(swiftclient.Connection, 'put_container') self.m.StubOutWithMock(swiftclient.Connection, 'delete_container') self.m.StubOutWithMock(swiftclient.Connection, 'get_auth') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_resource(self, t, stack, resource_name): resource_defns = stack.t.resource_definitions(stack) @@ -86,8 +84,6 @@ class s3Test(HeatTestCase): return rsrc def test_attributes(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -118,8 +114,6 @@ class s3Test(HeatTestCase): self.m.VerifyAll() def test_public_read(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( utils.PhysName('test_stack', 'test_resource'), @@ -138,8 +132,6 @@ class s3Test(HeatTestCase): self.m.VerifyAll() def test_tags(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( utils.PhysName('test_stack', 'test_resource'), @@ -158,8 +150,6 @@ class s3Test(HeatTestCase): self.m.VerifyAll() def test_public_read_write(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -178,8 +168,6 @@ class s3Test(HeatTestCase): self.m.VerifyAll() def test_authenticated_read(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -197,8 +185,6 @@ class s3Test(HeatTestCase): self.m.VerifyAll() def test_website(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -216,8 +202,6 @@ class s3Test(HeatTestCase): self.m.VerifyAll() def test_delete_exception(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -235,9 +219,6 @@ class s3Test(HeatTestCase): self.m.VerifyAll() def test_delete_retain(self): - - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) # first run, with retain policy swiftclient.Connection.put_container( utils.PhysName('test_stack', 'test_resource'), diff --git a/heat/tests/test_security_group.py b/heat/tests/test_security_group.py index 6992fbc0a..983a7cfea 100644 --- a/heat/tests/test_security_group.py +++ b/heat/tests/test_security_group.py @@ -24,7 +24,6 @@ from heat.engine import clients from heat.engine import parser from heat.engine import scheduler from heat.tests.common import HeatTestCase -from heat.tests.fakes import FakeKeystoneClient from heat.tests import utils from heat.tests.v1_1 import fakes @@ -129,7 +128,7 @@ Resources: super(SecurityGroupTest, self).setUp() self.fc = fakes.FakeClient() self.m.StubOutWithMock(clients.OpenStackClients, 'nova') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'create') self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'delete') self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'create') @@ -463,8 +462,6 @@ Resources: def test_security_group_neutron(self): #create script - clients.OpenStackClients.keystone().AndReturn( - FakeKeystoneClient()) sg_name = utils.PhysName('test_stack', 'the_sg') neutronclient.Client.create_security_group({ 'security_group': { @@ -710,8 +707,6 @@ Resources: def test_security_group_neutron_exception(self): #create script - clients.OpenStackClients.keystone().AndReturn( - FakeKeystoneClient()) sg_name = utils.PhysName('test_stack', 'the_sg') neutronclient.Client.create_security_group({ 'security_group': { diff --git a/heat/tests/test_server.py b/heat/tests/test_server.py index f6456e1d1..c2459b389 100644 --- a/heat/tests/test_server.py +++ b/heat/tests/test_server.py @@ -68,8 +68,7 @@ class ServersTest(HeatTestCase): def setUp(self): super(ServersTest, self).setUp() self.fc = fakes_v1_1.FakeClient() - self.fkc = fakes.FakeKeystoneClient() - + self.stub_keystoneclient() self.limits = self.m.CreateMockAnything() self.limits.absolute = self._limits_absolute() @@ -552,7 +551,6 @@ class ServersTest(HeatTestCase): resource_defns['WebServer'], stack) self.m.StubOutWithMock(server, 'nova') - self.m.StubOutWithMock(server, 'keystone') self.m.StubOutWithMock(server, 'heat') server.nova().MultipleTimes().AndReturn(self.fc) @@ -560,8 +558,6 @@ class ServersTest(HeatTestCase): clients.OpenStackClients.nova().MultipleTimes().AndReturn(self.fc) self._mock_get_image_id_success('F17-x86_64-gold', 744) - server.keystone().MultipleTimes().AndReturn(self.fkc) - self.m.StubOutWithMock(self.fc.servers, 'create') self.fc.servers.create( image=744, flavor=3, key_name='test', @@ -621,13 +617,11 @@ class ServersTest(HeatTestCase): resource_defns['WebServer'], stack) self.m.StubOutWithMock(server, 'nova') - self.m.StubOutWithMock(server, 'keystone') server.nova().MultipleTimes().AndReturn(self.fc) self.m.StubOutWithMock(clients.OpenStackClients, 'nova') clients.OpenStackClients.nova().MultipleTimes().AndReturn(self.fc) self._mock_get_image_id_success('F17-x86_64-gold', 744) - server.keystone().MultipleTimes().AndReturn(self.fkc) self.m.StubOutWithMock(self.fc.servers, 'create') self.fc.servers.create( @@ -2463,6 +2457,7 @@ class FlavorConstraintTest(HeatTestCase): def test_validate(self): client = fakes.FakeClient() + self.stub_keystoneclient() self.m.StubOutWithMock(clients.OpenStackClients, 'nova') clients.OpenStackClients.nova().MultipleTimes().AndReturn(client) client.flavors = self.m.CreateMockAnything() diff --git a/heat/tests/test_signal.py b/heat/tests/test_signal.py index 2f6ec2b61..8fcf33ccb 100644 --- a/heat/tests/test_signal.py +++ b/heat/tests/test_signal.py @@ -105,13 +105,10 @@ class SignalTest(HeatTestCase): def test_resource_data(self): self.stack = self.create_stack(stack_name='resource_data_test', stub=False) - - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') - clients.OpenStackClients.keystone().MultipleTimes().AndReturn( - fakes.FakeKeystoneClient( - access='anaccesskey', - secret='verysecret', - credential_id='mycredential')) + self.stub_keystoneclient( + access='anaccesskey', + secret='verysecret', + credential_id='mycredential') self.m.ReplayAll() self.stack.create() @@ -132,11 +129,7 @@ class SignalTest(HeatTestCase): def test_get_user_id(self): self.stack = self.create_stack(stack_name='resource_data_test', stub=False) - - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') - clients.OpenStackClients.keystone().MultipleTimes().AndReturn( - fakes.FakeKeystoneClient( - access='anaccesskey', secret='verysecret')) + self.stub_keystoneclient(access='anaccesskey', secret='verysecret') self.m.ReplayAll() self.stack.create() diff --git a/heat/tests/test_swift.py b/heat/tests/test_swift.py index 50f03ab08..fb4283220 100644 --- a/heat/tests/test_swift.py +++ b/heat/tests/test_swift.py @@ -16,12 +16,10 @@ import mox from testtools import skipIf from heat.common import template_format -from heat.engine import clients from heat.engine.resources import swift from heat.engine import scheduler from heat.openstack.common.importutils import try_import from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils swiftclient = try_import('swiftclient.client') @@ -77,7 +75,7 @@ class swiftTest(HeatTestCase): self.m.StubOutWithMock(swiftclient.Connection, 'delete_container') self.m.StubOutWithMock(swiftclient.Connection, 'head_container') self.m.StubOutWithMock(swiftclient.Connection, 'get_auth') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_resource(self, t, stack, resource_name): resource_defns = stack.t.resource_definitions(stack) @@ -130,8 +128,6 @@ class swiftTest(HeatTestCase): "x-container-bytes-used": "17680980", "content-type": "text/plain; charset=utf-8"} - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, {}).AndReturn(None) @@ -162,8 +158,6 @@ class swiftTest(HeatTestCase): self.m.VerifyAll() def test_public_read(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -180,8 +174,6 @@ class swiftTest(HeatTestCase): self.m.VerifyAll() def test_public_read_write(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -200,8 +192,6 @@ class swiftTest(HeatTestCase): self.m.VerifyAll() def test_container_headers(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -218,8 +208,6 @@ class swiftTest(HeatTestCase): self.m.VerifyAll() def test_account_headers(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container(container_name, {}) swiftclient.Connection.post_account( @@ -234,8 +222,6 @@ class swiftTest(HeatTestCase): self.m.VerifyAll() def test_delete_exception(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, @@ -252,9 +238,6 @@ class swiftTest(HeatTestCase): self.m.VerifyAll() def test_delete_retain(self): - - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) # first run, with retain policy swiftclient.Connection.put_container( utils.PhysName('test_stack', 'test_resource'), @@ -277,8 +260,6 @@ class swiftTest(HeatTestCase): empty string or swiftclient will pass them as string None. see bug lp:1259571. ''' - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) container_name = utils.PhysName('test_stack', 'test_resource') swiftclient.Connection.put_container( container_name, {}).AndReturn(None) diff --git a/heat/tests/test_vpc.py b/heat/tests/test_vpc.py index 66ca46d6f..78308517e 100644 --- a/heat/tests/test_vpc.py +++ b/heat/tests/test_vpc.py @@ -15,11 +15,9 @@ from testtools import skipIf from heat.common import exception from heat.common import template_format -from heat.engine import clients from heat.engine import parser from heat.engine import scheduler from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils try: @@ -60,7 +58,7 @@ class VPCTestBase(HeatTestCase): neutronclient.Client, 'create_security_group_rule') self.m.StubOutWithMock( neutronclient.Client, 'delete_security_group_rule') - self.m.StubOutWithMock(clients.OpenStackClients, 'keystone') + self.stub_keystoneclient() def create_stack(self, template): t = template_format.parse(template) @@ -76,10 +74,6 @@ class VPCTestBase(HeatTestCase): stack.store() return stack - def mock_keystone(self): - clients.OpenStackClients.keystone().AndReturn( - fakes.FakeKeystoneClient()) - def mock_create_network(self): self.vpc_name = utils.PhysName('test_stack', 'the_vpc') neutronclient.Client.create_network( @@ -355,7 +349,6 @@ Resources: ''' def test_vpc(self): - self.mock_keystone() self.mock_create_network() self.mock_delete_network() self.m.ReplayAll() @@ -385,7 +378,6 @@ Resources: ''' def test_subnet(self): - self.mock_keystone() self.mock_create_network() self.mock_create_subnet() self.mock_delete_subnet() @@ -585,7 +577,6 @@ Resources: neutronclient.Client.delete_port('dddd').AndReturn(None) def test_network_interface(self): - self.mock_keystone() self.mock_create_security_group() self.mock_create_network() self.mock_create_subnet() @@ -613,7 +604,6 @@ Resources: def test_network_interface_existing_groupset(self): self.m.StubOutWithMock(parser.Stack, 'resource_by_refid') - self.mock_keystone() self.mock_create_security_group() self.mock_create_network() self.mock_create_subnet() @@ -637,7 +627,6 @@ Resources: self.m.VerifyAll() def test_network_interface_no_groupset(self): - self.mock_keystone() self.mock_create_network() self.mock_create_subnet() self.mock_show_subnet() @@ -715,7 +704,6 @@ Resources: neutronclient.Client.remove_gateway_router('ffff').AndReturn(None) def test_internet_gateway(self): - self.mock_keystone() self.mock_create_internet_gateway() self.mock_create_network() self.mock_create_subnet() @@ -772,7 +760,6 @@ Resources: ''' def test_route_table(self): - self.mock_keystone() self.mock_create_network() self.mock_create_subnet() self.mock_create_route_table() diff --git a/heat/tests/test_waitcondition.py b/heat/tests/test_waitcondition.py index d1ffeaccd..a54e5702a 100644 --- a/heat/tests/test_waitcondition.py +++ b/heat/tests/test_waitcondition.py @@ -30,7 +30,6 @@ from heat.engine.resources import wait_condition as wc from heat.engine import rsrc_defn from heat.engine import scheduler from heat.tests.common import HeatTestCase -from heat.tests import fakes from heat.tests import utils test_template_waitcondition = ''' @@ -105,8 +104,7 @@ class WaitConditionTest(HeatTestCase): cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - - self.fc = fakes.FakeKeystoneClient() + self.stub_keystoneclient() # Note tests creating a stack should be decorated with @stack_delete_after # to ensure the stack is properly cleaned up @@ -129,10 +127,6 @@ class WaitConditionTest(HeatTestCase): stack.store() if stub: - self.m.StubOutWithMock(wc.WaitConditionHandle, 'keystone') - wc.WaitConditionHandle.keystone().MultipleTimes().AndReturn( - self.fc) - id = identifier.ResourceIdentifier('test_tenant', stack.name, stack.id, '', 'WaitHandle') self.m.StubOutWithMock(wc.WaitConditionHandle, 'identifier') @@ -377,8 +371,7 @@ class WaitConditionHandleTest(HeatTestCase): super(WaitConditionHandleTest, self).setUp() cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - - self.fc = fakes.FakeKeystoneClient() + self.stub_keystoneclient() def create_stack(self, stack_name=None, stack_id=None): temp = template_format.parse(test_template_waitcondition) @@ -400,10 +393,6 @@ class WaitConditionHandleTest(HeatTestCase): self.m.StubOutWithMock(wc.WaitConditionHandle, 'get_status') wc.WaitConditionHandle.get_status().AndReturn(['SUCCESS']) - # Stub keystone() with fake client - self.m.StubOutWithMock(wc.WaitConditionHandle, 'keystone') - wc.WaitConditionHandle.keystone().MultipleTimes().AndReturn(self.fc) - id = identifier.ResourceIdentifier('test_tenant', stack.name, stack.id, '', 'WaitHandle') self.m.StubOutWithMock(wc.WaitConditionHandle, 'identifier') @@ -521,11 +510,6 @@ class WaitConditionHandleTest(HeatTestCase): rsrc.metadata_update(new_metadata=test_metadata) self.assertEqual(['SUCCESS', 'SUCCESS'], rsrc.get_status()) - # re-stub keystone() with fake client or stack delete fails - self.m.StubOutWithMock(wc.WaitConditionHandle, 'keystone') - wc.WaitConditionHandle.keystone().MultipleTimes().AndReturn(self.fc) - self.m.ReplayAll() - def test_get_status_reason(self): self.stack = self.create_stack() rsrc = self.stack['WaitHandle'] @@ -553,8 +537,7 @@ class WaitConditionUpdateTest(HeatTestCase): super(WaitConditionUpdateTest, self).setUp() cfg.CONF.set_default('heat_waitcondition_server_url', 'http://server.test:8000/v1/waitcondition') - - self.fc = fakes.FakeKeystoneClient() + self.stub_keystoneclient() scheduler.ENABLE_SLEEP = False def tearDown(self): @@ -578,10 +561,6 @@ class WaitConditionUpdateTest(HeatTestCase): with utils.UUIDStub(self.stack_id): stack.store() - self.m.StubOutWithMock(wc.WaitConditionHandle, 'keystone') - wc.WaitConditionHandle.keystone().MultipleTimes().AndReturn( - self.fc) - self.m.StubOutWithMock(wc.WaitConditionHandle, 'get_status') wc.WaitConditionHandle.get_status().AndReturn([]) wc.WaitConditionHandle.get_status().AndReturn(['SUCCESS'])