Merge "Removed extra underlines in tests"

This commit is contained in:
Zuul 2018-09-25 02:59:31 +00:00 committed by Gerrit Code Review
commit 694bd525d5
32 changed files with 363 additions and 361 deletions

View File

@ -31,7 +31,7 @@ class TestTrustMiddleware(base.SenlinTestCase):
self.middleware = trust.TrustMiddleware(None)
@mock.patch("senlin.rpc.client.EngineClient")
def test__get_trust_already_exists(self, mock_rpc):
def test_get_trust_already_exists(self, mock_rpc):
x_cred = {'trust': 'FAKE_TRUST_ID'}
x_rpc = mock.Mock()
x_rpc.call.return_value = x_cred
@ -51,7 +51,7 @@ class TestTrustMiddleware(base.SenlinTestCase):
@mock.patch.object(context, "get_service_credentials")
@mock.patch("senlin.drivers.base.SenlinDriver")
@mock.patch("senlin.rpc.client.EngineClient")
def test__get_trust_bad(self, mock_rpc, mock_driver, mock_creds):
def test_get_trust_bad(self, mock_rpc, mock_driver, mock_creds):
x_cred = {'foo': 'bar'}
x_rpc = mock.Mock()
x_rpc.call.return_value = x_cred
@ -99,7 +99,7 @@ class TestTrustMiddleware(base.SenlinTestCase):
@mock.patch.object(context, "get_service_credentials")
@mock.patch("senlin.drivers.base.SenlinDriver")
@mock.patch("senlin.rpc.client.EngineClient")
def test__get_trust_not_found(self, mock_rpc, mock_driver, mock_creds):
def test_get_trust_not_found(self, mock_rpc, mock_driver, mock_creds):
x_rpc = mock.Mock()
x_rpc.call.return_value = None
mock_rpc.return_value = x_rpc
@ -137,7 +137,7 @@ class TestTrustMiddleware(base.SenlinTestCase):
@mock.patch.object(context, "get_service_credentials")
@mock.patch("senlin.drivers.base.SenlinDriver")
@mock.patch("senlin.rpc.client.EngineClient")
def test__get_trust_do_create(self, mock_rpc, mock_driver, mock_creds):
def test_get_trust_do_create(self, mock_rpc, mock_driver, mock_creds):
x_rpc = mock.Mock()
x_rpc.call.return_value = None
mock_rpc.return_value = x_rpc
@ -179,7 +179,7 @@ class TestTrustMiddleware(base.SenlinTestCase):
@mock.patch.object(context, "get_service_credentials")
@mock.patch("senlin.drivers.base.SenlinDriver")
@mock.patch("senlin.rpc.client.EngineClient")
def test__get_trust_fatal(self, mock_rpc, mock_driver, mock_creds):
def test_get_trust_fatal(self, mock_rpc, mock_driver, mock_creds):
x_rpc = mock.Mock()
x_rpc.call.return_value = None
mock_rpc.return_value = x_rpc

View File

@ -24,7 +24,7 @@ from senlin.tests.unit.common import base
@mock.patch("senlin.api.openstack.versions.Controller")
class VersionNegotiationTest(base.SenlinTestCase):
def test__get_version_controller(self, mock_vc):
def test_get_version_controller(self, mock_vc):
gvc = mock_vc.return_value
xvc = mock.Mock()
gvc.get_controller = mock.Mock(return_value=xvc)
@ -38,7 +38,7 @@ class VersionNegotiationTest(base.SenlinTestCase):
self.assertEqual(0, request.environ['api.minor'])
gvc.get_controller.assert_called_once_with('1.0')
def test__get_version_controller_shorter_version(self, mock_vc):
def test_get_version_controller_shorter_version(self, mock_vc):
gvc = mock_vc.return_value
xvc = mock.Mock()
gvc.get_controller = mock.Mock(return_value=xvc)
@ -52,7 +52,7 @@ class VersionNegotiationTest(base.SenlinTestCase):
self.assertEqual(0, request.environ['api.minor'])
gvc.get_controller.assert_called_once_with('1.0')
def test__get_controller_not_match_version(self, mock_vc):
def test_get_controller_not_match_version(self, mock_vc):
gvc = mock_vc.return_value
gvc.get_controller = mock.Mock(return_value=None)
vnf = vn.VersionNegotiationFilter(None, None)
@ -208,7 +208,7 @@ class VersionNegotiationTest(base.SenlinTestCase):
response = vnf.process_request(request)
self.assertEqual(gvc, response)
def test__check_version_request(self, mock_vc):
def test_check_version_request(self, mock_vc):
controller = mock.Mock()
minv = vr.APIVersionRequest('1.0')
maxv = vr.APIVersionRequest('1.3')
@ -224,7 +224,7 @@ class VersionNegotiationTest(base.SenlinTestCase):
expected = vr.APIVersionRequest('1.0')
self.assertEqual(expected, request.version_request)
def test__check_version_request_default(self, mock_vc):
def test_check_version_request_default(self, mock_vc):
controller = mock.Mock()
controller.DEFAULT_API_VERSION = "1.0"
request = webob.Request({'PATH_INFO': 'resource'})
@ -237,7 +237,7 @@ class VersionNegotiationTest(base.SenlinTestCase):
expected = vr.APIVersionRequest(controller.DEFAULT_API_VERSION)
self.assertEqual(expected, request.version_request)
def test__check_version_request_invalid_format(self, mock_vc):
def test_check_version_request_invalid_format(self, mock_vc):
controller = mock.Mock()
request = webob.Request({'PATH_INFO': 'resource'})
request.headers[wsgi.API_VERSION_KEY] = 'clustering 2.03'
@ -250,7 +250,7 @@ class VersionNegotiationTest(base.SenlinTestCase):
"must be of format 'major.minor'.",
six.text_type(ex))
def test__check_version_request_invalid_version(self, mock_vc):
def test_check_version_request_invalid_version(self, mock_vc):
controller = mock.Mock()
minv = vr.APIVersionRequest('1.0')
maxv = vr.APIVersionRequest('1.100')
@ -269,7 +269,7 @@ class VersionNegotiationTest(base.SenlinTestCase):
{'min_ver': str(minv), 'max_ver': str(maxv)})
self.assertEqual(expected, six.text_type(ex))
def test__check_version_request_latest(self, mock_vc):
def test_check_version_request_latest(self, mock_vc):
controller = mock.Mock()
controller.max_api_version = mock.Mock(return_value='12.34')

View File

