Mock Zun fake client method
* The Zun client doesn't have an rpm packaging so running the unit test might fail if not installed. * The Designate client was fixed so there is no need to mock it. * Use Mock Fixture instead of calling directly the mock.patch,object Change-Id: Id7226c889c18dbe3a38b106b0cdac5e331f54e3a
This commit is contained in:
parent
91ff80c79d
commit
b8943be736
|
@ -711,10 +711,9 @@ class DesignateAction(base.OpenStackAction):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_fake_client(cls):
|
def _get_fake_client(cls):
|
||||||
session = keystone_utils.get_admin_session()
|
|
||||||
return cls._get_client_class()(
|
return cls._get_client_class()(
|
||||||
endpoint_override="http://127.0.0.1:9001/",
|
endpoint_override="http://127.0.0.1:9001/",
|
||||||
session=session
|
session=ks_session.Session()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,9 @@
|
||||||
import contextlib
|
import contextlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import fixtures
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
from mistral_extra.actions import generator_factory
|
from mistral_extra.actions import generator_factory
|
||||||
from mistral_extra.actions.openstack.action_generator import base as \
|
from mistral_extra.actions.openstack.action_generator import base as \
|
||||||
generator_base
|
generator_base
|
||||||
|
@ -78,22 +77,17 @@ class GeneratorTest(base.BaseTest):
|
||||||
# when it is initialised and attempts to connect. This mocks out this
|
# when it is initialised and attempts to connect. This mocks out this
|
||||||
# service only and returns a simple function that can be used by the
|
# service only and returns a simple function that can be used by the
|
||||||
# inspection utils.
|
# inspection utils.
|
||||||
self.baremetal_patch = mock.patch.object(
|
self.useFixture(fixtures.MockPatchObject(
|
||||||
actions.BaremetalIntrospectionAction,
|
actions.BaremetalIntrospectionAction, "get_fake_client_method",
|
||||||
"get_fake_client_method",
|
return_value=lambda x: None))
|
||||||
return_value=lambda x: None)
|
|
||||||
|
|
||||||
self.baremetal_patch.start()
|
# Do the same for the Zun client.
|
||||||
self.addCleanup(self.baremetal_patch.stop)
|
# There is no rpm packaging for Zun client
|
||||||
|
# so importing the client will fail when building
|
||||||
# Do the same for the Designate client.
|
# the rpm and running the unittest so lets mock it
|
||||||
self.designate_patch = mock.patch.object(
|
self.useFixture(fixtures.MockPatchObject(
|
||||||
actions.DesignateAction,
|
actions.ZunAction, "get_fake_client_method",
|
||||||
"get_fake_client_method",
|
return_value=lambda x: None))
|
||||||
return_value=lambda x: None)
|
|
||||||
|
|
||||||
self.designate_patch.start()
|
|
||||||
self.addCleanup(self.designate_patch.stop)
|
|
||||||
|
|
||||||
def test_generator(self):
|
def test_generator(self):
|
||||||
for generator_cls in generator_factory.all_generators():
|
for generator_cls in generator_factory.all_generators():
|
||||||
|
|
Loading…
Reference in New Issue