Use more specific asserts in tests
Instead of assertTrue and assertFalse use more specific asserts. They are compatible with Python 2.7[1] and 3.4[2] [1]: https://docs.python.org/2.7/library/unittest.html [2]: https://docs.python.org/3.4/library/unittest.html Change-Id: Ifee66714db561fb329911395b2cfdd90c689b609
This commit is contained in:
parent
d5b129443d
commit
dfcb265ae8
@ -380,7 +380,7 @@ class JSONRequestDeserializerTest(common.HeatTestCase):
|
|||||||
def test_from_json_exceeds_max_json_mb(self):
|
def test_from_json_exceeds_max_json_mb(self):
|
||||||
cfg.CONF.set_override('max_json_body_size', 10, enforce_type=True)
|
cfg.CONF.set_override('max_json_body_size', 10, enforce_type=True)
|
||||||
body = json.dumps(['a'] * cfg.CONF.max_json_body_size)
|
body = json.dumps(['a'] * cfg.CONF.max_json_body_size)
|
||||||
self.assertTrue(len(body) > cfg.CONF.max_json_body_size)
|
self.assertGreater(len(body), cfg.CONF.max_json_body_size)
|
||||||
error = self.assertRaises(exception.RequestLimitExceeded,
|
error = self.assertRaises(exception.RequestLimitExceeded,
|
||||||
wsgi.JSONRequestDeserializer().from_json,
|
wsgi.JSONRequestDeserializer().from_json,
|
||||||
body)
|
body)
|
||||||
|
@ -523,7 +523,7 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
|
|||||||
tmpl_batch_sz = int(tmpl_policy['max_batch_size'])
|
tmpl_batch_sz = int(tmpl_policy['max_batch_size'])
|
||||||
policy = stack['my-group'].properties['rolling_updates']
|
policy = stack['my-group'].properties['rolling_updates']
|
||||||
self.assertTrue(policy)
|
self.assertTrue(policy)
|
||||||
self.assertTrue(len(policy) == 3)
|
self.assertEqual(3, len(policy))
|
||||||
self.assertEqual(1, int(policy['min_in_service']))
|
self.assertEqual(1, int(policy['min_in_service']))
|
||||||
self.assertEqual(tmpl_batch_sz, int(policy['max_batch_size']))
|
self.assertEqual(tmpl_batch_sz, int(policy['max_batch_size']))
|
||||||
self.assertEqual(1, policy['pause_time'])
|
self.assertEqual(1, policy['pause_time'])
|
||||||
|
@ -631,7 +631,8 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
|
|||||||
self.assertEqual(1, len(grp.update_policy))
|
self.assertEqual(1, len(grp.update_policy))
|
||||||
self.assertIn('AutoScalingRollingUpdate', grp.update_policy)
|
self.assertIn('AutoScalingRollingUpdate', grp.update_policy)
|
||||||
policy = grp.update_policy['AutoScalingRollingUpdate']
|
policy = grp.update_policy['AutoScalingRollingUpdate']
|
||||||
self.assertTrue(policy and len(policy) > 0)
|
self.assertIsNotNone(policy)
|
||||||
|
self.assertGreater(len(policy), 0)
|
||||||
self.assertEqual(1, int(policy['MinInstancesInService']))
|
self.assertEqual(1, int(policy['MinInstancesInService']))
|
||||||
self.assertEqual(tmpl_batch_sz, int(policy['MaxBatchSize']))
|
self.assertEqual(tmpl_batch_sz, int(policy['MaxBatchSize']))
|
||||||
self.assertEqual('PT1S', policy['PauseTime'])
|
self.assertEqual('PT1S', policy['PauseTime'])
|
||||||
@ -646,7 +647,8 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
|
|||||||
self.assertEqual(1, len(grp.update_policy))
|
self.assertEqual(1, len(grp.update_policy))
|
||||||
self.assertIn('AutoScalingRollingUpdate', grp.update_policy)
|
self.assertIn('AutoScalingRollingUpdate', grp.update_policy)
|
||||||
policy = grp.update_policy['AutoScalingRollingUpdate']
|
policy = grp.update_policy['AutoScalingRollingUpdate']
|
||||||
self.assertTrue(policy and len(policy) > 0)
|
self.assertIsNotNone(policy)
|
||||||
|
self.assertGreater(len(policy), 0)
|
||||||
self.assertEqual(0, int(policy['MinInstancesInService']))
|
self.assertEqual(0, int(policy['MinInstancesInService']))
|
||||||
self.assertEqual(1, int(policy['MaxBatchSize']))
|
self.assertEqual(1, int(policy['MaxBatchSize']))
|
||||||
self.assertEqual('PT0S', policy['PauseTime'])
|
self.assertEqual('PT0S', policy['PauseTime'])
|
||||||
|
@ -175,7 +175,7 @@ class InstancesTest(common.HeatTestCase):
|
|||||||
instance = self._create_test_instance(return_server,
|
instance = self._create_test_instance(return_server,
|
||||||
'in_create')
|
'in_create')
|
||||||
# this makes sure the auto increment worked on instance creation
|
# this makes sure the auto increment worked on instance creation
|
||||||
self.assertTrue(instance.id > 0)
|
self.assertGreater(instance.id, 0)
|
||||||
|
|
||||||
expected_ip = return_server.networks['public'][0]
|
expected_ip = return_server.networks['public'][0]
|
||||||
expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')
|
expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')
|
||||||
@ -197,7 +197,7 @@ class InstancesTest(common.HeatTestCase):
|
|||||||
instance = self._create_test_instance(return_server,
|
instance = self._create_test_instance(return_server,
|
||||||
'create_with_bdm')
|
'create_with_bdm')
|
||||||
# this makes sure the auto increment worked on instance creation
|
# this makes sure the auto increment worked on instance creation
|
||||||
self.assertTrue(instance.id > 0)
|
self.assertGreater(instance.id, 0)
|
||||||
|
|
||||||
expected_ip = return_server.networks['public'][0]
|
expected_ip = return_server.networks['public'][0]
|
||||||
expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')
|
expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')
|
||||||
@ -375,7 +375,7 @@ class InstancesTest(common.HeatTestCase):
|
|||||||
scheduler.TaskRunner(instance.create)()
|
scheduler.TaskRunner(instance.create)()
|
||||||
|
|
||||||
# this makes sure the auto increment worked on instance creation
|
# this makes sure the auto increment worked on instance creation
|
||||||
self.assertTrue(instance.id > 0)
|
self.assertGreater(instance.id, 0)
|
||||||
|
|
||||||
expected_ip = return_server.networks['public'][0]
|
expected_ip = return_server.networks['public'][0]
|
||||||
expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')
|
expected_az = getattr(return_server, 'OS-EXT-AZ:availability_zone')
|
||||||
@ -638,7 +638,7 @@ class InstancesTest(common.HeatTestCase):
|
|||||||
return_server)
|
return_server)
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
scheduler.TaskRunner(instance.create)()
|
scheduler.TaskRunner(instance.create)()
|
||||||
self.assertTrue(instance.id > 0)
|
self.assertGreater(instance.id, 0)
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_instance_validate(self):
|
def test_instance_validate(self):
|
||||||
@ -671,7 +671,7 @@ class InstancesTest(common.HeatTestCase):
|
|||||||
instance.status = vm_status
|
instance.status = vm_status
|
||||||
|
|
||||||
# this makes sure the auto increment worked on instance creation
|
# this makes sure the auto increment worked on instance creation
|
||||||
self.assertTrue(instance.id > 0)
|
self.assertGreater(instance.id, 0)
|
||||||
|
|
||||||
d1 = {'server': self.fc.client.get_servers_detail()[1]['servers'][0]}
|
d1 = {'server': self.fc.client.get_servers_detail()[1]['servers'][0]}
|
||||||
d1['server']['status'] = vm_status
|
d1['server']['status'] = vm_status
|
||||||
@ -706,7 +706,7 @@ class InstancesTest(common.HeatTestCase):
|
|||||||
instance.resource_id = '1234'
|
instance.resource_id = '1234'
|
||||||
|
|
||||||
# this makes sure the auto increment worked on instance creation
|
# this makes sure the auto increment worked on instance creation
|
||||||
self.assertTrue(instance.id > 0)
|
self.assertGreater(instance.id, 0)
|
||||||
|
|
||||||
self.m.StubOutWithMock(self.fc.client, 'delete_servers_1234')
|
self.m.StubOutWithMock(self.fc.client, 'delete_servers_1234')
|
||||||
self.fc.client.delete_servers_1234().AndRaise(
|
self.fc.client.delete_servers_1234().AndRaise(
|
||||||
|
@ -168,7 +168,7 @@ class instancesTest(common.HeatTestCase):
|
|||||||
instance.resource_id = '1234'
|
instance.resource_id = '1234'
|
||||||
instance.status = vm_status
|
instance.status = vm_status
|
||||||
# this makes sure the auto increment worked on instance creation
|
# this makes sure the auto increment worked on instance creation
|
||||||
self.assertTrue(instance.id > 0)
|
self.assertGreater(instance.id, 0)
|
||||||
|
|
||||||
expected_ip = return_server.networks['public'][0]
|
expected_ip = return_server.networks['public'][0]
|
||||||
self.assertEqual(expected_ip, instance.FnGetAtt('PublicIp'))
|
self.assertEqual(expected_ip, instance.FnGetAtt('PublicIp'))
|
||||||
@ -324,7 +324,7 @@ class instancesTest(common.HeatTestCase):
|
|||||||
return_server, 'in_create_wnic')
|
return_server, 'in_create_wnic')
|
||||||
|
|
||||||
# this makes sure the auto increment worked on instance creation
|
# this makes sure the auto increment worked on instance creation
|
||||||
self.assertTrue(instance.id > 0)
|
self.assertGreater(instance.id, 0)
|
||||||
|
|
||||||
expected_ip = return_server.networks['public'][0]
|
expected_ip = return_server.networks['public'][0]
|
||||||
self.assertEqual(expected_ip, instance.FnGetAtt('PublicIp'))
|
self.assertEqual(expected_ip, instance.FnGetAtt('PublicIp'))
|
||||||
|
@ -365,8 +365,8 @@ class TestClientPluginsInitialise(common.HeatTestCase):
|
|||||||
self.assertEqual({}, plugin._client_instances)
|
self.assertEqual({}, plugin._client_instances)
|
||||||
self.assertTrue(clients.has_client(plugin_name))
|
self.assertTrue(clients.has_client(plugin_name))
|
||||||
self.assertIsInstance(plugin.service_types, list)
|
self.assertIsInstance(plugin.service_types, list)
|
||||||
self.assertTrue(len(plugin.service_types) >= 1,
|
self.assertGreaterEqual(len(plugin.service_types), 1,
|
||||||
'service_types is not defined for plugin')
|
'service_types is not defined for plugin')
|
||||||
|
|
||||||
@mock.patch.object(client_plugin.ClientPlugin, 'invalidate')
|
@mock.patch.object(client_plugin.ClientPlugin, 'invalidate')
|
||||||
def test_invalidate_all_clients(self, mock_invalidate):
|
def test_invalidate_all_clients(self, mock_invalidate):
|
||||||
|
@ -82,7 +82,7 @@ class SwiftUtilsTest(SwiftClientPluginTestCase):
|
|||||||
self.assertThat(url, matchers.MatchesRegex(regexp))
|
self.assertThat(url, matchers.MatchesRegex(regexp))
|
||||||
|
|
||||||
timeout = int(url.split('=')[-1])
|
timeout = int(url.split('=')[-1])
|
||||||
self.assertTrue(timeout < swift.MAX_EPOCH)
|
self.assertLess(timeout, swift.MAX_EPOCH)
|
||||||
|
|
||||||
def test_get_temp_url_no_account_key(self):
|
def test_get_temp_url_no_account_key(self):
|
||||||
self.swift_client.url = ("http://fake-host.com:8080/v1/"
|
self.swift_client.url = ("http://fake-host.com:8080/v1/"
|
||||||
|
@ -61,8 +61,8 @@ class ResourceTypeConstraintTest(common.HeatTestCase):
|
|||||||
|
|
||||||
# Verify
|
# Verify
|
||||||
self.assertFalse(result)
|
self.assertFalse(result)
|
||||||
self.assertTrue('OS::Heat::None,OS::Heat::RandomString'
|
self.assertIn('OS::Heat::None,OS::Heat::RandomString',
|
||||||
in self.constraint._error_message)
|
self.constraint._error_message)
|
||||||
self.mock_env.get_class.assert_has_calls([mock.call(value[0]),
|
self.mock_env.get_class.assert_has_calls([mock.call(value[0]),
|
||||||
mock.call(value[1])])
|
mock.call(value[1])])
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ class dependenciesTest(common.HeatTestCase):
|
|||||||
for n in ('last', 'middle'):
|
for n in ('last', 'middle'):
|
||||||
self.assertIn(n, order,
|
self.assertIn(n, order,
|
||||||
"'%s' not found in dependency order" % n)
|
"'%s' not found in dependency order" % n)
|
||||||
self.assertTrue(order.index('last') > order.index('middle'))
|
self.assertGreater(order.index('last'), order.index('middle'))
|
||||||
|
|
||||||
def test_simple_multilevel_partial(self):
|
def test_simple_multilevel_partial(self):
|
||||||
d = dependencies.Dependencies([('last', 'middle'),
|
d = dependencies.Dependencies([('last', 'middle'),
|
||||||
|
@ -1283,8 +1283,8 @@ class TimeoutTest(common.HeatTestCase):
|
|||||||
eventlet.sleep(0.01)
|
eventlet.sleep(0.01)
|
||||||
later = scheduler.Timeout(task, 10)
|
later = scheduler.Timeout(task, 10)
|
||||||
|
|
||||||
self.assertTrue(earlier < later)
|
self.assertLess(earlier, later)
|
||||||
self.assertTrue(later > earlier)
|
self.assertGreater(later, earlier)
|
||||||
self.assertEqual(earlier, earlier)
|
self.assertEqual(earlier, earlier)
|
||||||
self.assertNotEqual(earlier, later)
|
self.assertNotEqual(earlier, later)
|
||||||
|
|
||||||
|
@ -1019,7 +1019,7 @@ class CinderVolumeTest(vt_base.BaseVolumeTest):
|
|||||||
self.patchobject(rsrc, '_store_config_default_properties')
|
self.patchobject(rsrc, '_store_config_default_properties')
|
||||||
scheduler.TaskRunner(rsrc.create)()
|
scheduler.TaskRunner(rsrc.create)()
|
||||||
# this makes sure the auto increment worked on volume creation
|
# this makes sure the auto increment worked on volume creation
|
||||||
self.assertTrue(rsrc.id > 0)
|
self.assertGreater(rsrc.id, 0)
|
||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
@ -181,7 +181,8 @@ class InstanceGroupTest(common.HeatTestCase):
|
|||||||
self.assertEqual(1, len(grp.update_policy))
|
self.assertEqual(1, len(grp.update_policy))
|
||||||
self.assertIn('RollingUpdate', grp.update_policy)
|
self.assertIn('RollingUpdate', grp.update_policy)
|
||||||
policy = grp.update_policy['RollingUpdate']
|
policy = grp.update_policy['RollingUpdate']
|
||||||
self.assertTrue(policy and len(policy) > 0)
|
self.assertIsNotNone(policy)
|
||||||
|
self.assertGreater(len(policy), 0)
|
||||||
self.assertEqual(1, int(policy['MinInstancesInService']))
|
self.assertEqual(1, int(policy['MinInstancesInService']))
|
||||||
self.assertEqual(2, int(policy['MaxBatchSize']))
|
self.assertEqual(2, int(policy['MaxBatchSize']))
|
||||||
self.assertEqual('PT1S', policy['PauseTime'])
|
self.assertEqual('PT1S', policy['PauseTime'])
|
||||||
@ -196,7 +197,8 @@ class InstanceGroupTest(common.HeatTestCase):
|
|||||||
self.assertEqual(1, len(grp.update_policy))
|
self.assertEqual(1, len(grp.update_policy))
|
||||||
self.assertIn('RollingUpdate', grp.update_policy)
|
self.assertIn('RollingUpdate', grp.update_policy)
|
||||||
policy = grp.update_policy['RollingUpdate']
|
policy = grp.update_policy['RollingUpdate']
|
||||||
self.assertTrue(policy and len(policy) > 0)
|
self.assertIsNotNone(policy)
|
||||||
|
self.assertGreater(len(policy), 0)
|
||||||
self.assertEqual(0, int(policy['MinInstancesInService']))
|
self.assertEqual(0, int(policy['MinInstancesInService']))
|
||||||
self.assertEqual(1, int(policy['MaxBatchSize']))
|
self.assertEqual(1, int(policy['MaxBatchSize']))
|
||||||
self.assertEqual('PT0S', policy['PauseTime'])
|
self.assertEqual('PT0S', policy['PauseTime'])
|
||||||
|
@ -92,7 +92,7 @@ Resources:
|
|||||||
return stack
|
return stack
|
||||||
|
|
||||||
def assert_min(self, pattern, string, minimum):
|
def assert_min(self, pattern, string, minimum):
|
||||||
self.assertTrue(len(re.findall(pattern, string)) >= minimum)
|
self.assertGreaterEqual(len(re.findall(pattern, string)), minimum)
|
||||||
|
|
||||||
def test_random_string(self):
|
def test_random_string(self):
|
||||||
stack = self.create_stack(self.template_random_string)
|
stack = self.create_stack(self.template_random_string)
|
||||||
|
@ -992,7 +992,8 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
|
|||||||
self.assertEqual(2, len(grp.update_policy))
|
self.assertEqual(2, len(grp.update_policy))
|
||||||
self.assertIn('rolling_update', grp.update_policy)
|
self.assertIn('rolling_update', grp.update_policy)
|
||||||
policy = grp.update_policy['rolling_update']
|
policy = grp.update_policy['rolling_update']
|
||||||
self.assertTrue(policy and len(policy) > 0)
|
self.assertIsNotNone(policy)
|
||||||
|
self.assertGreater(len(policy), 0)
|
||||||
self.assertEqual(1, int(policy['min_in_service']))
|
self.assertEqual(1, int(policy['min_in_service']))
|
||||||
self.assertEqual(tmpl_batch_sz, int(policy['max_batch_size']))
|
self.assertEqual(tmpl_batch_sz, int(policy['max_batch_size']))
|
||||||
self.assertEqual(1, policy['pause_time'])
|
self.assertEqual(1, policy['pause_time'])
|
||||||
@ -1006,7 +1007,8 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
|
|||||||
self.assertEqual(2, len(grp.update_policy))
|
self.assertEqual(2, len(grp.update_policy))
|
||||||
self.assertIn('rolling_update', grp.update_policy)
|
self.assertIn('rolling_update', grp.update_policy)
|
||||||
policy = grp.update_policy['rolling_update']
|
policy = grp.update_policy['rolling_update']
|
||||||
self.assertTrue(policy and len(policy) > 0)
|
self.assertIsNotNone(policy)
|
||||||
|
self.assertGreater(len(policy), 0)
|
||||||
self.assertEqual(0, int(policy['min_in_service']))
|
self.assertEqual(0, int(policy['min_in_service']))
|
||||||
self.assertEqual(1, int(policy['max_batch_size']))
|
self.assertEqual(1, int(policy['max_batch_size']))
|
||||||
self.assertEqual(0, policy['pause_time'])
|
self.assertEqual(0, policy['pause_time'])
|
||||||
|
@ -394,7 +394,7 @@ class ServersTest(common.HeatTestCase):
|
|||||||
server = self._create_test_server(return_server, server_name)
|
server = self._create_test_server(return_server, server_name)
|
||||||
|
|
||||||
# this makes sure the auto increment worked on server creation
|
# this makes sure the auto increment worked on server creation
|
||||||
self.assertTrue(server.id > 0)
|
self.assertGreater(server.id, 0)
|
||||||
|
|
||||||
interfaces = [
|
interfaces = [
|
||||||
self._create_fake_iface('1234', 'fa:16:3e:8c:22:aa', '4.5.6.7'),
|
self._create_fake_iface('1234', 'fa:16:3e:8c:22:aa', '4.5.6.7'),
|
||||||
@ -1066,7 +1066,7 @@ class ServersTest(common.HeatTestCase):
|
|||||||
_, kwargs = mock_create.call_args
|
_, kwargs = mock_create.call_args
|
||||||
self.assertEqual(kwargs['scheduler_hints'], scheduler_hints)
|
self.assertEqual(kwargs['scheduler_hints'], scheduler_hints)
|
||||||
# this makes sure the auto increment worked on server creation
|
# this makes sure the auto increment worked on server creation
|
||||||
self.assertTrue(server.id > 0)
|
self.assertGreater(server.id, 0)
|
||||||
|
|
||||||
def test_check_maximum(self):
|
def test_check_maximum(self):
|
||||||
msg = 'test_check_maximum'
|
msg = 'test_check_maximum'
|
||||||
@ -1451,7 +1451,7 @@ class ServersTest(common.HeatTestCase):
|
|||||||
server.resource_id = '1234'
|
server.resource_id = '1234'
|
||||||
|
|
||||||
# this makes sure the auto increment worked on server creation
|
# this makes sure the auto increment worked on server creation
|
||||||
self.assertTrue(server.id > 0)
|
self.assertGreater(server.id, 0)
|
||||||
|
|
||||||
side_effect = [server, fakes_nova.fake_exception()]
|
side_effect = [server, fakes_nova.fake_exception()]
|
||||||
self.patchobject(self.fc.servers, 'get', side_effect=side_effect)
|
self.patchobject(self.fc.servers, 'get', side_effect=side_effect)
|
||||||
@ -1465,7 +1465,7 @@ class ServersTest(common.HeatTestCase):
|
|||||||
server.resource_id = '1234'
|
server.resource_id = '1234'
|
||||||
|
|
||||||
# this makes sure the auto increment worked on server creation
|
# this makes sure the auto increment worked on server creation
|
||||||
self.assertTrue(server.id > 0)
|
self.assertGreater(server.id, 0)
|
||||||
|
|
||||||
self.patchobject(self.fc.client, 'delete_servers_1234',
|
self.patchobject(self.fc.client, 'delete_servers_1234',
|
||||||
side_effect=fakes_nova.fake_exception())
|
side_effect=fakes_nova.fake_exception())
|
||||||
@ -1479,7 +1479,7 @@ class ServersTest(common.HeatTestCase):
|
|||||||
server.resource_id = '1234'
|
server.resource_id = '1234'
|
||||||
|
|
||||||
# this makes sure the auto increment worked on server creation
|
# this makes sure the auto increment worked on server creation
|
||||||
self.assertTrue(server.id > 0)
|
self.assertGreater(server.id, 0)
|
||||||
|
|
||||||
def make_error(*args):
|
def make_error(*args):
|
||||||
return_server.status = "ERROR"
|
return_server.status = "ERROR"
|
||||||
@ -1525,7 +1525,7 @@ class ServersTest(common.HeatTestCase):
|
|||||||
server.resource_id = '1234'
|
server.resource_id = '1234'
|
||||||
|
|
||||||
# this makes sure the auto increment worked on server creation
|
# this makes sure the auto increment worked on server creation
|
||||||
self.assertTrue(server.id > 0)
|
self.assertGreater(server.id, 0)
|
||||||
|
|
||||||
def make_soft_delete(*args):
|
def make_soft_delete(*args):
|
||||||
return_server.status = "SOFT_DELETED"
|
return_server.status = "SOFT_DELETED"
|
||||||
|
@ -73,7 +73,7 @@ class NovaServerGroupTest(common.HeatTestCase):
|
|||||||
n = name
|
n = name
|
||||||
|
|
||||||
def fake_create(name, policies):
|
def fake_create(name, policies):
|
||||||
self.assertTrue(len(name) > 1)
|
self.assertGreater(len(name), 1)
|
||||||
return FakeGroup(n)
|
return FakeGroup(n)
|
||||||
self.sg_mgr.create = fake_create
|
self.sg_mgr.create = fake_create
|
||||||
scheduler.TaskRunner(self.sg.create)()
|
scheduler.TaskRunner(self.sg.create)()
|
||||||
|
@ -153,7 +153,7 @@ class SwiftTest(common.HeatTestCase):
|
|||||||
|
|
||||||
# Verify Expected Calls
|
# Verify Expected Calls
|
||||||
mock_put.assert_called_once_with(container_name, {})
|
mock_put.assert_called_once_with(container_name, {})
|
||||||
self.assertTrue(mock_head.call_count > 0)
|
self.assertGreater(mock_head.call_count, 0)
|
||||||
|
|
||||||
@mock.patch('swiftclient.client.Connection.put_container')
|
@mock.patch('swiftclient.client.Connection.put_container')
|
||||||
def test_public_read(self, mock_put):
|
def test_public_read(self, mock_put):
|
||||||
|
@ -122,7 +122,7 @@ class StackCreateTest(common.HeatTestCase):
|
|||||||
stack.create()
|
stack.create()
|
||||||
|
|
||||||
self.assertIsNotNone(stack['WebServer'])
|
self.assertIsNotNone(stack['WebServer'])
|
||||||
self.assertTrue(int(stack['WebServer'].resource_id) > 0)
|
self.assertGreater(int(stack['WebServer'].resource_id), 0)
|
||||||
self.assertNotEqual(stack['WebServer'].ipaddress, '0.0.0.0')
|
self.assertNotEqual(stack['WebServer'].ipaddress, '0.0.0.0')
|
||||||
|
|
||||||
def test_wordpress_single_instance_stack_adopt(self):
|
def test_wordpress_single_instance_stack_adopt(self):
|
||||||
@ -188,7 +188,7 @@ class StackCreateTest(common.HeatTestCase):
|
|||||||
self.assertIsNotNone(db_s)
|
self.assertIsNotNone(db_s)
|
||||||
|
|
||||||
self.assertIsNotNone(stack['WebServer'])
|
self.assertIsNotNone(stack['WebServer'])
|
||||||
self.assertTrue(int(stack['WebServer'].resource_id) > 0)
|
self.assertGreater(int(stack['WebServer'].resource_id), 0)
|
||||||
|
|
||||||
self.patchobject(fc.servers, 'delete',
|
self.patchobject(fc.servers, 'delete',
|
||||||
side_effect=fakes_nova.fake_exception())
|
side_effect=fakes_nova.fake_exception())
|
||||||
|
@ -56,7 +56,7 @@ class LifecyclePluginUtilsTest(common.HeatTestCase):
|
|||||||
self.assertIsNotNone(pp_cinstances)
|
self.assertIsNotNone(pp_cinstances)
|
||||||
self.assertTrue(self.is_iterable(pp_cinstances),
|
self.assertTrue(self.is_iterable(pp_cinstances),
|
||||||
"not iterable: %s" % pp_cinstances)
|
"not iterable: %s" % pp_cinstances)
|
||||||
self.assertTrue(len(pp_cinstances) == 1)
|
self.assertEqual(1, len(pp_cinstances))
|
||||||
self.assertEqual(TestLifecycleCallout1, pp_cinstances[0].__class__)
|
self.assertEqual(TestLifecycleCallout1, pp_cinstances[0].__class__)
|
||||||
|
|
||||||
def test_do_pre_and_post_callouts(self):
|
def test_do_pre_and_post_callouts(self):
|
||||||
|
@ -284,7 +284,7 @@ class WaitConditionMetadataUpdateTest(common.HeatTestCase):
|
|||||||
jsonutils.loads(inst.metadata_get(refresh=True)['test']))
|
jsonutils.loads(inst.metadata_get(refresh=True)['test']))
|
||||||
|
|
||||||
# Verify outgoing calls
|
# Verify outgoing calls
|
||||||
self.assertTrue(mock_available.call_count > 0)
|
self.assertGreater(mock_available.call_count, 0)
|
||||||
self.assertEqual(2, mock_handle.call_count)
|
self.assertEqual(2, mock_handle.call_count)
|
||||||
self.assertEqual(2, mock_check.call_count)
|
self.assertEqual(2, mock_check.call_count)
|
||||||
|
|
||||||
|
@ -4229,7 +4229,7 @@ class TestResourceMapping(common.HeatTestCase):
|
|||||||
type_elements = r_type.split('::')
|
type_elements = r_type.split('::')
|
||||||
# type has fixed format
|
# type has fixed format
|
||||||
# Platform type::Service/Type::Optional Sub-sections::Name
|
# Platform type::Service/Type::Optional Sub-sections::Name
|
||||||
self.assertTrue(len(type_elements) >= 3)
|
self.assertGreaterEqual(len(type_elements), 3)
|
||||||
# type should be OS or AWS
|
# type should be OS or AWS
|
||||||
self.assertIn(type_elements[0], ('AWS', 'OS'))
|
self.assertIn(type_elements[0], ('AWS', 'OS'))
|
||||||
# check that value is a class object
|
# check that value is a class object
|
||||||
@ -4257,4 +4257,4 @@ class TestResourceMapping(common.HeatTestCase):
|
|||||||
# that there is no regressions
|
# that there is no regressions
|
||||||
# It's soft check and should not be a cause of the merge conflict
|
# It's soft check and should not be a cause of the merge conflict
|
||||||
# Feel free to update it in some separate patch
|
# Feel free to update it in some separate patch
|
||||||
self.assertTrue(num_of_types >= 137)
|
self.assertGreaterEqual(num_of_types, 137)
|
||||||
|
@ -47,9 +47,10 @@ class JsonToYamlTest(common.HeatTestCase):
|
|||||||
if template_test_count >= self.expected_test_count:
|
if template_test_count >= self.expected_test_count:
|
||||||
break
|
break
|
||||||
|
|
||||||
self.assertTrue(template_test_count >= self.expected_test_count,
|
self.assertGreaterEqual(
|
||||||
'Expected at least %d templates to be tested, not %d' %
|
template_test_count, self.expected_test_count,
|
||||||
(self.expected_test_count, template_test_count))
|
'Expected at least %d templates to be tested, not %d' %
|
||||||
|
(self.expected_test_count, template_test_count))
|
||||||
|
|
||||||
def compare_json_vs_yaml(self, json_str, yml_str):
|
def compare_json_vs_yaml(self, json_str, yml_str):
|
||||||
yml = template_format.parse(yml_str)
|
yml = template_format.parse(yml_str)
|
||||||
@ -103,7 +104,7 @@ class YamlMinimalTest(common.HeatTestCase):
|
|||||||
config.cfg.CONF.max_template_size / 3)
|
config.cfg.CONF.max_template_size / 3)
|
||||||
limit = config.cfg.CONF.max_template_size
|
limit = config.cfg.CONF.max_template_size
|
||||||
long_yaml = yaml.safe_dump(template)
|
long_yaml = yaml.safe_dump(template)
|
||||||
self.assertTrue(len(long_yaml) > limit)
|
self.assertGreater(len(long_yaml), limit)
|
||||||
ex = self.assertRaises(exception.RequestLimitExceeded,
|
ex = self.assertRaises(exception.RequestLimitExceeded,
|
||||||
template_format.parse, long_yaml)
|
template_format.parse, long_yaml)
|
||||||
msg = ('Request limit exceeded: Template size (%(actual_len)s '
|
msg = ('Request limit exceeded: Template size (%(actual_len)s '
|
||||||
|
@ -512,7 +512,7 @@ class WatchRuleTest(common.HeatTestCase):
|
|||||||
actions = wr.evaluate()
|
actions = wr.evaluate()
|
||||||
self.assertEqual('ALARM', wr.state)
|
self.assertEqual('ALARM', wr.state)
|
||||||
self.assertEqual(['DummyAction'], actions)
|
self.assertEqual(['DummyAction'], actions)
|
||||||
self.assertTrue(mock_get_resource.call_count > 0)
|
self.assertGreater(mock_get_resource.call_count, 0)
|
||||||
|
|
||||||
@mock.patch('heat.engine.stack.Stack.resource_by_refid')
|
@mock.patch('heat.engine.stack.Stack.resource_by_refid')
|
||||||
def test_rule_actions_alarm_two_actions(self, mock_get_resource):
|
def test_rule_actions_alarm_two_actions(self, mock_get_resource):
|
||||||
@ -542,7 +542,7 @@ class WatchRuleTest(common.HeatTestCase):
|
|||||||
actions = wr.evaluate()
|
actions = wr.evaluate()
|
||||||
self.assertEqual('ALARM', wr.state)
|
self.assertEqual('ALARM', wr.state)
|
||||||
self.assertEqual(['DummyAction', 'DummyAction'], actions)
|
self.assertEqual(['DummyAction', 'DummyAction'], actions)
|
||||||
self.assertTrue(mock_get_resource.call_count > 0)
|
self.assertGreater(mock_get_resource.call_count, 0)
|
||||||
|
|
||||||
@mock.patch('heat.engine.stack.Stack.resource_by_refid')
|
@mock.patch('heat.engine.stack.Stack.resource_by_refid')
|
||||||
def test_rule_actions_ok_alarm(self, mock_get_resource):
|
def test_rule_actions_ok_alarm(self, mock_get_resource):
|
||||||
@ -583,7 +583,7 @@ class WatchRuleTest(common.HeatTestCase):
|
|||||||
actions = wr.evaluate()
|
actions = wr.evaluate()
|
||||||
self.assertEqual('NORMAL', wr.state)
|
self.assertEqual('NORMAL', wr.state)
|
||||||
self.assertEqual(['DummyAction'], actions)
|
self.assertEqual(['DummyAction'], actions)
|
||||||
self.assertTrue(mock_get_resource.call_count > 0)
|
self.assertGreater(mock_get_resource.call_count, 0)
|
||||||
|
|
||||||
@mock.patch('heat.engine.stack.Stack.resource_by_refid')
|
@mock.patch('heat.engine.stack.Stack.resource_by_refid')
|
||||||
def test_rule_actions_nodata(self, mock_get_resource):
|
def test_rule_actions_nodata(self, mock_get_resource):
|
||||||
@ -622,7 +622,7 @@ class WatchRuleTest(common.HeatTestCase):
|
|||||||
actions = wr.evaluate()
|
actions = wr.evaluate()
|
||||||
self.assertEqual('NODATA', wr.state)
|
self.assertEqual('NODATA', wr.state)
|
||||||
self.assertEqual(['DummyAction'], actions)
|
self.assertEqual(['DummyAction'], actions)
|
||||||
self.assertTrue(mock_get_resource.call_count > 0)
|
self.assertGreater(mock_get_resource.call_count, 0)
|
||||||
|
|
||||||
@mock.patch('heat.engine.stack.Stack.resource_by_refid')
|
@mock.patch('heat.engine.stack.Stack.resource_by_refid')
|
||||||
def test_to_ceilometer(self, mock_get_resource):
|
def test_to_ceilometer(self, mock_get_resource):
|
||||||
@ -951,7 +951,7 @@ class WatchRuleTest(common.HeatTestCase):
|
|||||||
|
|
||||||
actions = wr.set_watch_state(watchrule.WatchRule.ALARM)
|
actions = wr.set_watch_state(watchrule.WatchRule.ALARM)
|
||||||
self.assertEqual(['DummyAction'], actions)
|
self.assertEqual(['DummyAction'], actions)
|
||||||
self.assertTrue(mock_get_resource.call_count > 0)
|
self.assertGreater(mock_get_resource.call_count, 0)
|
||||||
|
|
||||||
def test_set_watch_state_invalid(self):
|
def test_set_watch_state_invalid(self):
|
||||||
# Setup
|
# Setup
|
||||||
|
@ -58,7 +58,7 @@ class ResourceChainTests(functional_base.FunctionalTestsBase):
|
|||||||
|
|
||||||
# Verify
|
# Verify
|
||||||
stack = self.client.stacks.get(stack_id)
|
stack = self.client.stacks.get(stack_id)
|
||||||
self.assertTrue(stack is not None)
|
self.assertIsNotNone(stack)
|
||||||
|
|
||||||
# Top-level resource for chain
|
# Top-level resource for chain
|
||||||
expected = {'my-chain': 'OS::Heat::ResourceChain'}
|
expected = {'my-chain': 'OS::Heat::ResourceChain'}
|
||||||
@ -74,15 +74,15 @@ class ResourceChainTests(functional_base.FunctionalTestsBase):
|
|||||||
|
|
||||||
# Outputs
|
# Outputs
|
||||||
resource_ids = self._stack_output(stack, 'resource-ids')
|
resource_ids = self._stack_output(stack, 'resource-ids')
|
||||||
self.assertTrue(resource_ids is not None)
|
self.assertIsNotNone(resource_ids)
|
||||||
self.assertEqual(2, len(resource_ids))
|
self.assertEqual(2, len(resource_ids))
|
||||||
|
|
||||||
resource_value = self._stack_output(stack, 'resource-0-value')
|
resource_value = self._stack_output(stack, 'resource-0-value')
|
||||||
self.assertTrue(resource_value is not None)
|
self.assertIsNotNone(resource_value)
|
||||||
self.assertEqual(8, len(resource_value)) # from parameter
|
self.assertEqual(8, len(resource_value)) # from parameter
|
||||||
|
|
||||||
resource_attrs = self._stack_output(stack, 'all-resource-attrs')
|
resource_attrs = self._stack_output(stack, 'all-resource-attrs')
|
||||||
self.assertTrue(resource_attrs is not None)
|
self.assertIsNotNone(resource_attrs)
|
||||||
self.assertIsInstance(resource_attrs, dict)
|
self.assertIsInstance(resource_attrs, dict)
|
||||||
self.assertEqual(2, len(resource_attrs))
|
self.assertEqual(2, len(resource_attrs))
|
||||||
self.assertEqual(8, len(resource_attrs['0']))
|
self.assertEqual(8, len(resource_attrs['0']))
|
||||||
|
@ -74,7 +74,7 @@ outputs:
|
|||||||
stack_event.resource_name)
|
stack_event.resource_name)
|
||||||
|
|
||||||
# Resource events are a subset of the original stack event list
|
# Resource events are a subset of the original stack event list
|
||||||
self.assertTrue(len(resource_events) < len(stack_events))
|
self.assertLess(len(resource_events), len(stack_events))
|
||||||
|
|
||||||
# Get the event details for each resource event
|
# Get the event details for each resource event
|
||||||
for resource_event in resource_events:
|
for resource_event in resource_events:
|
||||||
|
@ -100,7 +100,7 @@ class SoftwareConfigIntegrationTest(scenario_base.ScenarioTestsBase):
|
|||||||
res1['result'])
|
res1['result'])
|
||||||
self.assertEqual(0, res1['status_code'])
|
self.assertEqual(0, res1['status_code'])
|
||||||
self.assertEqual('Output to stderr\n', res1['stderr'])
|
self.assertEqual('Output to stderr\n', res1['stderr'])
|
||||||
self.assertTrue(len(res1['stdout']) > 0)
|
self.assertGreater(len(res1['stdout']), 0)
|
||||||
|
|
||||||
res2 = self._stack_output(stack, 'res2')
|
res2 = self._stack_output(stack, 'res2')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -118,7 +118,7 @@ class SoftwareConfigIntegrationTest(scenario_base.ScenarioTestsBase):
|
|||||||
res3['result'])
|
res3['result'])
|
||||||
self.assertEqual(0, res3['status_code'])
|
self.assertEqual(0, res3['status_code'])
|
||||||
self.assertEqual('', res3['stderr'])
|
self.assertEqual('', res3['stderr'])
|
||||||
self.assertTrue(len(res1['stdout']) > 0)
|
self.assertGreater(len(res1['stdout']), 0)
|
||||||
|
|
||||||
dep1_resource = self.client.resources.get(sid, 'dep1')
|
dep1_resource = self.client.resources.get(sid, 'dep1')
|
||||||
dep1_id = dep1_resource.physical_resource_id
|
dep1_id = dep1_resource.physical_resource_id
|
||||||
|
Loading…
Reference in New Issue
Block a user