@ -407,7 +407,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_add_nodes(self, mock_call, mock_parse, mock_enforce):
def test_do_add_nodes(self, mock_call, mock_parse, mock_enforce):
req = mock.Mock()
cid = 'FAKE_ID'
data = dict(nodes=['NODE1'])
@ -428,8 +428,8 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_add_nodes_failed_request(self, mock_call,
mock_parse, _ignore):
def test_do_add_nodes_failed_request(self, mock_call,
mock_parse, _ignore):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(nodes=['NODE2'])
@ -449,7 +449,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__add_nodes_failed_engine(self, mock_call, mock_parse, _ignore):
def test_add_nodes_failed_engine(self, mock_call, mock_parse, _ignore):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(nodes=['NODE3'])
@ -472,7 +472,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_del_nodes(self, mock_call, mock_parse, _ignore):
def test_do_del_nodes(self, mock_call, mock_parse, _ignore):
req = mock.Mock()
cid = 'FAKE_ID'
data = dict(nodes=['NODE4'], destroy=False)
@ -492,8 +492,8 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_del_nodes_failed_request(self, mock_call,
mock_parse, _ignore):
def test_do_del_nodes_failed_request(self, mock_call,
mock_parse, _ignore):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(nodes=['NODE5'], destroy=False)
@ -512,7 +512,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_del_nodes_failed_engine(self, mock_call, mock_parse, _ignore):
def test_do_del_nodes_failed_engine(self, mock_call, mock_parse, _ignore):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(nodes=['NODE6'], destroy=False)
@ -534,7 +534,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_replace_nodes(self, mock_call, mock_parse, _ignore):
def test_do_replace_nodes(self, mock_call, mock_parse, _ignore):
req = mock.Mock()
cid = 'FAKE_ID'
data = dict(nodes={'OLD': 'NEW'})
@ -555,7 +555,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_replace_nodes_none(self, mock_call, mock_parse, _ign):
def test_do_replace_nodes_none(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(nodes=None)
@ -569,8 +569,8 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_replace_nodes_failed_request(self, mock_call,
mock_parse, _ign):
def test_do_replace_nodes_failed_request(self, mock_call,
mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(nodes={'OLD': 'NEW'})
@ -590,8 +590,8 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_replace_nodes_failed_engine(self, mock_call,
mock_parse, _ign):
def test_do_replace_nodes_failed_engine(self, mock_call,
mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(nodes={'OLD': 'NEW'})
@ -641,18 +641,18 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
'ClusterResizeRequest', req, params)
mock_call.assert_called_once_with(req.context, 'cluster_resize', obj)
def test__do_resize_exact_capacity(self, mock_enforce):
def test_do_resize_exact_capacity(self, mock_enforce):
self._test_do_resize_with_type('EXACT_CAPACITY')
def test__do_resize_with_change_capacity(self, mock_enforce):
def test_do_resize_with_change_capacity(self, mock_enforce):
self._test_do_resize_with_type('CHANGE_IN_CAPACITY')
def test__do_resize_with_change_percentage(self, mock_enforce):
def test_do_resize_with_change_percentage(self, mock_enforce):
self._test_do_resize_with_type('CHANGE_IN_PERCENTAGE')
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_resize_failed_request(self, mock_call, mock_parse, _ign):
def test_do_resize_failed_request(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'adjustment_type': 'EXACT_CAPACITY', 'number': 10}
@ -674,7 +674,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_resize_missing_number(self, mock_call, mock_parse, _ign):
def test_do_resize_missing_number(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'adjustment_type': 'EXACT_CAPACITY'}
@ -690,7 +690,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_resize_missing_type(self, mock_call, mock_parse, _ign):
def test_do_resize_missing_type(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'number': 2}
@ -707,7 +707,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_resize_max_size_too_small(self, mock_call, mock_parse, _ign):
def test_do_resize_max_size_too_small(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'min_size': 2, 'max_size': 1}
@ -724,7 +724,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_resize_empty_params(self, mock_call, mock_parse, _ign):
def test_do_resize_empty_params(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {}
@ -739,7 +739,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_resize_failed_engine(self, mock_call, mock_parse, _ign):
def test_do_resize_failed_engine(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'max_size': 200}
@ -759,7 +759,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_scale_out(self, mock_call, mock_parse, _ignore):
def test_do_scale_out(self, mock_call, mock_parse, _ignore):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(count=1)
@ -780,7 +780,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_scale_out_failed_request(self, mock_call, mock_parse, _ign):
def test_do_scale_out_failed_request(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(count=2)
@ -800,7 +800,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_scale_out_failed_engine(self, mock_call, mock_parse, _ign):
def test_do_scale_out_failed_engine(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(count=3)
@ -823,7 +823,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_scale_in(self, mock_call, mock_parse, _ignore):
def test_do_scale_in(self, mock_call, mock_parse, _ignore):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(count=4)
@ -844,7 +844,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_scale_in_failed_request(self, mock_call, mock_parse, _ign):
def test_do_scale_in_failed_request(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(count=5)
@ -864,7 +864,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_scale_in_failed_engine(self, mock_call, mock_parse, _ign):
def test_do_scale_in_failed_engine(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = dict(count=6)
@ -887,7 +887,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_attach(self, mock_call, mock_parse, _ign):
def test_do_policy_attach(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -906,7 +906,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_attach_failed_request(self, mock_call, mock_parse, _i):
def test_do_policy_attach_failed_request(self, mock_call, mock_parse, _i):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -924,7 +924,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_attach_failed_engine(self, mock_call, mock_parse, _i):
def test_do_policy_attach_failed_engine(self, mock_call, mock_parse, _i):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -945,7 +945,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_detach(self, mock_call, mock_parse, _ign):
def test_do_policy_detach(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -964,7 +964,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_detach_failed_request(self, mock_call, mock_parse, _i):
def test_do_policy_detach_failed_request(self, mock_call, mock_parse, _i):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -982,7 +982,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_detach_failed_engine(self, mock_call, mock_parse, _i):
def test_do_policy_detach_failed_engine(self, mock_call, mock_parse, _i):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -1003,7 +1003,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_update(self, mock_call, mock_parse, _ign):
def test_do_policy_update(self, mock_call, mock_parse, _ign):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -1022,7 +1022,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_update_failed_request(self, mock_call, mock_parse, _i):
def test_do_policy_update_failed_request(self, mock_call, mock_parse, _i):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -1040,7 +1040,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_policy_update_failed_engine(self, mock_call, mock_parse, _i):
def test_do_policy_update_failed_engine(self, mock_call, mock_parse, _i):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'policy_id': 'xxxx-yyyy'}
@ -1061,7 +1061,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_check(self, mock_call, mock_parse, _ignore):
def test_do_check(self, mock_call, mock_parse, _ignore):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'op': 'value'}
@ -1080,7 +1080,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_check_failed_request(self, mock_call, mock_parse, _ign):
def test_do_check_failed_request(self, mock_call, mock_parse, _ign):
data = {}
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
@ -1097,7 +1097,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_check_failed_engine(self, mock_call, mock_parse, _i):
def test_do_check_failed_engine(self, mock_call, mock_parse, _i):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {}
@ -1117,7 +1117,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_recover(self, mock_call, mock_parse, _ignore):
def test_do_recover(self, mock_call, mock_parse, _ignore):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {'op': 'value'}
@ -1136,7 +1136,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_recover_failed_request(self, mock_call, mock_parse, _ign):
def test_do_recover_failed_request(self, mock_call, mock_parse, _ign):
data = {}
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
@ -1153,7 +1153,7 @@ class ClusterControllerTest(shared.ControllerTest, base.SenlinTestCase):
@mock.patch.object(util, 'parse_request')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__do_recover_failed_engine(self, mock_call, mock_parse, _i):
def test_do_recover_failed_engine(self, mock_call, mock_parse, _i):
req = mock.Mock()
cid = 'aaaa-bbbb-cccc'
data = {}

View File

@ -687,7 +687,7 @@ class ActionPolicyCheckTest(base.SenlinTestCase):
self.assertEqual(0, mock_pre_op.call_count)
self.assertEqual(0, mock_post_op.call_count)
def test__check_result_true(self):
def test_check_result_true(self):
cluster_id = CLUSTER_ID
action = ab.Action(cluster_id, 'OBJECT_ACTION', self.ctx)
action.data['status'] = policy_mod.CHECK_OK
@ -697,7 +697,7 @@ class ActionPolicyCheckTest(base.SenlinTestCase):
self.assertTrue(res)
def test__check_result_false(self):
def test_check_result_false(self):
cluster_id = CLUSTER_ID
action = ab.Action(cluster_id, 'OBJECT_ACTION', self.ctx)
action.data['status'] = policy_mod.CHECK_ERROR

View File

@ -36,7 +36,7 @@ class ClusterActionTest(base.SenlinTestCase):
self.ctx = utils.dummy_context()
@mock.patch.object(ab.Action, 'policy_check')
def test__execute(self, mock_check, mock_load):
def test_execute(self, mock_check, mock_load):
cluster = mock.Mock()
cluster.id = 'FAKE_CLUSTER'
mock_load.return_value = cluster
@ -122,7 +122,7 @@ class ClusterActionTest(base.SenlinTestCase):
@mock.patch.object(senlin_lock, 'cluster_lock_acquire')
@mock.patch.object(senlin_lock, 'cluster_lock_release')
def test_execute(self, mock_release, mock_acquire, mock_load):
def test_execute_with_locking(self, mock_release, mock_acquire, mock_load):
cluster = mock.Mock()
cluster.id = 'FAKE_CLUSTER'
mock_load.return_value = cluster

View File

@ -39,9 +39,9 @@ class ClusterCreateTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__create_nodes_single(self, mock_wait, mock_start, mock_dep,
mock_node, mock_index, mock_action,
mock_update, mock_load):
def test_create_nodes_single(self, mock_wait, mock_start, mock_dep,
mock_node, mock_index, mock_action,
mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', profile_id='FAKE_PROFILE',
user='FAKE_USER', project='FAKE_PROJECT',
@ -109,9 +109,9 @@ class ClusterCreateTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__create_nodes_multiple(self, mock_wait, mock_start, mock_dep,
mock_node, mock_index, mock_action,
mock_update, mock_load):
def test_create_nodes_multiple(self, mock_wait, mock_start, mock_dep,
mock_node, mock_index, mock_action,
mock_update, mock_load):
cluster = mock.Mock(id='01234567-123434',
config={"node.name.format": "node-$3I"})
node1 = mock.Mock(id='01234567-abcdef',
@ -183,9 +183,9 @@ class ClusterCreateTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__create_nodes_multiple_failed_wait(self, mock_wait, mock_start,
mock_dep, mock_node, mock_get,
mock_update, mock_load):
def test_create_nodes_multiple_failed_wait(self, mock_wait, mock_start,
mock_dep, mock_node, mock_get,
mock_update, mock_load):
cluster = mock.Mock(id='01234567-123434', config={})
db_cluster = mock.Mock(next_index=1)
mock_get.return_value = db_cluster

View File

@ -37,8 +37,8 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_single(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
def test_delete_nodes_single(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='FAKE_CLUSTER', desired_capacity=100, config={})
@ -73,9 +73,9 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_single_stop_node(self, mock_wait, mock_start,
mock_dep, mock_action, mock_update,
mock_load):
def test_delete_nodes_single_stop_node(self, mock_wait, mock_start,
mock_dep, mock_action, mock_update,
mock_load):
# prepare mocks
cluster = mock.Mock(id='FAKE_CLUSTER', desired_capacity=100,
config={'cluster.stop_node_before_delete': True})
@ -124,8 +124,8 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_multi(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
def test_delete_nodes_multi(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100, config={})
mock_load.return_value = cluster
@ -157,7 +157,7 @@ class ClusterDeleteTest(base.SenlinTestCase):
cluster.remove_node.assert_has_calls([
mock.call('NODE_1'), mock.call('NODE_2')])
def test__delete_empty(self, mock_load):
def test_delete_empty(self, mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID')
mock_load.return_value = cluster
@ -176,8 +176,8 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_with_pd(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
def test_delete_nodes_with_pd(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100, config={})
mock_load.return_value = cluster
@ -209,11 +209,11 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(msg.Message, 'post_lifecycle_hook_message')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_with_lifecycle_hook(self, mock_wait, mock_start,
mock_post, mock_dep,
mock_node_get,
mock_action, mock_update,
mock_load):
def test_delete_nodes_with_lifecycle_hook(self, mock_wait, mock_start,
mock_post, mock_dep,
mock_node_get,
mock_action, mock_update,
mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100, config={})
mock_load.return_value = cluster
@ -264,7 +264,7 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(msg.Message, 'post_lifecycle_hook_message')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_with_lifecycle_hook_failed_node(
def test_delete_nodes_with_lifecycle_hook_failed_node(
self, mock_wait, mock_start, mock_post, mock_dep, mock_node_get,
mock_action, mock_update, mock_load):
self.delete_nodes_with_lifecycle_hook_invalid_node(
@ -279,7 +279,7 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(msg.Message, 'post_lifecycle_hook_message')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_with_lifecycle_hook_missing_node(
def test_delete_nodes_with_lifecycle_hook_missing_node(
self, mock_wait, mock_start, mock_post, mock_dep, mock_node_get,
mock_action, mock_update, mock_load):
self.delete_nodes_with_lifecycle_hook_invalid_node(
@ -335,14 +335,14 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(msg.Message, 'post_lifecycle_hook_message')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_with_lifecycle_hook_timeout(self, mock_wait,
mock_start,
mock_post, mock_dep,
mock_node_get,
mock_action,
mock_update,
mock_check_status,
mock_load):
def test_delete_nodes_with_lifecycle_hook_timeout(self, mock_wait,
mock_start,
mock_post, mock_dep,
mock_node_get,
mock_action,
mock_update,
mock_check_status,
mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100, config={})
mock_load.return_value = cluster
@ -395,9 +395,9 @@ class ClusterDeleteTest(base.SenlinTestCase):
mock_wait.assert_has_calls(wait_calls)
@mock.patch.object(ab.Action, 'create')
def test__delete_nodes_with_lifecycle_hook_invalid_type(self,
mock_action,
mock_load):
def test_delete_nodes_with_lifecycle_hook_invalid_type(self,
mock_action,
mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100, config={})
mock_load.return_value = cluster
@ -424,10 +424,10 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(ao.Action, 'update')
@mock.patch.object(ab.Action, 'create')
def test__delete_nodes_with_lifecycle_hook_unsupported_webhook(self,
mock_action,
mock_update,
mock_load):
def test_delete_nodes_with_lifecycle_hook_unsupported_webhook(self,
mock_action,
mock_update,
mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100, config={})
mock_load.return_value = cluster
@ -453,8 +453,8 @@ class ClusterDeleteTest(base.SenlinTestCase):
"'webhook' is not implemented", res_msg)
@mock.patch.object(ca.ClusterAction, '_remove_nodes_normally')
def test__delete_nodes_failed_remove_stop_node(self, mock_remove,
mock_load):
def test_delete_nodes_failed_remove_stop_node(self, mock_remove,
mock_load):
# prepare mocks
cluster = mock.Mock(id='ID',
config={'cluster.stop_node_before_delete': True})
@ -481,7 +481,7 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(ca.ClusterAction, '_remove_nodes_with_hook')
@mock.patch.object(ca.ClusterAction, '_remove_nodes_normally')
def test__delete_nodes_with_lifecycle_hook_failed_remove_stop_node(
def test_delete_nodes_with_lifecycle_hook_failed_remove_stop_node(
self, mock_remove_normally, mock_remove_hook, mock_load):
# prepare mocks
cluster = mock.Mock(id='ID',
@ -773,8 +773,8 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__remove_nodes_normally(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
def test_remove_nodes_normally(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100)
mock_load.return_value = cluster
@ -810,9 +810,9 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(msg.Message, 'post_lifecycle_hook_message')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__remove_nodes_with_hook(self, mock_wait, mock_start, mock_post,
mock_dep, mock_node_get, mock_action,
mock_update, mock_load):
def test_remove_nodes_with_hook(self, mock_wait, mock_start, mock_post,
mock_dep, mock_node_get, mock_action,
mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100)
mock_load.return_value = cluster
@ -860,9 +860,9 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__remove_nodes_normally_failed_wait(self, mock_wait, mock_start,
mock_dep, mock_action,
mock_update, mock_load):
def test_remove_nodes_normally_failed_wait(self, mock_wait, mock_start,
mock_dep, mock_action,
mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='ID', config={})
mock_load.return_value = cluster
@ -888,9 +888,9 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__remove_nodes_hook_failed_wait(self, mock_wait, mock_start,
mock_dep, mock_action,
mock_update, mock_load):
def test_remove_nodes_hook_failed_wait(self, mock_wait, mock_start,
mock_dep, mock_action,
mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='ID', config={})
mock_load.return_value = cluster
@ -925,10 +925,10 @@ class ClusterDeleteTest(base.SenlinTestCase):
@mock.patch.object(msg.Message, 'post_lifecycle_hook_message')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__delete_nodes_with_error_nodes(self, mock_wait, mock_start,
mock_post, mock_dep,
mock_node_get, mock_action,
mock_update, mock_load):
def test_delete_nodes_with_error_nodes(self, mock_wait, mock_start,
mock_post, mock_dep,
mock_node_get, mock_action,
mock_update, mock_load):
# prepare mocks
cluster = mock.Mock(id='CLUSTER_ID', desired_capacity=100)
mock_load.return_value = cluster

View File

@ -366,7 +366,7 @@ class ClusterRecoverTest(base.SenlinTestCase):
mock_desired.assert_called_once_with()
@mock.patch.object(ca.ClusterAction, '_create_nodes')
def test__check_capacity_create(self, mock_create, mock_load):
def test_check_capacity_create(self, mock_create, mock_load):
node1 = mock.Mock(id='NODE_1', cluster_id='FAKE_ID', status='ACTIVE')
cluster = mock.Mock(id='FAKE_ID', RECOVERING='RECOVERING',
@ -383,8 +383,8 @@ class ClusterRecoverTest(base.SenlinTestCase):
@mock.patch.object(su, 'nodes_by_random')
@mock.patch.object(no.Node, 'get_all_by_cluster')
@mock.patch.object(ca.ClusterAction, '_delete_nodes')
def test__check_capacity_delete(self, mock_delete, mock_get,
mock_su, mock_load):
def test_check_capacity_delete(self, mock_delete, mock_get,
mock_su, mock_load):
node1 = mock.Mock(id='NODE_1', cluster_id='FAKE_ID', status='ACTIVE')
node2 = mock.Mock(id='NODE_2', cluster_id='FAKE_ID', status='ERROR')

View File

@ -28,7 +28,7 @@ class ClusterResizeTest(base.SenlinTestCase):
super(ClusterResizeTest, self).setUp()
self.ctx = utils.dummy_context()
def test__update_cluster_size(self, mock_load):
def test_update_cluster_size(self, mock_load):
cluster = mock.Mock(id='CID', desired_capacity=10, nodes=[])
mock_load.return_value = cluster
action = ca.ClusterAction(cluster.id, 'CLUSTER_RESIZE', self.ctx,
@ -40,7 +40,7 @@ class ClusterResizeTest(base.SenlinTestCase):
action.context, consts.CS_RESIZING, 'Cluster resize started.',
desired_capacity=15, min_size=1, max_size=20)
def test__update_cluster_size_minimum(self, mock_load):
def test_update_cluster_size_minimum(self, mock_load):
cluster = mock.Mock(id='CID', desired_capacity=10, nodes=[])
mock_load.return_value = cluster
action = ca.ClusterAction(cluster.id, 'CLUSTER_RESIZE', self.ctx,

View File

@ -144,8 +144,8 @@ class ClusterUpdateTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__update_nodes_no_policy(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
def test_update_nodes_no_policy(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
node1 = mock.Mock(id='node_id1')
node2 = mock.Mock(id='node_id2')
cluster = mock.Mock(id='FAKE_ID', nodes=[node1, node2],
@ -176,8 +176,8 @@ class ClusterUpdateTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__update_nodes_batch_policy(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
def test_update_nodes_batch_policy(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
node1 = mock.Mock(id='node_id1')
node2 = mock.Mock(id='node_id2')
cluster = mock.Mock(id='FAKE_ID', nodes=[node1, node2],
@ -215,8 +215,8 @@ class ClusterUpdateTest(base.SenlinTestCase):
@mock.patch.object(dobj.Dependency, 'create')
@mock.patch.object(dispatcher, 'start_action')
@mock.patch.object(ca.ClusterAction, '_wait_for_dependents')
def test__update_nodes_fail_wait(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
def test_update_nodes_fail_wait(self, mock_wait, mock_start, mock_dep,
mock_action, mock_update, mock_load):
node1 = mock.Mock(id='node_id1')
node2 = mock.Mock(id='node_id2')
cluster = mock.Mock(id='FAKE_ID', nodes=[node1, node2],

View File

@ -87,7 +87,7 @@ class TestMessage(base.SenlinTestCase):
mock_param.assert_called_once_with('user1', 'project1')
sd.message.assert_called_once_with(params)
def test__generate_subscriber_url_host_provided(self):
def test_generate_subscriber_url_host_provided(self):
cfg.CONF.set_override('host', 'web.com', 'receiver')
cfg.CONF.set_override('port', '1234', 'receiver')
message = mmod.Message('message', None, None, id=UUID)
@ -97,7 +97,7 @@ class TestMessage(base.SenlinTestCase):
self.assertEqual(expected, res)
@mock.patch.object(mmod.Message, '_get_base_url')
def test__generate_subscriber_url_host_not_provided(
def test_generate_subscriber_url_host_not_provided(
self, mock_get_base_url):
mock_get_base_url.return_value = 'http://web.com:1234/v1'
message = mmod.Message('message', None, None, id=UUID)
@ -108,7 +108,7 @@ class TestMessage(base.SenlinTestCase):
@mock.patch.object(socket, 'gethostname')
@mock.patch.object(mmod.Message, '_get_base_url')
def test__generate_subscriber_url_no_host_no_base(
def test_generate_subscriber_url_no_host_no_base(
self, mock_get_base_url, mock_gethostname):
mock_get_base_url.return_value = None
mock_gethostname.return_value = 'test-host'
@ -160,7 +160,7 @@ class TestMessage(base.SenlinTestCase):
mock_create_subscription.assert_called_once_with('test-queue')
@mock.patch.object(mmod.Message, 'zaqar')
def test__create_queue(self, mock_zaqar):
def test_create_queue(self, mock_zaqar):
cfg.CONF.set_override('max_message_size', 8192, 'receiver')
mock_zc = mock.Mock()
mock_zaqar.return_value = mock_zc
@ -178,7 +178,7 @@ class TestMessage(base.SenlinTestCase):
mock_zc.queue_create.assert_called_once_with(**kwargs)
@mock.patch.object(mmod.Message, 'zaqar')
def test__create_queue_fail(self, mock_zaqar):
def test_create_queue_fail(self, mock_zaqar):
cfg.CONF.set_override('max_message_size', 8192, 'receiver')
mock_zc = mock.Mock()
mock_zaqar.return_value = mock_zc
@ -196,8 +196,8 @@ class TestMessage(base.SenlinTestCase):
@mock.patch.object(mmod.Message, '_generate_subscriber_url')
@mock.patch.object(mmod.Message, '_build_trust')
@mock.patch.object(mmod.Message, 'zaqar')
def test__create_subscription(self, mock_zaqar, mock_build_trust,
mock_generate_subscriber_url):
def test_create_subscription(self, mock_zaqar, mock_build_trust,
mock_generate_subscriber_url):
mock_zc = mock.Mock()
mock_zaqar.return_value = mock_zc
mock_build_trust.return_value = '123abc'
@ -223,8 +223,8 @@ class TestMessage(base.SenlinTestCase):
@mock.patch.object(mmod.Message, '_generate_subscriber_url')
@mock.patch.object(mmod.Message, '_build_trust')
@mock.patch.object(mmod.Message, 'zaqar')
def test__create_subscription_fail(self, mock_zaqar, mock_build_trust,
mock_generate_subscriber_url):
def test_create_subscription_fail(self, mock_zaqar, mock_build_trust,
mock_generate_subscriber_url):
mock_zc = mock.Mock()
mock_zaqar.return_value = mock_zc
mock_build_trust.return_value = '123abc'
@ -296,8 +296,8 @@ class TestMessage(base.SenlinTestCase):
@mock.patch.object(ks_loading, 'load_auth_from_conf_options')
@mock.patch.object(ks_loading, 'load_session_from_conf_options')
@mock.patch.object(mmod.Message, 'keystone')
def test__build_trust_exists(self, mock_keystone, mock_load_session,
mock_load_auth):
def test_build_trust_exists(self, mock_keystone, mock_load_session,
mock_load_auth):
mock_auth = mock.Mock()
mock_session = mock.Mock()
mock_session.get_user_id.return_value = 'zaqar-trustee-user-id'
@ -324,7 +324,7 @@ class TestMessage(base.SenlinTestCase):
@mock.patch.object(ks_loading, 'load_auth_from_conf_options')
@mock.patch.object(ks_loading, 'load_session_from_conf_options')
@mock.patch.object(mmod.Message, 'keystone')
def test__build_trust_create_new_multiroles(
def test_build_trust_create_new_multiroles(
self, mock_keystone, mock_load_session, mock_load_auth):
mock_auth = mock.Mock()
mock_session = mock.Mock()
@ -352,7 +352,7 @@ class TestMessage(base.SenlinTestCase):
@mock.patch.object(ks_loading, 'load_auth_from_conf_options')
@mock.patch.object(ks_loading, 'load_session_from_conf_options')
@mock.patch.object(mmod.Message, 'keystone')
def test__build_trust_create_new_single_admin_role(
def test_build_trust_create_new_single_admin_role(
self, mock_keystone, mock_load_session, mock_load_auth):
mock_auth = mock.Mock()
mock_session = mock.Mock()
@ -380,9 +380,9 @@ class TestMessage(base.SenlinTestCase):
@mock.patch.object(ks_loading, 'load_auth_from_conf_options')
@mock.patch.object(ks_loading, 'load_session_from_conf_options')
@mock.patch.object(mmod.Message, 'keystone')
def test__build_trust_create_new_trust_failed(self, mock_keystone,
mock_load_session,
mock_load_auth):
def test_build_trust_create_new_trust_failed(self, mock_keystone,
mock_load_session,
mock_load_auth):
mock_auth = mock.Mock()
mock_session = mock.Mock()
mock_session.get_user_id.return_value = 'zaqar-trustee-user-id'
@ -409,9 +409,9 @@ class TestMessage(base.SenlinTestCase):
@mock.patch.object(ks_loading, 'load_auth_from_conf_options')
@mock.patch.object(ks_loading, 'load_session_from_conf_options')
@mock.patch.object(mmod.Message, 'keystone')
def test__build_trust_get_trust_exception(self, mock_keystone,
mock_load_session,
mock_load_auth):
def test_build_trust_get_trust_exception(self, mock_keystone,
mock_load_session,
mock_load_auth):
mock_auth = mock.Mock()
mock_session = mock.Mock()
mock_session.get_user_id.return_value = 'zaqar-trustee-user-id'

View File

@ -289,8 +289,8 @@ class TestReceiver(base.SenlinTestCase):
@mock.patch.object(context, "get_service_credentials")
@mock.patch.object(driver_base, "SenlinDriver")
def test__get_base_url_succeeded(self, mock_senlin_driver,
mock_get_service_creds):
def test_get_base_url_succeeded(self, mock_senlin_driver,
mock_get_service_creds):
cfg.CONF.set_override('default_region_name', 'RegionOne')
fake_driver = mock.Mock()
fake_kc = mock.Mock()
@ -312,7 +312,7 @@ class TestReceiver(base.SenlinTestCase):
@mock.patch.object(context, "get_service_credentials")
@mock.patch.object(driver_base, "SenlinDriver")
def test__get_base_url_failed_get_endpoint_exception(
def test_get_base_url_failed_get_endpoint_exception(
self, mock_senlin_driver, mock_get_service_creds):
cfg.CONF.set_override('default_region_name', 'RegionOne')
fake_driver = mock.Mock()

View File

@ -1570,7 +1570,7 @@ class ClusterTest(base.SenlinTestCase):
@mock.patch.object(no.Node, 'find')
@mock.patch.object(po.Profile, 'get')
def test__validate_replace_nodes(self, mock_profile, mock_node):
def test_validate_replace_nodes(self, mock_profile, mock_node):
cluster = mock.Mock(id='CID', profile_id='FAKE_ID')
mock_profile.return_value = mock.Mock(type='FAKE_TYPE')
mock_node.side_effect = [
@ -1595,8 +1595,8 @@ class ClusterTest(base.SenlinTestCase):
@mock.patch.object(no.Node, 'find')
@mock.patch.object(po.Profile, 'get')
def test__validate_replace_nodes_old_missing(self, mock_profile,
mock_node):
def test_validate_replace_nodes_old_missing(self, mock_profile,
mock_node):
c = mock.Mock(id='CID', profile_id='FAKE_ID')
mock_node.side_effect = exc.ResourceNotFound(type='node', id='OLD')
@ -1610,8 +1610,8 @@ class ClusterTest(base.SenlinTestCase):
@mock.patch.object(no.Node, 'find')
@mock.patch.object(po.Profile, 'get')
def test__validate_replace_nodes_new_missing(self, mock_profile,
mock_node):
def test_validate_replace_nodes_new_missing(self, mock_profile,
mock_node):
c = mock.Mock(id='CID', profile_id='FAKE_ID')
mock_node.side_effect = [
mock.Mock(),
@ -1632,8 +1632,8 @@ class ClusterTest(base.SenlinTestCase):
@mock.patch.object(no.Node, 'find')
@mock.patch.object(po.Profile, 'get')
def test__validate_replace_nodes_old_not_member(self, mock_profile,
mock_node):
def test_validate_replace_nodes_old_not_member(self, mock_profile,
mock_node):
c = mock.Mock(id='CID', profile_id='FAKE_ID')
mock_node.side_effect = [
mock.Mock(cluster_id='OTHER'),
@ -1654,8 +1654,8 @@ class ClusterTest(base.SenlinTestCase):
@mock.patch.object(no.Node, 'find')
@mock.patch.object(po.Profile, 'get')
def test__validate_replace_nodes_new_not_orphan(self, mock_profile,
mock_node):
def test_validate_replace_nodes_new_not_orphan(self, mock_profile,
mock_node):
c = mock.Mock(id='CID', profile_id='FAKE_ID')
mock_node.side_effect = [
mock.Mock(cluster_id='CID'),
@ -1676,8 +1676,8 @@ class ClusterTest(base.SenlinTestCase):
@mock.patch.object(no.Node, 'find')
@mock.patch.object(po.Profile, 'get')
def test__validate_replace_nodes_new_bad_status(self, mock_profile,
mock_node):
def test_validate_replace_nodes_new_bad_status(self, mock_profile,
mock_node):
c = mock.Mock(id='CID', profile_id='FAKE_ID')
mock_node.side_effect = [
mock.Mock(cluster_id='CID'),
@ -1697,8 +1697,8 @@ class ClusterTest(base.SenlinTestCase):
@mock.patch.object(no.Node, 'find')
@mock.patch.object(po.Profile, 'get')
def test__validate_replace_nodes_mult_err(self, mock_profile,
mock_node):
def test_validate_replace_nodes_mult_err(self, mock_profile,
mock_node):
c = mock.Mock(id='CID', profile_id='FAKE_ID')
mock_node.side_effect = [
mock.Mock(id='OLD1', cluster_id='CID'),
@ -1721,7 +1721,7 @@ class ClusterTest(base.SenlinTestCase):
@mock.patch.object(no.Node, 'find')
@mock.patch.object(po.Profile, 'get')
def test__validate_replace_nodes_new_profile_type_mismatch(
def test_validate_replace_nodes_new_profile_type_mismatch(
self, mock_profile, mock_node):
c = mock.Mock(id='CID', profile_id='FAKE_CLUSTER_PROFILE')
mock_profile.side_effect = [

View File

@ -708,7 +708,7 @@ class NodeTest(base.SenlinTestCase):
@mock.patch.object(environment.Environment, 'get_profile')
@mock.patch.object(pb.Profile, 'adopt_node')
def test__node_adopt_preview(self, mock_adopt, mock_profile):
def test_node_adopt_preview_with_profile(self, mock_adopt, mock_profile):
class FakeProfile(object):
pass
@ -742,7 +742,7 @@ class NodeTest(base.SenlinTestCase):
self.assertEqual(expected, s)
@mock.patch.object(pb.Profile, 'adopt_node')
def test__node_adopt_preview_bad_type(self, mock_adopt):
def test_node_adopt_preview_bad_type(self, mock_adopt):
req = mock.Mock(
identity="FAKE_NODE",
type="TestProfile-1.0",
@ -760,7 +760,7 @@ class NodeTest(base.SenlinTestCase):
@mock.patch.object(environment.Environment, 'get_profile')
@mock.patch.object(pb.Profile, 'adopt_node')
def test__node_adopt_preview_failed_adopt(self, mock_adopt, mock_profile):
def test_node_adopt_preview_failed_adopt(self, mock_adopt, mock_profile):
class FakeProfile(object):
pass

View File

@ -87,8 +87,8 @@ class TestCluster(base.SenlinTestCase):
@mock.patch.object(pcb.Policy, 'load')
@mock.patch.object(pfb.Profile, 'load')
@mock.patch.object(no.Node, 'get_all_by_cluster')
def test__load_runtime_data(self, mock_nodes, mock_profile, mock_policy,
mock_pb):
def test_load_runtime_data(self, mock_nodes, mock_profile, mock_policy,
mock_pb):
x_binding = mock.Mock()
x_binding.policy_id = POLICY_ID
mock_pb.return_value = [x_binding]
@ -121,7 +121,7 @@ class TestCluster(base.SenlinTestCase):
project_safe=False)
mock_nodes.assert_called_once_with(self.context, CLUSTER_ID)
def test__load_runtime_data_id_is_none(self):
def test_load_runtime_data_id_is_none(self):
cluster = cm.Cluster('test-cluster', 0, PROFILE_ID)
cluster._load_runtime_data(self.context)

View File

@ -169,7 +169,7 @@ class EngineStatusTest(base.SenlinTestCase):
@mock.patch.object(service_obj.Service, 'gc_by_engine')
@mock.patch.object(service_obj.Service, 'get_all')
@mock.patch.object(service_obj.Service, 'delete')
def test__service_manage_cleanup(self, mock_delete, mock_get_all, mock_gc):
def test_service_manage_cleanup(self, mock_delete, mock_get_all, mock_gc):
delta = datetime.timedelta(seconds=2 * cfg.CONF.periodic_interval)
ages_a_go = timeutils.utcnow(True) - delta
mock_get_all.return_value = [{'id': 'foo', 'updated_at': ages_a_go}]
@ -181,8 +181,10 @@ class EngineStatusTest(base.SenlinTestCase):
@mock.patch('senlin.engine.health_manager.HealthManager')
@mock.patch('oslo_messaging.Target')
@mock.patch.object(service_obj.Service, 'get_all')
def test_service_manage_cleanup(self, mock_get_all, mock_msg_cls,
mock_hm_cls, mock_disp_cls):
def test_service_manage_cleanup_without_exception(self, mock_get_all,
mock_msg_cls,
mock_hm_cls,
mock_disp_cls):
cfg.CONF.set_override('periodic_interval', 1)
# start engine and verify that get_all is being called more than once

View File

@ -53,7 +53,7 @@ class TestEvent(testtools.TestCase):
invoke_on_load=True,
propagate_map_exceptions=True)
def test__event_data(self):
def test_event_data(self):
entity = mock.Mock(id='ENTITY_ID')
entity.name = 'FAKE_ENTITY'
action = mock.Mock(id='ACTION_ID', action='ACTION', entity=entity)
@ -65,7 +65,7 @@ class TestEvent(testtools.TestCase):
'id': 'ACTION_I'},
res)
def test__event_data_with_phase_reason(self):
def test_event_data_with_phase_reason(self):
entity = mock.Mock(id='ENTITY_ID')
entity.name = 'FAKE_ENTITY'
action = mock.Mock(id='ACTION_ID', action='ACTION', entity=entity)
@ -77,7 +77,7 @@ class TestEvent(testtools.TestCase):
'obj_id': 'ENTITY_I', 'reason': 'REASON1'},
res)
def test__dump(self):
def test_dump(self):
cfg.CONF.set_override('debug', True)
saved_dispathers = event.dispatchers
event.dispatchers = mock.Mock()
@ -90,7 +90,7 @@ class TestEvent(testtools.TestCase):
finally:
event.dispatchers = saved_dispathers
def test__dump_without_timestamp(self):
def test_dump_without_timestamp(self):
cfg.CONF.set_override('debug', True)
saved_dispathers = event.dispatchers
event.dispatchers = mock.Mock()
@ -104,7 +104,7 @@ class TestEvent(testtools.TestCase):
finally:
event.dispatchers = saved_dispathers
def test__dump_guarded(self):
def test_dump_guarded(self):
cfg.CONF.set_override('debug', False)
cfg.CONF.set_override('priority', 'warning', group='dispatchers')
saved_dispathers = event.dispatchers
@ -117,7 +117,7 @@ class TestEvent(testtools.TestCase):
finally:
event.dispatchers = saved_dispathers
def test__dump_exclude_derived_actions_positive(self):
def test_dump_exclude_derived_actions_positive(self):
cfg.CONF.set_override('exclude_derived_actions', True,
group='dispatchers')
saved_dispathers = event.dispatchers
@ -130,7 +130,7 @@ class TestEvent(testtools.TestCase):
finally:
event.dispatchers = saved_dispathers
def test__dump_exclude_derived_actions_negative(self):
def test_dump_exclude_derived_actions_negative(self):
cfg.CONF.set_override('exclude_derived_actions', False,
group='dispatchers')
saved_dispathers = event.dispatchers
@ -145,7 +145,7 @@ class TestEvent(testtools.TestCase):
finally:
event.dispatchers = saved_dispathers
def test__dump_with_exception(self):
def test_dump_with_exception(self):
cfg.CONF.set_override('debug', True)
saved_dispathers = event.dispatchers
event.dispatchers = mock.Mock()

View File

@ -522,13 +522,13 @@ class TestHealthManager(base.SenlinTestCase):
self.assertEqual(0, len(self.hm.rt['registries']))
@mock.patch.object(hm.HealthManager, "_load_runtime_registry")
def test__dummy_task(self, mock_load):
def test_dummy_task(self, mock_load):
self.hm._dummy_task()
mock_load.assert_called_once_with()
@mock.patch.object(hr.HealthRegistry, 'claim')
@mock.patch.object(objects.HealthRegistry, 'update')
def test__load_runtime_registry(self, mock_update, mock_claim):
def test_load_runtime_registry(self, mock_update, mock_claim):
mock_claim.return_value = [
mock.Mock(cluster_id='CID1',
check_type=consts.NODE_STATUS_POLLING,
@ -580,7 +580,7 @@ class TestHealthManager(base.SenlinTestCase):
},
self.hm.registries[1])
def test__expand_url_template(self):
def test_expand_url_template(self):
url_template = 'https://abc123/foo/bar'
node = mock.Mock()
@ -589,7 +589,7 @@ class TestHealthManager(base.SenlinTestCase):
self.assertEqual(res, url_template)
def test__expand_url_template_nodename(self):
def test_expand_url_template_nodename(self):
node = mock.Mock()
node.name = 'name'
url_template = 'https://abc123/{nodename}/bar'
@ -606,8 +606,8 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(obj_cluster.Cluster, 'get')
@mock.patch.object(context, 'get_service_context')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__poll_cluster(self, mock_rpc, mock_ctx, mock_get,
mock_wait, mock_nodes, mock_chase):
def test_poll_cluster(self, mock_rpc, mock_ctx, mock_get,
mock_wait, mock_nodes, mock_chase):
x_cluster = mock.Mock(user='USER_ID', project='PROJECT_ID')
mock_get.return_value = x_cluster
ctx = mock.Mock()
@ -638,7 +638,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm, "_chase_up")
@mock.patch.object(obj_cluster.Cluster, 'get')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__poll_cluster_not_found(self, mock_check, mock_get, mock_chase):
def test_poll_cluster_not_found(self, mock_check, mock_get, mock_chase):
mock_get.return_value = None
recover_action = {'operation': 'REBUILD'}
@ -653,8 +653,8 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(context, 'get_service_context')
@mock.patch.object(obj_cluster.Cluster, 'get')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__poll_cluster_failed_check_rpc(self, mock_check, mock_get,
mock_ctx, mock_chase):
def test_poll_cluster_failed_check_rpc(self, mock_check, mock_get,
mock_ctx, mock_chase):
x_cluster = mock.Mock(user='USER_ID', project='PROJECT_ID')
mock_get.return_value = x_cluster
ctx = mock.Mock()
@ -678,8 +678,8 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(obj_cluster.Cluster, 'get')
@mock.patch.object(context, 'get_service_context')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__poll_cluster_failed_wait(self, mock_rpc, mock_ctx,
mock_get, mock_wait, mock_chase):
def test_poll_cluster_failed_wait(self, mock_rpc, mock_ctx,
mock_get, mock_wait, mock_chase):
x_cluster = mock.Mock(user='USER_ID', project='PROJECT_ID')
mock_get.return_value = x_cluster
ctx = mock.Mock()
@ -705,7 +705,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_expand_url_template")
@mock.patch.object(utils, 'url_fetch')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__check_url_and_recover_node_healthy(
def test_check_url_and_recover_node_healthy(
self, mock_rpc, mock_url_fetch, mock_expand_url, mock_time):
ctx = mock.Mock()
node = mock.Mock()
@ -741,7 +741,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_expand_url_template")
@mock.patch.object(utils, 'url_fetch')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__check_url_and_recover_node_unhealthy_inactive(
def test_check_url_and_recover_node_unhealthy_inactive(
self, mock_rpc, mock_url_fetch, mock_expand_url, mock_time):
ctx = mock.Mock()
node = mock.Mock()
@ -776,7 +776,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_expand_url_template")
@mock.patch.object(utils, 'url_fetch')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__check_url_and_recover_node_unhealthy_update_timeout(
def test_check_url_and_recover_node_unhealthy_update_timeout(
self, mock_rpc, mock_url_fetch, mock_expand_url, mock_time):
ctx = mock.Mock()
node = mock.Mock()
@ -813,7 +813,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_expand_url_template")
@mock.patch.object(utils, 'url_fetch')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__check_url_and_recover_node_unhealthy_init_timeout(
def test_check_url_and_recover_node_unhealthy_init_timeout(
self, mock_rpc, mock_url_fetch, mock_expand_url, mock_time):
ctx = mock.Mock()
node = mock.Mock()
@ -852,10 +852,10 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_expand_url_template")
@mock.patch.object(utils, 'url_fetch')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__check_url_and_recover_node_unhealthy(self,
mock_rpc, mock_url_fetch,
mock_expand_url, mock_time,
mock_sleep):
def test_check_url_and_recover_node_unhealthy(self,
mock_rpc, mock_url_fetch,
mock_expand_url, mock_time,
mock_sleep):
ctx = mock.Mock()
node = mock.Mock()
node.status = consts.NS_ACTIVE
@ -896,7 +896,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_expand_url_template")
@mock.patch.object(utils, 'url_fetch')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__check_url_and_recover_node_conn_error(
def test_check_url_and_recover_node_conn_error(
self, mock_rpc, mock_url_fetch, mock_expand_url, mock_time,
mock_sleep):
ctx = mock.Mock()
@ -939,7 +939,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_expand_url_template")
@mock.patch.object(utils, 'url_fetch')
@mock.patch.object(rpc_client.EngineClient, 'call')
def test__check_url_and_recover_node_conn_error_noop(
def test_check_url_and_recover_node_conn_error_noop(
self, mock_rpc, mock_url_fetch, mock_expand_url, mock_time,
mock_sleep):
ctx = mock.Mock()
@ -980,8 +980,8 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_wait_for_action")
@mock.patch.object(obj_cluster.Cluster, 'get')
@mock.patch.object(context, 'get_service_context')
def test__poll_url(self, mock_ctx, mock_get, mock_wait, mock_nodes,
mock_check_url, mock_chase):
def test_poll_url(self, mock_ctx, mock_get, mock_wait, mock_nodes,
mock_check_url, mock_chase):
x_cluster = mock.Mock(user='USER_ID', project='PROJECT_ID')
mock_get.return_value = x_cluster
ctx = mock.Mock()
@ -1011,8 +1011,8 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm, "_chase_up")
@mock.patch.object(obj_cluster.Cluster, 'get')
@mock.patch.object(context, 'get_service_context')
def test__poll_url_cluster_not_found(self, mock_ctx, mock_get,
mock_chase):
def test_poll_url_cluster_not_found(self, mock_ctx, mock_get,
mock_chase):
mock_get.return_value = None
recover_action = {'operation': 'REBUILD'}
@ -1031,8 +1031,8 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(hm.HealthManager, "_wait_for_action")
@mock.patch.object(obj_cluster.Cluster, 'get')
@mock.patch.object(context, 'get_service_context')
def test__poll_url_no_action(self, mock_ctx, mock_get, mock_wait,
mock_nodes, mock_check_url, mock_chase):
def test_poll_url_no_action(self, mock_ctx, mock_get, mock_wait,
mock_nodes, mock_check_url, mock_chase):
x_cluster = mock.Mock(user='USER_ID', project='PROJECT_ID')
mock_get.return_value = x_cluster
ctx = mock.Mock()
@ -1060,7 +1060,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(obj_profile.Profile, 'get')
@mock.patch.object(obj_cluster.Cluster, 'get')
def test__add_listener_nova(self, mock_cluster, mock_profile):
def test_add_listener_nova(self, mock_cluster, mock_profile):
cfg.CONF.set_override('nova_control_exchange', 'FAKE_NOVA_EXCHANGE',
group='health_manager')
x_listener = mock.Mock()
@ -1087,7 +1087,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(obj_profile.Profile, 'get')
@mock.patch.object(obj_cluster.Cluster, 'get')
def test__add_listener_heat(self, mock_cluster, mock_profile):
def test_add_listener_heat(self, mock_cluster, mock_profile):
cfg.CONF.set_override('heat_control_exchange', 'FAKE_HEAT_EXCHANGE',
group='health_manager')
x_listener = mock.Mock()
@ -1114,7 +1114,7 @@ class TestHealthManager(base.SenlinTestCase):
@mock.patch.object(obj_profile.Profile, 'get')
@mock.patch.object(obj_cluster.Cluster, 'get')
def test__add_listener_other_types(self, mock_cluster, mock_profile):
def test_add_listener_other_types(self, mock_cluster, mock_profile):
mock_add_thread = self.patchobject(self.hm.TG, 'add_thread')
x_cluster = mock.Mock(project='PROJECT_ID', profile_id='PROFILE_ID')
mock_cluster.return_value = x_cluster
@ -1134,7 +1134,7 @@ class TestHealthManager(base.SenlinTestCase):
self.assertFalse(mock_add_thread.called)
@mock.patch.object(obj_cluster.Cluster, 'get')
def test__add_listener_cluster_not_found(self, mock_get):
def test_add_listener_cluster_not_found(self, mock_get):
mock_get.return_value = None
mock_add_thread = self.patchobject(self.hm.TG, 'add_thread')
@ -1148,7 +1148,7 @@ class TestHealthManager(base.SenlinTestCase):
project_safe=False)
self.assertEqual(0, mock_add_thread.call_count)
def test__start_check_for_polling(self):
def test_start_check_for_polling(self):
x_timer = mock.Mock()
mock_add_timer = self.patchobject(self.hm.TG, 'add_dynamic_timer',
return_value=x_timer)
@ -1168,7 +1168,7 @@ class TestHealthManager(base.SenlinTestCase):
mock_add_timer.assert_called_once_with(
self.hm._poll_cluster, None, None, 'CCID', 12, recover_action)
def test__start_check_for_poll_url(self):
def test_start_check_for_poll_url(self):
x_timer = mock.Mock()
mock_add_timer = self.patchobject(self.hm.TG, 'add_dynamic_timer',
return_value=x_timer)
@ -1197,7 +1197,7 @@ class TestHealthManager(base.SenlinTestCase):
self.hm._poll_url, None, None, 'CCID', 12, recover_action,
entry['params'])
def test__start_check_for_listening(self):
def test_start_check_for_listening(self):
x_listener = mock.Mock()
mock_add_listener = self.patchobject(self.hm, '_add_listener',
return_value=x_listener)
@ -1215,7 +1215,7 @@ class TestHealthManager(base.SenlinTestCase):
self.assertEqual(expected, res)
mock_add_listener.assert_called_once_with('CCID', recover_action)
def test__start_check_for_listening_failed(self):
def test_start_check_for_listening_failed(self):
mock_add_listener = self.patchobject(self.hm, '_add_listener',
return_value=None)
@ -1230,7 +1230,7 @@ class TestHealthManager(base.SenlinTestCase):
self.assertIsNone(res)
mock_add_listener.assert_called_once_with('CCID', recover_action)
def test__start_check_other_types(self):
def test_start_check_other_types(self):
entry = {
'cluster_id': 'CCID',
'check_type': 'BOGUS TYPE',
@ -1240,7 +1240,7 @@ class TestHealthManager(base.SenlinTestCase):
self.assertIsNone(res)
def test__stop_check_with_timer(self):
def test_stop_check_with_timer(self):
x_timer = mock.Mock()
entry = {'timer': x_timer}
mock_timer_done = self.patchobject(self.hm.TG, 'timer_done')
@ -1252,7 +1252,7 @@ class TestHealthManager(base.SenlinTestCase):
x_timer.stop.assert_called_once_with()
mock_timer_done.assert_called_once_with(x_timer)
def test__stop_check_with_listener(self):
def test_stop_check_with_listener(self):
x_thread = mock.Mock()
entry = {'listener': x_thread}
mock_thread_done = self.patchobject(self.hm.TG, 'thread_done')

View File

@ -27,7 +27,7 @@ class TestEventBackend(testtools.TestCase):
self.ctx = utils.dummy_context()
@mock.patch('oslo_utils.reflection.get_class_name')
def test__check_entity_cluster(self, mock_get):
def test_check_entity_cluster(self, mock_get):
entity = mock.Mock()
mock_get.return_value = 'Cluster'
@ -37,7 +37,7 @@ class TestEventBackend(testtools.TestCase):
mock_get.assert_called_once_with(entity, fully_qualified=False)
@mock.patch('oslo_utils.reflection.get_class_name')
def test__check_entity_node(self, mock_get):
def test_check_entity_node(self, mock_get):
entity = mock.Mock()
mock_get.return_value = 'Node'
@ -46,23 +46,23 @@ class TestEventBackend(testtools.TestCase):
self.assertEqual('NODE', res)
mock_get.assert_called_once_with(entity, fully_qualified=False)
def test__get_action_name_unexpected(self):
def test_get_action_name_unexpected(self):
action = mock.Mock(action="UNEXPECTED")
res = base.EventBackend._get_action_name(action)
self.assertEqual('unexpected', res)
def test__get_action_name_correct_format(self):
def test_get_action_name_correct_format(self):
action = mock.Mock(action="FOO_BAR")
res = base.EventBackend._get_action_name(action)
self.assertEqual('bar', res)
def test__get_action_name_operation_found(self):
def test_get_action_name_operation_found(self):
action = mock.Mock(action=consts.NODE_OPERATION,
inputs={'operation': 'bar'})
res = base.EventBackend._get_action_name(action)
self.assertEqual('bar', res)
def test__get_action_name_operation_not_found(self):
def test_get_action_name_operation_not_found(self):
action = mock.Mock(action="FOO_OPERATION", inputs={})
res = base.EventBackend._get_action_name(action)
self.assertEqual('operation', res)

View File

@ -35,7 +35,7 @@ class TestMessageEvent(testtools.TestCase):
self.ctx = utils.dummy_context()
@mock.patch.object(nobj.NotificationBase, '_emit')
def test__notify_cluster_action(self, mock_emit):
def test_notify_cluster_action(self, mock_emit):
cluster_id = uuidutils.generate_uuid()
profile_id = uuidutils.generate_uuid()
cluster_init = timeutils.utcnow(True)
@ -131,7 +131,7 @@ class TestMessageEvent(testtools.TestCase):
self.assertEqual(expected_payload, payload)
@mock.patch.object(nobj.NotificationBase, '_emit')
def test__notify_node_action(self, mock_emit):
def test_notify_node_action(self, mock_emit):
node_id = uuidutils.generate_uuid()
profile_id = uuidutils.generate_uuid()
node_init = timeutils.utcnow(True)

View File

@ -42,7 +42,7 @@ class TestBatchPolicy(base.SenlinTestCase):
self.assertEqual(2, policy.max_batch_size)
self.assertEqual(60, policy.pause_time)
def test__get_batch_size(self):
def test_get_batch_size(self):
policy = bp.BatchPolicy('test-batch', self.spec)
size, number = policy._get_batch_size(5)
@ -50,7 +50,7 @@ class TestBatchPolicy(base.SenlinTestCase):
self.assertEqual(2, size)
self.assertEqual(3, number)
def test__get_batch_size_less_than_max(self):
def test_get_batch_size_less_than_max(self):
spec = copy.deepcopy(self.spec)
spec['properties']['max_batch_size'] = 3
policy = bp.BatchPolicy('test-batch', spec)
@ -60,7 +60,7 @@ class TestBatchPolicy(base.SenlinTestCase):
self.assertEqual(2, size)
self.assertEqual(2, number)
def test__get_batch_size_less_than_min(self):
def test_get_batch_size_less_than_min(self):
spec = copy.deepcopy(self.spec)
spec['properties']['min_in_service'] = 2
policy = bp.BatchPolicy('test-batch', spec)
@ -70,7 +70,7 @@ class TestBatchPolicy(base.SenlinTestCase):
self.assertEqual(1, size)
self.assertEqual(1, number)
def test__get_batch_size_with_default_max(self):
def test_get_batch_size_with_default_max(self):
spec = copy.deepcopy(self.spec)
spec['properties']['max_batch_size'] = -1
policy = bp.BatchPolicy('test-batch', spec)
@ -79,7 +79,7 @@ class TestBatchPolicy(base.SenlinTestCase):
self.assertEqual(4, size)
self.assertEqual(2, number)
def test__pick_nodes_all_active(self):
def test_pick_nodes_all_active(self):
node1 = mock.Mock(id='1', status='ACTIVE')
node2 = mock.Mock(id='2', status='ACTIVE')
node3 = mock.Mock(id='3', status='ACTIVE')
@ -93,7 +93,7 @@ class TestBatchPolicy(base.SenlinTestCase):
self.assertIn(node2.id, nodes[0])
self.assertIn(node3.id, nodes[1])
def test__pick_nodes_with_error_nodes(self):
def test_pick_nodes_with_error_nodes(self):
node1 = mock.Mock(id='1', status='ACTIVE')
node2 = mock.Mock(id='2', status='ACTIVE')
node3 = mock.Mock(id='3', status='ERROR')
@ -110,7 +110,7 @@ class TestBatchPolicy(base.SenlinTestCase):
@mock.patch.object(bp.BatchPolicy, '_pick_nodes')
@mock.patch.object(bp.BatchPolicy, '_get_batch_size')
def test__create_plan_for_update(self, mock_cal, mock_pick):
def test_create_plan_for_update(self, mock_cal, mock_pick):
action = mock.Mock(context=self.context, action='CLUSTER_UPDATE')
cluster = mock.Mock(id='cid')
node1, node2, node3 = mock.Mock(), mock.Mock(), mock.Mock()
@ -132,7 +132,7 @@ class TestBatchPolicy(base.SenlinTestCase):
mock_cal.assert_called_once_with(3)
mock_pick.assert_called_once_with([node1, node2, node3], 2, 2)
def test__create_plan_for_update_no_node(self):
def test_create_plan_for_update_no_node(self):
action = mock.Mock(context=self.context, action='CLUSTER_UPDATE')
cluster = mock.Mock(id='cid')
cluster.nodes = []

View File

@ -48,7 +48,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
self.assertFalse(policy.reduce_desired_capacity)
@mock.patch.object(su, 'nodes_by_random')
def test__victims_by_regions_random(self, mock_select):
def test_victims_by_regions_random(self, mock_select):
cluster = mock.Mock()
node1 = mock.Mock(id=1)
node2 = mock.Mock(id=2)
@ -72,7 +72,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
mock.call('R1'), mock.call('R2')])
@mock.patch.object(su, 'nodes_by_profile_age')
def test__victims_by_regions_profile_age(self, mock_select):
def test_victims_by_regions_profile_age(self, mock_select):
cluster = mock.Mock()
node1 = mock.Mock(id=1)
node2 = mock.Mock(id=2)
@ -96,7 +96,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
mock.call('R1'), mock.call('R2')])
@mock.patch.object(su, 'nodes_by_age')
def test__victims_by_regions_age_oldest(self, mock_select):
def test_victims_by_regions_age_oldest(self, mock_select):
cluster = mock.Mock()
node1 = mock.Mock(id=1)
node2 = mock.Mock(id=2)
@ -120,7 +120,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
mock.call('R1'), mock.call('R2')])
@mock.patch.object(su, 'nodes_by_age')
def test__victims_by_regions_age_youngest(self, mock_select):
def test_victims_by_regions_age_youngest(self, mock_select):
cluster = mock.Mock()
node1 = mock.Mock(id=1)
node2 = mock.Mock(id=2)
@ -144,7 +144,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
mock.call('R1'), mock.call('R2')])
@mock.patch.object(su, 'nodes_by_random')
def test__victims_by_zones_random(self, mock_select):
def test_victims_by_zones_random(self, mock_select):
cluster = mock.Mock()
node1 = mock.Mock(id=1)
node2 = mock.Mock(id=2)
@ -169,7 +169,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
)
@mock.patch.object(su, 'nodes_by_profile_age')
def test__victims_by_zones_profile_age(self, mock_select):
def test_victims_by_zones_profile_age(self, mock_select):
cluster = mock.Mock()
node1 = mock.Mock(id=1)
node2 = mock.Mock(id=2)
@ -196,7 +196,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
)
@mock.patch.object(su, 'nodes_by_age')
def test__victims_by_zones_age_oldest(self, mock_select):
def test_victims_by_zones_age_oldest(self, mock_select):
cluster = mock.Mock()
node1 = mock.Mock(id=1)
node2 = mock.Mock(id=2)
@ -221,7 +221,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
)
@mock.patch.object(su, 'nodes_by_age')
def test__victims_by_zones_age_youngest(self, mock_select):
def test_victims_by_zones_age_youngest(self, mock_select):
cluster = mock.Mock()
node1 = mock.Mock(id=1)
node2 = mock.Mock(id=3)
@ -247,7 +247,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
[mock.call('AZ5'), mock.call('AZ6')],
)
def test__update_action_clean(self):
def test_update_action_clean(self):
action = mock.Mock()
action.data = {}
@ -269,7 +269,7 @@ class TestDeletionPolicy(base.SenlinTestCase):
self.assertEqual(pd, action.data)
action.store.assert_called_with(action.context)
def test__update_action_override(self):
def test_update_action_override(self):
action = mock.Mock()
action.data = {
'deletion': {

View File

@ -697,8 +697,8 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
@mock.patch.object(no.Node, 'get')
@mock.patch.object(no.Node, 'update')
def test__add_member(self, m_node_update, m_node_get,
m_extract, m_load):
def test_add_member(self, m_node_update, m_node_get,
m_extract, m_load):
node1 = mock.Mock(id='NODE1_ID', data={})
node2 = mock.Mock(id='NODE2_ID', data={})
action = mock.Mock(context='action_context',
@ -754,8 +754,8 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
@mock.patch.object(no.Node, 'get')
@mock.patch.object(no.Node, 'update')
def test__add_member_fail(self, m_node_update, m_node_get,
m_extract, m_load):
def test_add_member_fail(self, m_node_update, m_node_get,
m_extract, m_load):
node1 = mock.Mock(id='NODE1_ID', data={})
action = mock.Mock(context='action_context',
action=consts.CLUSTER_RESIZE,
@ -921,8 +921,8 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
@mock.patch.object(no.Node, 'get')
@mock.patch.object(no.Node, 'update')
def test__remove_member(self, m_node_update, m_node_get,
m_extract, m_load):
def test_remove_member(self, m_node_update, m_node_get,
m_extract, m_load):
node1 = mock.Mock(id='NODE1', data={'lb_member': 'MEM_ID1'})
node2 = mock.Mock(id='NODE2', data={'lb_member': 'MEM_ID2'})
action = mock.Mock(
@ -976,8 +976,8 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
@mock.patch.object(no.Node, 'get')
@mock.patch.object(no.Node, 'update')
def test__remove_member_not_in_pool(self, m_node_update, m_node_get,
m_extract, m_load):
def test_remove_member_not_in_pool(self, m_node_update, m_node_get,
m_extract, m_load):
node1 = mock.Mock(id='NODE1', data={'lb_member': 'MEM_ID1'})
node2 = mock.Mock(id='NODE2', data={})
action = mock.Mock(
@ -1025,8 +1025,8 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
@mock.patch.object(no.Node, 'get')
@mock.patch.object(no.Node, 'update')
def test__remove_member_fail(self, m_node_update, m_node_get,
m_extract, m_load):
def test_remove_member_fail(self, m_node_update, m_node_get,
m_extract, m_load):
node1 = mock.Mock(id='NODE1', data={'lb_member': 'MEM_ID1'})
action = mock.Mock(
context='action_context', action=consts.CLUSTER_DEL_NODES,
@ -1120,7 +1120,7 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
mock.ANY, self.lb_driver)
@mock.patch.object(no.Node, 'update')
def test__process_recovery_not_lb_member(self, m_update, m1, m2):
def test_process_recovery_not_lb_member(self, m_update, m1, m2):
node = mock.Mock(id='NODE', data={})
action = mock.Mock(
action=consts.NODE_RECOVER,
@ -1137,7 +1137,7 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
@mock.patch.object(no.Node, 'update')
@mock.patch.object(lb_policy.LoadBalancingPolicy, '_remove_member')
def test__process_recovery_reboot(self, m_remove, m_update, m1, m2):
def test_process_recovery_reboot(self, m_remove, m_update, m1, m2):
node = mock.Mock(id='NODE', data={'lb_member': 'mem_1'})
action = mock.Mock(
action=consts.NODE_RECOVER,
@ -1156,7 +1156,7 @@ class TestLoadBalancingPolicyOperations(base.SenlinTestCase):
@mock.patch.object(no.Node, 'update')
@mock.patch.object(lb_policy.LoadBalancingPolicy, '_remove_member')
def test__process_recovery_recreate(self, m_remove, m_update, m1, m2):
def test_process_recovery_recreate(self, m_remove, m_update, m1, m2):
node = mock.Mock(id='NODE', data={'lb_member': 'mem_1',
'recovery': 'RECREATE'})
action = mock.Mock(

View File

@ -109,7 +109,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
self.assertEqual("The specified regions '['R1', 'R3']' could not "
"be found.", six.text_type(ex))
def test__create_plan(self):
def test_create_plan(self):
policy = rp.RegionPlacementPolicy('p1', self.spec)
regions = policy.regions
@ -133,7 +133,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
answer = {'R2': 1, 'R3': 1, 'R4': 1}
self.assertEqual(answer, plan)
def test__get_count_node_create_no_region(self):
def test_get_count_node_create_no_region(self):
x_profile = mock.Mock(CONTEXT='context', properties={'context': {}})
x_node = mock.Mock(rt={'profile': x_profile})
action = mock.Mock(action=consts.NODE_CREATE, entity=x_node)
@ -143,7 +143,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(1, res)
def test__get_count_node_create_region_specified(self):
def test_get_count_node_create_region_specified(self):
x_profile = mock.Mock(CONTEXT='context',
properties={'context': {'region_name': 'foo'}})
x_node = mock.Mock(rt={'profile': x_profile})
@ -154,7 +154,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(0, res)
def test__get_count_resize_deletion(self):
def test_get_count_resize_deletion(self):
action = mock.Mock(action=consts.CLUSTER_RESIZE,
data={'deletion': {'count': 3}})
@ -163,7 +163,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-3, res)
def test__get_count_resize_creation(self):
def test_get_count_resize_creation(self):
action = mock.Mock(action=consts.CLUSTER_RESIZE,
data={'creation': {'count': 3}})
policy = rp.RegionPlacementPolicy('p1', self.spec)
@ -173,7 +173,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
self.assertEqual(3, res)
@mock.patch.object(su, 'parse_resize_params')
def test__get_count_resize_parse_error(self, mock_parse):
def test_get_count_resize_parse_error(self, mock_parse):
x_cluster = mock.Mock()
x_cluster.nodes = [mock.Mock(), mock.Mock()]
action = mock.Mock(action=consts.CLUSTER_RESIZE, data={})
@ -189,7 +189,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
self.assertEqual('Something wrong.', action.data['reason'])
@mock.patch.object(su, 'parse_resize_params')
def test__get_count_resize_parse_creation(self, mock_parse):
def test_get_count_resize_parse_creation(self, mock_parse):
def fake_parse(action, cluster, current):
action.data = {'creation': {'count': 3}}
return pb.CHECK_OK, ''
@ -208,7 +208,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
mock_parse.assert_called_once_with(action, x_cluster, 0)
@mock.patch.object(su, 'parse_resize_params')
def test__get_count_resize_parse_deletion(self, mock_parse):
def test_get_count_resize_parse_deletion(self, mock_parse):
def fake_parse(action, cluster, current):
action.data = {'deletion': {'count': 3}}
return pb.CHECK_OK, ''
@ -226,7 +226,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
self.assertEqual(-3, res)
mock_parse.assert_called_once_with(action, x_cluster, 3)
def test__get_count_scale_in_with_data(self):
def test_get_count_scale_in_with_data(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_IN,
data={'deletion': {'count': 3}})
policy = rp.RegionPlacementPolicy('p1', self.spec)
@ -234,7 +234,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-3, res)
def test__get_count_scale_in_with_no_data(self):
def test_get_count_scale_in_with_no_data(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_IN,
data={'deletion': {'num': 3}})
policy = rp.RegionPlacementPolicy('p1', self.spec)
@ -242,7 +242,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-1, res)
def test__get_count_scale_in_with_inputs(self):
def test_get_count_scale_in_with_inputs(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_IN, data={},
inputs={'count': 3})
policy = rp.RegionPlacementPolicy('p1', self.spec)
@ -250,7 +250,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-3, res)
def test__get_count_scale_in_with_incorrect_inputs(self):
def test_get_count_scale_in_with_incorrect_inputs(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_IN, data={},
inputs={'num': 3})
policy = rp.RegionPlacementPolicy('p1', self.spec)
@ -258,7 +258,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-1, res)
def test__get_count_scale_out_with_data(self):
def test_get_count_scale_out_with_data(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_OUT,
data={'creation': {'count': 3}})
policy = rp.RegionPlacementPolicy('p1', self.spec)
@ -266,7 +266,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(3, res)
def test__get_count_scale_out_with_no_data(self):
def test_get_count_scale_out_with_no_data(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_OUT,
data={'creation': {'num': 3}})
policy = rp.RegionPlacementPolicy('p1', self.spec)
@ -274,7 +274,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(1, res)
def test__get_count_scale_out_with_inputs(self):
def test_get_count_scale_out_with_inputs(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_OUT, data={},
inputs={'count': 3})
policy = rp.RegionPlacementPolicy('p1', self.spec)
@ -282,7 +282,7 @@ class TestRegionPlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(3, res)
def test__get_count_scale_out_with_incorrect_inputs(self):
def test_get_count_scale_out_with_incorrect_inputs(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_OUT, data={},
inputs={'num': 3})
policy = rp.RegionPlacementPolicy('p1', self.spec)

View File

@ -93,7 +93,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
self.assertEqual("The specified name '['AZ2', 'AZ3']' "
"could not be found.", six.text_type(ex))
def test__create_plan_default(self):
def test_create_plan_default(self):
self.spec['properties']['zones'] = [
{'name': 'AZ1'}, {'name': 'AZ2'}, {'name': 'AZ3'}, {'name': 'AZ4'}
]
@ -105,7 +105,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
answer = {'AZ1': 1, 'AZ2': 1, 'AZ3': 1, 'AZ4': 2}
self.assertEqual(answer, plan)
def test__create_plan(self):
def test_create_plan(self):
policy = zp.ZonePlacementPolicy('test-policy', self.spec)
zones = policy.zones
@ -129,7 +129,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
answer = {'AZ4': 4}
self.assertEqual(answer, plan)
def test__get_count_node_create_with_zone(self):
def test_get_count_node_create_with_zone(self):
x_profile = mock.Mock(AVAILABILITY_ZONE='availability_zone',
properties={'availability_zone': 'zone1'})
x_node = mock.Mock(rt={'profile': x_profile})
@ -140,7 +140,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(0, res)
def test__get_count_node_create_without_zone(self):
def test_get_count_node_create_without_zone(self):
x_profile = mock.Mock(AVAILABILITY_ZONE='availability_zone',
properties={'availability_zone': None})
x_node = mock.Mock(rt={'profile': x_profile})
@ -151,7 +151,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(1, res)
def test__get_count_resize_deletion(self):
def test_get_count_resize_deletion(self):
action = mock.Mock(action=consts.CLUSTER_RESIZE,
data={'deletion': {'count': 3}})
@ -160,7 +160,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-3, res)
def test__get_count_resize_creation(self):
def test_get_count_resize_creation(self):
action = mock.Mock(action=consts.CLUSTER_RESIZE,
data={'creation': {'count': 3}})
policy = zp.ZonePlacementPolicy('p1', self.spec)
@ -171,8 +171,8 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
@mock.patch.object(no.Node, 'count_by_cluster')
@mock.patch.object(su, 'parse_resize_params')
@mock.patch.object(co.Cluster, 'get')
def test__get_count_resize_parse_error(self, mock_cluster, mock_parse,
mock_count):
def test_get_count_resize_parse_error(self, mock_cluster, mock_parse,
mock_count):
x_cluster = mock.Mock()
mock_cluster.return_value = x_cluster
mock_count.return_value = 3
@ -192,8 +192,8 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
@mock.patch.object(no.Node, 'count_by_cluster')
@mock.patch.object(su, 'parse_resize_params')
@mock.patch.object(co.Cluster, 'get')
def test__get_count_resize_parse_creation(self, mock_cluster, mock_parse,
mock_count):
def test_get_count_resize_parse_creation(self, mock_cluster, mock_parse,
mock_count):
def fake_parse(action, cluster, current):
action.data = {'creation': {'count': 3}}
return policy_base.CHECK_OK, ''
@ -215,8 +215,8 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
@mock.patch.object(no.Node, 'count_by_cluster')
@mock.patch.object(su, 'parse_resize_params')
@mock.patch.object(co.Cluster, 'get')
def test__get_count_resize_parse_deletion(self, mock_cluster, mock_parse,
mock_count):
def test_get_count_resize_parse_deletion(self, mock_cluster, mock_parse,
mock_count):
def fake_parse(action, cluster, current):
action.data = {'deletion': {'count': 3}}
return policy_base.CHECK_OK, ''
@ -235,7 +235,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
mock_count.assert_called_once_with(action.context, 'FOO')
mock_parse.assert_called_once_with(action, x_cluster, 3)
def test__get_count_scale_in_with_data(self):
def test_get_count_scale_in_with_data(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_IN,
data={'deletion': {'count': 3}})
policy = zp.ZonePlacementPolicy('p1', self.spec)
@ -243,7 +243,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-3, res)
def test__get_count_scale_in_with_no_data(self):
def test_get_count_scale_in_with_no_data(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_IN,
data={'deletion': {'num': 3}})
policy = zp.ZonePlacementPolicy('p1', self.spec)
@ -251,7 +251,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-1, res)
def test__get_count_scale_in_with_inputs(self):
def test_get_count_scale_in_with_inputs(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_IN, data={},
inputs={'count': 3})
policy = zp.ZonePlacementPolicy('p1', self.spec)
@ -259,7 +259,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-3, res)
def test__get_count_scale_in_with_incorrect_inputs(self):
def test_get_count_scale_in_with_incorrect_inputs(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_IN, data={},
inputs={'num': 3})
policy = zp.ZonePlacementPolicy('p1', self.spec)
@ -267,7 +267,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(-1, res)
def test__get_count_scale_out_with_data(self):
def test_get_count_scale_out_with_data(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_OUT,
data={'creation': {'count': 3}})
policy = zp.ZonePlacementPolicy('p1', self.spec)
@ -275,7 +275,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(3, res)
def test__get_count_scale_out_with_no_data(self):
def test_get_count_scale_out_with_no_data(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_OUT,
data={'creation': {'num': 3}})
policy = zp.ZonePlacementPolicy('p1', self.spec)
@ -283,7 +283,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(1, res)
def test__get_count_scale_out_with_inputs(self):
def test_get_count_scale_out_with_inputs(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_OUT, data={},
inputs={'count': 3})
policy = zp.ZonePlacementPolicy('p1', self.spec)
@ -291,7 +291,7 @@ class TestZonePlacementPolicy(base.SenlinTestCase):
res = policy._get_count('FOO', action)
self.assertEqual(3, res)
def test__get_count_scale_out_with_incorrect_inputs(self):
def test_get_count_scale_out_with_incorrect_inputs(self):
action = mock.Mock(action=consts.CLUSTER_SCALE_OUT, data={},
inputs={'num': 3})
policy = zp.ZonePlacementPolicy('p1', self.spec)

View File

@ -178,7 +178,7 @@ class TestContainerDockerProfile(base.SenlinTestCase):
self.assertEqual(msg, ex.message)
@mock.patch.object(node.Node, 'load')
def test__get_host_node_found_by_node(self, mock_load):
def test_get_host_node_found_by_node(self, mock_load):
node = mock.Mock()
mock_load.return_value = node
ctx = mock.Mock()
@ -190,7 +190,7 @@ class TestContainerDockerProfile(base.SenlinTestCase):
mock_load.assert_called_once_with(ctx, node_id='host_node')
@mock.patch.object(dp.DockerProfile, '_get_random_node')
def test__get_host_node_found_by_cluster(self, mock_get):
def test_get_host_node_found_by_cluster(self, mock_get):
node = mock.Mock()
mock_get.return_value = node
ctx = mock.Mock()
@ -202,7 +202,7 @@ class TestContainerDockerProfile(base.SenlinTestCase):
mock_get.assert_called_once_with(ctx, 'host_cluster')
@mock.patch.object(node.Node, 'load')
def test__get_host_node_not_found(self, mock_load):
def test_get_host_node_not_found(self, mock_load):
mock_load.side_effect = exc.ResourceNotFound(type='node',
id='fake_node')
profile = dp.DockerProfile('container', self.spec)
@ -218,7 +218,7 @@ class TestContainerDockerProfile(base.SenlinTestCase):
@mock.patch.object(node.Node, 'load')
@mock.patch.object(no.Node, 'get_all_by_cluster')
@mock.patch.object(cluster.Cluster, 'load')
def test__get_random_node(self, mock_cluster, mock_nodes, mock_load):
def test_get_random_node(self, mock_cluster, mock_nodes, mock_load):
cluster = mock.Mock()
mock_cluster.return_value = cluster
node1 = mock.Mock()
@ -240,7 +240,7 @@ class TestContainerDockerProfile(base.SenlinTestCase):
self.assertIn(n, [node1, node2])
@mock.patch.object(cluster.Cluster, 'load')
def test__get_random_node_cluster_not_found(self, mock_load):
def test_get_random_node_cluster_not_found(self, mock_load):
mock_load.side_effect = exc.ResourceNotFound(type='cluster',
id='host_cluster')
ctx = mock.Mock()
@ -255,7 +255,7 @@ class TestContainerDockerProfile(base.SenlinTestCase):
@mock.patch.object(no.Node, 'get_all_by_cluster')
@mock.patch.object(cluster.Cluster, 'load')
def test__get_random_node_empty_cluster(self, mock_cluster, mock_nodes):
def test_get_random_node_empty_cluster(self, mock_cluster, mock_nodes):
cluster = mock.Mock()
mock_cluster.return_value = cluster
mock_nodes.return_value = []

View File

@ -801,7 +801,7 @@ class TestHeatStackProfile(base.SenlinTestCase):
oc.stack_get.assert_called_once_with('FAKE_ID')
oc.stack_get_template.assert_called_once_with('FAKE_ID')
def test__refresh_tags_empty_no_add(self):
def test_refresh_tags_empty_no_add(self):
profile = stack.StackProfile('t', self.spec)
node = mock.Mock()
@ -809,7 +809,7 @@ class TestHeatStackProfile(base.SenlinTestCase):
self.assertEqual(("", False), res)
def test__refresh_tags_with_contents_no_add(self):
def test_refresh_tags_with_contents_no_add(self):
profile = stack.StackProfile('t', self.spec)
node = mock.Mock()
@ -817,7 +817,7 @@ class TestHeatStackProfile(base.SenlinTestCase):
self.assertEqual(('foo', False), res)
def test__refresh_tags_deleted_no_add(self):
def test_refresh_tags_deleted_no_add(self):
profile = stack.StackProfile('t', self.spec)
node = mock.Mock()
@ -825,7 +825,7 @@ class TestHeatStackProfile(base.SenlinTestCase):
self.assertEqual(('bar', True), res)
def test__refresh_tags_empty_and_add(self):
def test_refresh_tags_empty_and_add(self):
profile = stack.StackProfile('t', self.spec)
node = mock.Mock(id='NODE_ID', cluster_id='CLUSTER_ID', index=123)
@ -836,7 +836,7 @@ class TestHeatStackProfile(base.SenlinTestCase):
'cluster_node_index=123'])
self.assertEqual((expected, True), res)
def test__refresh_tags_with_contents_and_add(self):
def test_refresh_tags_with_contents_and_add(self):
profile = stack.StackProfile('t', self.spec)
node = mock.Mock(id='NODE_ID', cluster_id='CLUSTER_ID', index=123)
@ -848,7 +848,7 @@ class TestHeatStackProfile(base.SenlinTestCase):
'cluster_node_index=123'])
self.assertEqual((expected, True), res)
def test__refresh_tags_deleted_and_add(self):
def test_refresh_tags_deleted_and_add(self):
profile = stack.StackProfile('t', self.spec)
node = mock.Mock(id='NODE_ID', cluster_id='CLUSTER_ID', index=123)

View File

@ -66,7 +66,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
self.assertIsNone(profile.server_id)
def test__build_metadata(self):
def test_build_metadata(self):
obj = mock.Mock(id='NODE_ID', cluster_id='')
profile = server.ServerProfile('t', self.spec)
@ -74,7 +74,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
self.assertEqual({'cluster_node_id': 'NODE_ID'}, res)
def test__build_metadata_with_inputs(self):
def test_build_metadata_with_inputs(self):
obj = mock.Mock(id='NODE_ID', cluster_id='')
profile = server.ServerProfile('t', self.spec)
@ -82,7 +82,7 @@ class TestNovaServerBasic(base.SenlinTestCase):
self.assertEqual({'cluster_node_id': 'NODE_ID', 'foo': 'bar'}, res)
def test__build_metadata_for_cluster_node(self):
def test_build_metadata_for_cluster_node(self):
obj = mock.Mock(id='NODE_ID', cluster_id='CLUSTER_ID', index=123)
profile = server.ServerProfile('t', self.spec)

View File

@ -159,7 +159,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
}
self.patchobject(node_obj.Node, 'update')
def test__update_name(self):
def test_update_name(self):
profile = server.ServerProfile('t', self.spec)
cc = mock.Mock()
profile._computeclient = cc
@ -170,7 +170,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertIsNone(res)
cc.server_update.assert_called_once_with('NOVA_ID', name='NEW_NAME')
def test__update_name_nova_failure(self):
def test_update_name_nova_failure(self):
profile = server.ServerProfile('t', self.spec)
cc = mock.Mock()
profile._computeclient = cc
@ -185,7 +185,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
six.text_type(ex))
cc.server_update.assert_called_once_with('NOVA_ID', name='NEW_NAME')
def test__update_password(self):
def test_update_password(self):
profile = server.ServerProfile('t', self.spec)
cc = mock.Mock()
profile._computeclient = cc
@ -197,7 +197,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
cc.server_change_password.assert_called_once_with(
'NOVA_ID', 'NEW_PASSWORD')
def test__update_password_nova_failure(self):
def test_update_password_nova_failure(self):
profile = server.ServerProfile('t', self.spec)
cc = mock.Mock()
profile._computeclient = cc
@ -214,7 +214,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
cc.server_change_password.assert_called_once_with(
'NOVA_ID', 'NEW_PASSWORD')
def test__update_metadata(self):
def test_update_metadata(self):
obj = mock.Mock(id='NODE_ID', physical_id='NOVA_ID',
cluster_id='CLUSTER_ID', index=456)
cc = mock.Mock()
@ -237,7 +237,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
}
)
def test___update_metadata_no_change(self):
def test__update_metadata_no_change(self):
obj = mock.Mock(id='NODE_ID')
profile = server.ServerProfile('t', self.spec)
cc = mock.Mock()
@ -250,7 +250,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertIsNone(res)
self.assertEqual(0, cc.server_metadata_update.call_count)
def test__update_metadata_nova_failure(self):
def test_update_metadata_nova_failure(self):
obj = mock.Mock(id='NODE_ID', physical_id='NOVA_ID', cluster_id='')
err = exc.InternalError(code=500, message='Nova Error')
cc = mock.Mock()
@ -273,7 +273,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
'NOVA_ID', {'fooa': 'baaar', 'cluster_node_id': 'NODE_ID'}
)
def test__update_flavor(self):
def test_update_flavor(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
profile = server.ServerProfile('t', self.spec)
@ -296,7 +296,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
mock.call('NOVA_ID', 'VERIFY_RESIZE'),
mock.call('NOVA_ID', 'ACTIVE')])
def test__update_flavor_failed_validation(self):
def test_update_flavor_failed_validation(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
profile = server.ServerProfile('t', self.spec)
@ -314,7 +314,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
mock_validate.assert_called_once_with(obj, 'FLAV', 'update')
def test__update_flavor_failed_validation_2(self):
def test_update_flavor_failed_validation_2(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
profile = server.ServerProfile('t', self.spec)
@ -338,7 +338,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
mock.call(obj, 'new_flavor', 'update'),
])
def test__update_flavor_same(self):
def test_update_flavor_same(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
profile = server.ServerProfile('t', self.spec)
@ -359,7 +359,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
])
self.assertEqual(0, cc.server_resize.call_count)
def test__update_flavor_resize_failed(self):
def test_update_flavor_resize_failed(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
cc.server_resize.side_effect = [
@ -387,7 +387,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertEqual("Failed in updating server 'NOVA_ID': Resize "
"failed.", six.text_type(ex))
def test__update_flavor_first_wait_for_server_failed(self):
def test_update_flavor_first_wait_for_server_failed(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
cc.wait_for_server.side_effect = [
@ -421,7 +421,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertEqual("Failed in updating server 'NOVA_ID': "
"TIMEOUT.", six.text_type(ex))
def test__update_flavor_resize_failed_revert_failed(self):
def test_update_flavor_resize_failed_revert_failed(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
err_resize = exc.InternalError(code=500, message='Resize')
@ -454,7 +454,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertEqual("Failed in updating server 'NOVA_ID': "
"Revert.", six.text_type(ex))
def test__update_flavor_confirm_failed(self):
def test_update_flavor_confirm_failed(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
err_confirm = exc.InternalError(code=500, message='Confirm')
@ -484,7 +484,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertEqual("Failed in updating server 'NOVA_ID': Confirm.",
six.text_type(ex))
def test__update_flavor_wait_confirm_failed(self):
def test_update_flavor_wait_confirm_failed(self):
obj = mock.Mock(physical_id='NOVA_ID')
cc = mock.Mock()
err_wait = exc.InternalError(code=500, message='Wait')
@ -517,7 +517,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertEqual("Failed in updating server 'NOVA_ID': Wait.",
six.text_type(ex))
def test__update_image(self):
def test_update_image(self):
profile = server.ServerProfile('t', self.spec)
x_image = {'id': '123'}
x_server = mock.Mock(image=x_image)
@ -542,7 +542,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
'NOVA_ID', '456', 'new_name', 'new_pass')
cc.wait_for_server.assert_called_once_with('NOVA_ID', 'ACTIVE')
def test__update_image_new_image_is_none(self):
def test_update_image_new_image_is_none(self):
profile = server.ServerProfile('t', self.spec)
obj = mock.Mock(physical_id='NOVA_ID')
new_spec = copy.deepcopy(self.spec)
@ -557,7 +557,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
" with image set to None is not supported by Nova.")
self.assertEqual(msg, six.text_type(ex))
def test__update_image_new_image_invalid(self):
def test_update_image_new_image_invalid(self):
# NOTE: The image invalid could be caused by a non-existent image or
# a compute driver failure
profile = server.ServerProfile('t', self.spec)
@ -578,7 +578,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertEqual(msg, six.text_type(ex))
mock_check.assert_called_once_with(obj, 'new_image', reason='update')
def test__update_image_old_image_invalid(self):
def test_update_image_old_image_invalid(self):
# NOTE: The image invalid could be caused by a non-existent image or
# a compute driver failure
profile = server.ServerProfile('t', self.spec)
@ -608,7 +608,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
mock.call(obj, 'new_image', reason='update'),
])
def test__update_image_old_image_is_none_but_succeeded(self):
def test_update_image_old_image_is_none_but_succeeded(self):
old_spec = copy.deepcopy(self.spec)
del old_spec['properties']['image']
profile = server.ServerProfile('t', old_spec)
@ -634,7 +634,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
'NOVA_ID', '456', 'new_name', 'new_pass')
cc.wait_for_server.assert_called_once_with('NOVA_ID', 'ACTIVE')
def test__update_image_old_image_is_none_but_failed(self):
def test_update_image_old_image_is_none_but_failed(self):
old_spec = copy.deepcopy(self.spec)
del old_spec['properties']['image']
profile = server.ServerProfile('t', old_spec)
@ -659,7 +659,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
mock_check.assert_called_once_with(obj, 'new_image', reason='update')
cc.server_get.assert_called_once_with('NOVA_ID')
def test__update_image_updating_to_same_image(self):
def test_update_image_updating_to_same_image(self):
profile = server.ServerProfile('t', self.spec)
x_image = {'id': '123'}
x_server = mock.Mock(image=x_image)
@ -684,7 +684,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
self.assertEqual(0, cc.server_rebuild.call_count)
self.assertEqual(0, cc.wait_for_server.call_count)
def test__update_image_failed_rebuilding(self):
def test_update_image_failed_rebuilding(self):
profile = server.ServerProfile('t', self.spec)
x_image = {'id': '123'}
x_server = mock.Mock(image=x_image)
@ -714,7 +714,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
'NOVA_ID', '456', 'new_name', 'new_pass')
self.assertEqual(0, cc.wait_for_server.call_count)
def test__update_image_failed_waiting(self):
def test_update_image_failed_waiting(self):
profile = server.ServerProfile('t', self.spec)
x_image = {'id': '123'}
x_server = mock.Mock(image=x_image)
@ -744,7 +744,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
'NOVA_ID', '456', 'new_name', 'new_pass')
cc.wait_for_server.assert_called_once_with('NOVA_ID', 'ACTIVE')
def test__create_interfaces(self):
def test_create_interfaces(self):
cc = mock.Mock()
server_obj = mock.Mock()
cc.server_get.return_value = server_obj
@ -804,7 +804,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
]
cc.server_interface_create.assert_has_calls(create_calls)
def test__create_interfaces_failed_getting_server(self):
def test_create_interfaces_failed_getting_server(self):
cc = mock.Mock()
cc.server_get.side_effect = exc.InternalError(message='Not valid')
profile = server.ServerProfile('t', self.spec)
@ -823,7 +823,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
cc.server_get.assert_called_once_with('NOVA_ID')
self.assertEqual(0, profile._create_ports_from_properties.call_count)
def test__create_interfaces_failed_validation(self):
def test_create_interfaces_failed_validation(self):
cc = mock.Mock()
server_obj = mock.Mock()
cc.server_get.return_value = server_obj
@ -846,7 +846,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
mock_validate.assert_called_once_with(obj, networks[0], 'update')
self.assertEqual(0, cc.server_interface_create.call_count)
def test__delete_interfaces(self):
def test_delete_interfaces(self):
cc = mock.Mock()
nc = mock.Mock()
net1 = mock.Mock(id='net1')
@ -886,7 +886,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
mock.call('port3', ignore_missing=True),
])
def test__delete_interfaces_failed_delete(self):
def test_delete_interfaces_failed_delete(self):
cc = mock.Mock()
profile = server.ServerProfile('t', self.spec)
profile._computeclient = cc
@ -918,7 +918,7 @@ class TestNovaServerUpdate(base.SenlinTestCase):
@mock.patch.object(server.ServerProfile, '_update_network_remove_port')
@mock.patch.object(server.ServerProfile, '_update_network_add_port')
def test__update_network(self, mock_create, mock_delete):
def test_update_network(self, mock_create, mock_delete):
obj = mock.Mock(physical_id='FAKE_ID')
old_spec = copy.deepcopy(self.spec)

View File

@ -637,7 +637,7 @@ class TestProfileBase(base.SenlinTestCase):
self.assertRaises(exception.ESchema, profile.validate)
@mock.patch.object(senlin_ctx, 'get_service_credentials')
def test__init_context(self, mock_creds):
def test_init_context(self, mock_creds):
fake_ctx = mock.Mock()
mock_creds.return_value = fake_ctx
@ -652,7 +652,7 @@ class TestProfileBase(base.SenlinTestCase):
mock_creds.assert_called_once_with()
@mock.patch.object(senlin_ctx, 'get_service_credentials')
def test__init_context_for_real(self, mock_creds):
def test_init_context_for_real(self, mock_creds):
fake_ctx = {
'project_name': 'this project',
'project_domain_name': 'this domain',
@ -674,7 +674,7 @@ class TestProfileBase(base.SenlinTestCase):
self.assertEqual(expected, profile.context)
@mock.patch.object(senlin_ctx, 'get_service_credentials')
def test__init_context_for_real_with_data(self, mock_creds):
def test_init_context_for_real_with_data(self, mock_creds):
fake_ctx = {
'project_name': 'this project',
'project_domain_name': 'this domain',
@ -700,7 +700,7 @@ class TestProfileBase(base.SenlinTestCase):
@mock.patch.object(co.Credential, 'get')
@mock.patch.object(oslo_ctx, 'get_current')
def test__build_conn_params(self, mock_current, mock_get):
def test_build_conn_params(self, mock_current, mock_get):
profile = self._create_profile('test-profile')
profile.context = {'foo': 'bar'}
fake_cred = mock.Mock(cred={'openstack': {'trust': 'TRUST_ID'}})
@ -722,7 +722,7 @@ class TestProfileBase(base.SenlinTestCase):
@mock.patch.object(co.Credential, 'get')
@mock.patch.object(oslo_ctx, 'get_current')
def test__build_conn_params_trust_not_found(self, mock_current, mock_get):
def test_build_conn_params_trust_not_found(self, mock_current, mock_get):
profile = self._create_profile('test-profile')
mock_get.return_value = None
fake_ctx = mock.Mock()

View File

@ -279,7 +279,7 @@ class ScaleUtilsTest(base.SenlinTestCase):
self.assertEqual(['N1', 'N2', 'N15', 'N13', 'N12'], res)
@mock.patch.object(su, 'filter_error_nodes')
def test__victims_by_profile_age_oldest(self, mock_filter):
def test_victims_by_profile_age_oldest(self, mock_filter):
good_nodes = [
mock.Mock(id='N11', profile_created_at=110),
mock.Mock(id='N15', profile_created_at=150),

View File

@ -90,12 +90,12 @@ class TestSchemaBase(base.SenlinTestCase):
self.assertEqual('VVV', res)
mock_resolve.assert_called_once_with('DEFAULT')
def test__validate_default(self):
def test_validate_default(self):
sot = FakeSchema()
self.assertIsNone(sot._validate_default(mock.Mock()))
def test__validate_default_with_value(self):
def test_validate_default_with_value(self):
sot = FakeSchema(default='DEFAULT')
mock_validate = self.patchobject(sot, 'validate', return_value=None)
fake_context = mock.Mock()
@ -105,7 +105,7 @@ class TestSchemaBase(base.SenlinTestCase):
self.assertIsNone(res)
mock_validate.assert_called_once_with('DEFAULT', fake_context)
def test__validate_default_with_value_but_failed(self):
def test_validate_default_with_value_but_failed(self):
sot = FakeSchema(default='DEFAULT')
mock_validate = self.patchobject(sot, 'validate',
side_effect=ValueError('boom'))
@ -143,7 +143,7 @@ class TestSchemaBase(base.SenlinTestCase):
c1.validate.assert_called_once_with('FOO', schema=None, context=ctx)
self.assertEqual('BOOM', six.text_type(ex))
def test__validate_version(self):
def test_validate_version(self):
sot = FakeSchema(min_version='1.0', max_version='2.0')
res = sot._validate_version('field', '1.0')
@ -170,7 +170,7 @@ class TestSchemaBase(base.SenlinTestCase):
'spec version 2.1.',
six.text_type(ex))
def test__validate_version_no_min_version(self):
def test_validate_version_no_min_version(self):
sot = FakeSchema(max_version='2.0')
res = sot._validate_version('field', '1.0')
@ -186,7 +186,7 @@ class TestSchemaBase(base.SenlinTestCase):
'spec version 2.1.',
six.text_type(ex))
def test__validate_version_no_max_version(self):
def test_validate_version_no_max_version(self):
sot = FakeSchema(min_version='1.0')
res = sot._validate_version('field', '1.0')
@ -202,7 +202,7 @@ class TestSchemaBase(base.SenlinTestCase):
'spec version 0.5.',
six.text_type(ex))
def test__validate_version_no_version_restriction(self):
def test_validate_version_no_version_restriction(self):
sot = FakeSchema()
res = sot._validate_version('field', '1.0')
@ -531,7 +531,7 @@ class TestList(base.SenlinTestCase):
self.assertEqual('List', sot['type'])
self.assertEqual('desc', sot['description'])
def test__get_children(self):
def test_get_children(self):
sot = schema.List('desc', schema=schema.String())
res = sot._get_children(['v1', 'v2'], [0, 1])
@ -570,7 +570,7 @@ class TestMap(base.SenlinTestCase):
self.assertEqual('Map', sot['type'])
self.assertEqual('desc', sot['description'])
def test__get_children(self):
def test_get_children(self):
sot = schema.Map('desc', schema={'foo': schema.String()})
res = sot._get_children({'foo': 'bar'})
@ -893,7 +893,7 @@ class TestSpec(base.SenlinTestCase):
self.assertIn("Required spec item 'key2' not provided",
six.text_type(ex.message))
def test___getitem__(self):
def test__getitem__(self):
data = {'key2': 2}
sot = schema.Spec(self.spec_schema, data, version='1.2')
@ -902,14 +902,14 @@ class TestSpec(base.SenlinTestCase):
res = sot['key2']
self.assertEqual(2, res)
def test___len__(self):
def test__len__(self):
data = {'key2': 2}
sot = schema.Spec(self.spec_schema, data, version='1.2')
res = len(sot)
self.assertEqual(2, res)
def test___contains__(self):
def test__contains__(self):
data = {'key2': 2}
sot = schema.Spec(self.spec_schema, data, version='1.2')