Fix senlin/sdk client plugin unit tests

New python-openstacksdk has broken the client plugins.
This also change to use `status_code` instead of `http_status`
of HttpException when checking for bad request.

Closes-Bug: #1746956
Change-Id: Ib1f295a6dea014df3237acf0efd6b84464eac9c1
This commit is contained in:
rabi 2018-02-02 16:14:13 +05:30
parent f62167f3de
commit 164a8ab2ba
3 changed files with 16 additions and 9 deletions

View File

@ -69,7 +69,7 @@ class SenlinClientPlugin(client_plugin.ClientPlugin):
def is_bad_request(self, ex): def is_bad_request(self, ex):
return (isinstance(ex, exc.sdkexc.HttpException) and return (isinstance(ex, exc.sdkexc.HttpException) and
ex.http_status == 400) ex.status_code == 400)
def execute_actions(self, actions): def execute_actions(self, actions):
all_executed = True all_executed = True

View File

@ -22,7 +22,8 @@ from heat.tests import utils
class OpenStackSDKPluginTest(common.HeatTestCase): class OpenStackSDKPluginTest(common.HeatTestCase):
def test_create(self): @mock.patch('openstack.connection.Connection')
def test_create(self, mock_connection):
context = utils.dummy_context() context = utils.dummy_context()
plugin = context.clients.client_plugin('openstack') plugin = context.clients.client_plugin('openstack')
client = plugin.client() client = plugin.client()

View File

@ -12,15 +12,16 @@
# under the License. # under the License.
import mock import mock
from senlinclient.common import exc
from heat.engine.clients.os import senlin as senlin_plugin from heat.engine.clients.os import senlin as senlin_plugin
from heat.tests import common from heat.tests import common
from heat.tests import utils from heat.tests import utils
from senlinclient.common import exc
class SenlinClientPluginTest(common.HeatTestCase): class SenlinClientPluginTest(common.HeatTestCase):
def setUp(self): @mock.patch('openstack.connection.Connection')
def setUp(self, mock_connection):
super(SenlinClientPluginTest, self).setUp() super(SenlinClientPluginTest, self).setUp()
context = utils.dummy_context() context = utils.dummy_context()
self.plugin = context.clients.client_plugin('senlin') self.plugin = context.clients.client_plugin('senlin')
@ -71,7 +72,8 @@ class SenlinClientPluginTest(common.HeatTestCase):
class ProfileConstraintTest(common.HeatTestCase): class ProfileConstraintTest(common.HeatTestCase):
def setUp(self): @mock.patch('openstack.connection.Connection')
def setUp(self, mock_connection):
super(ProfileConstraintTest, self).setUp() super(ProfileConstraintTest, self).setUp()
self.senlin_client = mock.MagicMock() self.senlin_client = mock.MagicMock()
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()
@ -95,7 +97,8 @@ class ProfileConstraintTest(common.HeatTestCase):
class ClusterConstraintTest(common.HeatTestCase): class ClusterConstraintTest(common.HeatTestCase):
def setUp(self): @mock.patch('openstack.connection.Connection')
def setUp(self, mock_connection):
super(ClusterConstraintTest, self).setUp() super(ClusterConstraintTest, self).setUp()
self.senlin_client = mock.MagicMock() self.senlin_client = mock.MagicMock()
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()
@ -119,7 +122,8 @@ class ClusterConstraintTest(common.HeatTestCase):
class PolicyConstraintTest(common.HeatTestCase): class PolicyConstraintTest(common.HeatTestCase):
def setUp(self): @mock.patch('openstack.connection.Connection')
def setUp(self, mock_connection):
super(PolicyConstraintTest, self).setUp() super(PolicyConstraintTest, self).setUp()
self.senlin_client = mock.MagicMock() self.senlin_client = mock.MagicMock()
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()
@ -143,7 +147,8 @@ class PolicyConstraintTest(common.HeatTestCase):
class ProfileTypeConstraintTest(common.HeatTestCase): class ProfileTypeConstraintTest(common.HeatTestCase):
def setUp(self): @mock.patch('openstack.connection.Connection')
def setUp(self, mock_connection):
super(ProfileTypeConstraintTest, self).setUp() super(ProfileTypeConstraintTest, self).setUp()
self.senlin_client = mock.MagicMock() self.senlin_client = mock.MagicMock()
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()
@ -168,7 +173,8 @@ class ProfileTypeConstraintTest(common.HeatTestCase):
class PolicyTypeConstraintTest(common.HeatTestCase): class PolicyTypeConstraintTest(common.HeatTestCase):
def setUp(self): @mock.patch('openstack.connection.Connection')
def setUp(self, mock_connection):
super(PolicyTypeConstraintTest, self).setUp() super(PolicyTypeConstraintTest, self).setUp()
self.senlin_client = mock.MagicMock() self.senlin_client = mock.MagicMock()
self.ctx = utils.dummy_context() self.ctx = utils.dummy_context()