Merge "Skip tests using heat when heat service is not deployed"

This commit is contained in:
Zuul 2024-03-04 14:17:52 +00:00 committed by Gerrit Code Review
commit f728814347
3 changed files with 8 additions and 8 deletions

View File

@ -19,6 +19,7 @@ from heatclient.v1 import client as v1_client
import tobiko import tobiko
from tobiko.openstack import _client from tobiko.openstack import _client
from tobiko.openstack import keystone
HeatClient = typing.Union[v1_client.Client] HeatClient = typing.Union[v1_client.Client]
@ -46,6 +47,7 @@ HeatClientType = typing.Union[None,
HeatClientFixture] HeatClientFixture]
@keystone.skip_if_missing_service(name='heat')
def heat_client(obj: HeatClientType = None) -> HeatClient: def heat_client(obj: HeatClientType = None) -> HeatClient:
if obj is None: if obj is None:
return default_heat_client() return default_heat_client()

View File

@ -13,6 +13,8 @@
# under the License. # under the License.
from __future__ import absolute_import from __future__ import absolute_import
import inspect
import tobiko import tobiko
from tobiko.openstack.keystone import _client from tobiko.openstack.keystone import _client
@ -38,7 +40,10 @@ def has_service(**attributes):
def is_service_missing(**params): def is_service_missing(**params):
return not has_service(**params) # return False if it is called from a unit test
test_module_name = inspect.getmodule(tobiko.get_test_case()).__name__
return (not test_module_name.startswith('tobiko.tests.unit.') and
not has_service(**params))
def skip_if_missing_service(**params): def skip_if_missing_service(**params):

View File

@ -19,18 +19,11 @@ import mock
from tobiko.openstack import keystone from tobiko.openstack import keystone
from tobiko.openstack import heat from tobiko.openstack import heat
from tobiko.tests.unit import openstack from tobiko.tests.unit import openstack
from tobiko.tests.unit.openstack import test_client
MockClient = mock.create_autospec(heatclient.Client) MockClient = mock.create_autospec(heatclient.Client)
class HeatClientFixtureTest(test_client.OpenstackClientFixtureTest):
def create_client(self, session=None):
return heat.HeatClientFixture(session=session)
class GetHeatClientTest(openstack.OpenstackTest): class GetHeatClientTest(openstack.OpenstackTest):
def test_get_heat_client(self, session=None, shared=True): def test_get_heat_client(self, session=None, shared=True):