Merge "Fix comparison with singletons"

This commit is contained in:
Jenkins 2014-01-17 05:05:38 +00:00 committed by Gerrit Code Review
commit 201b36255a
25 changed files with 154 additions and 157 deletions

View File

@ -61,7 +61,7 @@ class DockerContainerTest(HeatTestCase):
resource_name, t['Resources'][resource_name], stack) resource_name, t['Resources'][resource_name], stack)
self.m.StubOutWithMock(resource, 'get_client') self.m.StubOutWithMock(resource, 'get_client')
resource.get_client().MultipleTimes().AndReturn(FakeDockerClient()) resource.get_client().MultipleTimes().AndReturn(FakeDockerClient())
self.assertEqual(None, resource.validate()) self.assertIsNone(resource.validate())
self.m.ReplayAll() self.m.ReplayAll()
scheduler.TaskRunner(resource.create)() scheduler.TaskRunner(resource.create)()
self.assertEqual(resource.state, (resource.CREATE, self.assertEqual(resource.state, (resource.CREATE,
@ -76,7 +76,7 @@ class DockerContainerTest(HeatTestCase):
container = self.create_container('Blog') container = self.create_container('Blog')
self.assertTrue(container.resource_id) self.assertTrue(container.resource_id)
running = self.get_container_state(container)['Running'] running = self.get_container_state(container)['Running']
self.assertEqual(True, running) self.assertIs(True, running)
self.m.VerifyAll() self.m.VerifyAll()
def test_resource_attributes(self): def test_resource_attributes(self):
@ -99,7 +99,7 @@ class DockerContainerTest(HeatTestCase):
self.assertEqual(container.state, (container.DELETE, self.assertEqual(container.state, (container.DELETE,
container.COMPLETE)) container.COMPLETE))
running = self.get_container_state(container)['Running'] running = self.get_container_state(container)['Running']
self.assertEqual(False, running) self.assertIs(False, running)
self.m.VerifyAll() self.m.VerifyAll()
def test_resource_suspend_resume(self): def test_resource_suspend_resume(self):
@ -109,11 +109,11 @@ class DockerContainerTest(HeatTestCase):
self.assertEqual(container.state, (container.SUSPEND, self.assertEqual(container.state, (container.SUSPEND,
container.COMPLETE)) container.COMPLETE))
running = self.get_container_state(container)['Running'] running = self.get_container_state(container)['Running']
self.assertEqual(False, running) self.assertIs(False, running)
# Test resume # Test resume
scheduler.TaskRunner(container.resume)() scheduler.TaskRunner(container.resume)()
self.assertEqual(container.state, (container.RESUME, self.assertEqual(container.state, (container.RESUME,
container.COMPLETE)) container.COMPLETE))
running = self.get_container_state(container)['Running'] running = self.get_container_state(container)['Running']
self.assertEqual(True, running) self.assertIs(True, running)
self.m.VerifyAll() self.m.VerifyAll()

View File

@ -521,7 +521,7 @@ class WebHookTest(HeatTestCase):
self.stack = utils.parse_stack(template) self.stack = utils.parse_stack(template)
self.stack.create() self.stack.create()
resource = self.stack['my_webhook'] resource = self.stack['my_webhook']
self.assertIs(resource.FnGetAtt('capabilityUrl'), None) self.assertIsNone(resource.FnGetAtt('capabilityUrl'))
def test_update(self): def test_update(self):
self._setup_test_stack(self.webhook_template) self._setup_test_stack(self.webhook_template)

View File

@ -309,7 +309,7 @@ class LoadBalancerTest(HeatTestCase):
rsrc, fake_loadbalancer = self._mock_loadbalancer(template, rsrc, fake_loadbalancer = self._mock_loadbalancer(template,
self.lb_name, self.lb_name,
expected) expected)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
#test TCP_CLIENT_FIRST protocol #test TCP_CLIENT_FIRST protocol
template = self._set_template(template, template = self._set_template(template,
@ -319,7 +319,7 @@ class LoadBalancerTest(HeatTestCase):
rsrc, fake_loadbalancer = self._mock_loadbalancer(template, rsrc, fake_loadbalancer = self._mock_loadbalancer(template,
self.lb_name, self.lb_name,
expected) expected)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
def test_validate_health_monitor(self): def test_validate_health_monitor(self):
#test connect success #test connect success
@ -337,7 +337,7 @@ class LoadBalancerTest(HeatTestCase):
self.lb_name, self.lb_name,
expected) expected)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
#test connect failure #test connect failure
#bodyRegex is only valid for type 'HTTP(S)' #bodyRegex is only valid for type 'HTTP(S)'
@ -366,7 +366,7 @@ class LoadBalancerTest(HeatTestCase):
rsrc, fake_loadbalancer = self._mock_loadbalancer(template, rsrc, fake_loadbalancer = self._mock_loadbalancer(template,
self.lb_name, self.lb_name,
expected) expected)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
def test_validate_ssl_termination(self): def test_validate_ssl_termination(self):
ssl_termination = { ssl_termination = {
@ -395,7 +395,7 @@ class LoadBalancerTest(HeatTestCase):
rsrc, fake_loadbalancer = self._mock_loadbalancer(template, rsrc, fake_loadbalancer = self._mock_loadbalancer(template,
self.lb_name, self.lb_name,
expected) expected)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
def test_post_creation_access_list(self): def test_post_creation_access_list(self):
access_list = [{"address": '192.168.1.1/0', access_list = [{"address": '192.168.1.1/0',

View File

@ -122,8 +122,8 @@ class CloudDBInstanceTest(HeatTestCase):
def test_clouddbinstance(self): def test_clouddbinstance(self):
instance = self._setup_test_clouddbinstance('dbinstance') instance = self._setup_test_clouddbinstance('dbinstance')
self.assertEqual(instance.hostname, None) self.assertIsNone(instance.hostname)
self.assertEqual(instance.href, None) self.assertIsNone(instance.href)
def test_clouddbinstance_create(self): def test_clouddbinstance_create(self):
instance = self._setup_test_clouddbinstance('dbinstance_create') instance = self._setup_test_clouddbinstance('dbinstance_create')
@ -169,7 +169,7 @@ class CloudDBInstanceTest(HeatTestCase):
volume=30).AndReturn(fakedbinstance) volume=30).AndReturn(fakedbinstance)
self.m.ReplayAll() self.m.ReplayAll()
instance.handle_create() instance.handle_create()
self.assertEqual(instance._resolve_attribute('invalid-attrib'), None) self.assertIsNone(instance._resolve_attribute('invalid-attrib'))
self.m.VerifyAll() self.m.VerifyAll()
def test_clouddbinstance_delete(self): def test_clouddbinstance_delete(self):
@ -187,7 +187,7 @@ class CloudDBInstanceTest(HeatTestCase):
inject_property_error=False) inject_property_error=False)
self.m.ReplayAll() self.m.ReplayAll()
ret = instance.validate() ret = instance.validate()
self.assertEqual(ret, None) self.assertIsNone(ret)
self.m.VerifyAll() self.m.VerifyAll()
def test_clouddbinstance_param_validation_fail(self): def test_clouddbinstance_param_validation_fail(self):

View File

@ -243,7 +243,7 @@ class RackspaceCloudServerTest(HeatTestCase):
cs = cloud_server.CloudServer('cs_create_image_err', cs = cloud_server.CloudServer('cs_create_image_err',
t['Resources']['WebServer'], stack) t['Resources']['WebServer'], stack)
self.assertEqual(None, cs.validate()) self.assertIsNone(cs.validate())
self.m.VerifyAll() self.m.VerifyAll()
def test_cs_create_heatscript_nonzero_exit_status(self): def test_cs_create_heatscript_nonzero_exit_status(self):
@ -316,7 +316,7 @@ class RackspaceCloudServerTest(HeatTestCase):
mox.Replay(get) mox.Replay(get)
scheduler.TaskRunner(cs.delete)() scheduler.TaskRunner(cs.delete)()
self.assertTrue(cs.resource_id is None) self.assertIsNone(cs.resource_id)
self.assertEqual(cs.state, (cs.DELETE, cs.COMPLETE)) self.assertEqual(cs.state, (cs.DELETE, cs.COMPLETE))
self.m.VerifyAll() self.m.VerifyAll()

View File

@ -1070,7 +1070,7 @@ class AutoScalingTest(HeatTestCase):
'WebServerScaleUpPolicy') 'WebServerScaleUpPolicy')
alarm_url = up_policy.FnGetAtt('AlarmUrl') alarm_url = up_policy.FnGetAtt('AlarmUrl')
self.assertNotEqual(None, alarm_url) self.assertIsNotNone(alarm_url)
ex = self.assertRaises(exception.ResourceFailure, up_policy.signal) ex = self.assertRaises(exception.ResourceFailure, up_policy.signal)
self.assertIn('Alarm WebServerScaleUpPolicy could ' self.assertIn('Alarm WebServerScaleUpPolicy could '
'not find scaling group', str(ex)) 'not find scaling group', str(ex))

View File

@ -166,7 +166,7 @@ class OSDBInstanceTest(HeatTestCase):
self.m.ReplayAll() self.m.ReplayAll()
scheduler.TaskRunner(instance.delete)() scheduler.TaskRunner(instance.delete)()
self.assertEqual(None, instance.resource_id) self.assertIsNone(instance.resource_id)
self.m.VerifyAll() self.m.VerifyAll()
def test_osdatabase_delete_resource_none(self): def test_osdatabase_delete_resource_none(self):
@ -179,7 +179,7 @@ class OSDBInstanceTest(HeatTestCase):
self.m.ReplayAll() self.m.ReplayAll()
scheduler.TaskRunner(instance.delete)() scheduler.TaskRunner(instance.delete)()
self.assertEqual(None, instance.resource_id) self.assertIsNone(instance.resource_id)
self.m.VerifyAll() self.m.VerifyAll()
def test_osdatabase_resource_not_found(self): def test_osdatabase_resource_not_found(self):
@ -193,14 +193,14 @@ class OSDBInstanceTest(HeatTestCase):
self.m.ReplayAll() self.m.ReplayAll()
scheduler.TaskRunner(instance.delete)() scheduler.TaskRunner(instance.delete)()
self.assertEqual(None, instance.resource_id) self.assertIsNone(instance.resource_id)
self.m.VerifyAll() self.m.VerifyAll()
def test_osdatabase_invalid_attribute(self): def test_osdatabase_invalid_attribute(self):
t = template_format.parse(wp_template) t = template_format.parse(wp_template)
instance = self._setup_test_clouddbinstance("db_invalid_attrib", t) instance = self._setup_test_clouddbinstance("db_invalid_attrib", t)
attrib = instance._resolve_attribute("invalid_attrib") attrib = instance._resolve_attribute("invalid_attrib")
self.assertEqual(None, attrib) self.assertIsNone(attrib)
self.m.VerifyAll() self.m.VerifyAll()
def test_osdatabase_get_hostname(self): def test_osdatabase_get_hostname(self):
@ -245,13 +245,13 @@ class OSDBInstanceTest(HeatTestCase):
self.fc.instances.get(12345).AndReturn(fake_dbinstance) self.fc.instances.get(12345).AndReturn(fake_dbinstance)
self.m.ReplayAll() self.m.ReplayAll()
attrib = instance._resolve_attribute('href') attrib = instance._resolve_attribute('href')
self.assertEqual(None, attrib) self.assertIsNone(attrib)
def test_osdatabase_prop_validation_success(self): def test_osdatabase_prop_validation_success(self):
t = template_format.parse(wp_template) t = template_format.parse(wp_template)
instance = self._setup_test_clouddbinstance('dbinstance_test', t) instance = self._setup_test_clouddbinstance('dbinstance_test', t)
ret = instance.validate() ret = instance.validate()
self.assertEqual(None, ret) self.assertIsNone(ret)
def test_osdatabase_prop_validation_invaliddb(self): def test_osdatabase_prop_validation_invaliddb(self):
t = template_format.parse(wp_template) t = template_format.parse(wp_template)
@ -269,7 +269,7 @@ class OSDBInstanceTest(HeatTestCase):
t['Resources']['MySqlCloudDB']['Properties']['users'] = [] t['Resources']['MySqlCloudDB']['Properties']['users'] = []
instance = self._setup_test_clouddbinstance('dbinstance_test', t) instance = self._setup_test_clouddbinstance('dbinstance_test', t)
ret = instance.validate() ret = instance.validate()
self.assertEqual(None, ret) self.assertIsNone(ret)
def test_osdatabase_prop_validation_databases_none(self): def test_osdatabase_prop_validation_databases_none(self):
t = template_format.parse(wp_template) t = template_format.parse(wp_template)

View File

@ -50,14 +50,14 @@ class ParserTest(HeatTestCase):
parsed = join(raw) parsed = join(raw)
for i in xrange(len(raw)): for i in xrange(len(raw)):
self.assertEqual(parsed[i], raw[i]) self.assertEqual(parsed[i], raw[i])
self.assertTrue(parsed is not raw) self.assertIsNot(raw, parsed)
def test_dict(self): def test_dict(self):
raw = {'foo': 'bar', 'blarg': 'wibble'} raw = {'foo': 'bar', 'blarg': 'wibble'}
parsed = join(raw) parsed = join(raw)
for k in raw: for k in raw:
self.assertEqual(parsed[k], raw[k]) self.assertEqual(parsed[k], raw[k])
self.assertTrue(parsed is not raw) self.assertIsNot(raw, parsed)
def test_dict_list(self): def test_dict_list(self):
raw = {'foo': ['bar', 'baz'], 'blarg': 'wibble'} raw = {'foo': ['bar', 'baz'], 'blarg': 'wibble'}
@ -65,8 +65,8 @@ class ParserTest(HeatTestCase):
self.assertEqual(parsed['blarg'], raw['blarg']) self.assertEqual(parsed['blarg'], raw['blarg'])
for i in xrange(len(raw['foo'])): for i in xrange(len(raw['foo'])):
self.assertEqual(parsed['foo'][i], raw['foo'][i]) self.assertEqual(parsed['foo'][i], raw['foo'][i])
self.assertTrue(parsed is not raw) self.assertIsNot(raw, parsed)
self.assertTrue(parsed['foo'] is not raw['foo']) self.assertIsNot(raw['foo'], parsed['foo'])
def test_list_dict(self): def test_list_dict(self):
raw = [{'foo': 'bar', 'blarg': 'wibble'}, 'baz', 'quux'] raw = [{'foo': 'bar', 'blarg': 'wibble'}, 'baz', 'quux']
@ -75,8 +75,8 @@ class ParserTest(HeatTestCase):
self.assertEqual(parsed[i], raw[i]) self.assertEqual(parsed[i], raw[i])
for k in raw[0]: for k in raw[0]:
self.assertEqual(parsed[0][k], raw[0][k]) self.assertEqual(parsed[0][k], raw[0][k])
self.assertTrue(parsed is not raw) self.assertIsNot(raw, parsed)
self.assertTrue(parsed[0] is not raw[0]) self.assertIsNot(raw[0], parsed[0])
def test_join(self): def test_join(self):
raw = {'Fn::Join': [' ', ['foo', 'bar', 'baz']]} raw = {'Fn::Join': [' ', ['foo', 'bar', 'baz']]}
@ -92,7 +92,7 @@ class ParserTest(HeatTestCase):
self.assertEqual(parsed[0], 'foo bar baz') self.assertEqual(parsed[0], 'foo bar baz')
for i in xrange(1, len(raw)): for i in xrange(1, len(raw)):
self.assertEqual(parsed[i], raw[i]) self.assertEqual(parsed[i], raw[i])
self.assertTrue(parsed is not raw) self.assertIsNot(raw, parsed)
def test_join_dict_val(self): def test_join_dict_val(self):
raw = {'quux': {'Fn::Join': [' ', ['foo', 'bar', 'baz']]}, raw = {'quux': {'Fn::Join': [' ', ['foo', 'bar', 'baz']]},
@ -100,7 +100,7 @@ class ParserTest(HeatTestCase):
parsed = join(raw) parsed = join(raw)
self.assertEqual(parsed['quux'], 'foo bar baz') self.assertEqual(parsed['quux'], 'foo bar baz')
self.assertEqual(parsed['blarg'], raw['blarg']) self.assertEqual(parsed['blarg'], raw['blarg'])
self.assertTrue(parsed is not raw) self.assertIsNot(raw, parsed)
mapping_template = template_format.parse('''{ mapping_template = template_format.parse('''{
@ -807,7 +807,7 @@ class StackTest(HeatTestCase):
def test_total_resources_nested(self): def test_total_resources_nested(self):
self._setup_nested('zyzzyx') self._setup_nested('zyzzyx')
self.assertEqual(4, self.stack.total_resources()) self.assertEqual(4, self.stack.total_resources())
self.assertNotEqual(None, self.stack['A'].nested()) self.assertIsNotNone(self.stack['A'].nested())
self.assertEqual( self.assertEqual(
2, self.stack['A'].nested().total_resources()) 2, self.stack['A'].nested().total_resources())
self.assertEqual( self.assertEqual(
@ -818,7 +818,7 @@ class StackTest(HeatTestCase):
def test_root_stack(self): def test_root_stack(self):
self._setup_nested('toor') self._setup_nested('toor')
self.assertEqual(self.stack, self.stack.root_stack) self.assertEqual(self.stack, self.stack.root_stack)
self.assertNotEqual(None, self.stack['A'].nested()) self.assertIsNotNone(self.stack['A'].nested())
self.assertEqual( self.assertEqual(
self.stack, self.stack['A'].nested().root_stack) self.stack, self.stack['A'].nested().root_stack)
@ -877,11 +877,11 @@ class StackTest(HeatTestCase):
parser.Template(tpl)) parser.Template(tpl))
self.stack.store() self.stack.store()
info = self.stack.get_abandon_data() info = self.stack.get_abandon_data()
self.assertEqual(None, info['action']) self.assertIsNone(info['action'])
self.assertIn('id', info) self.assertIn('id', info)
self.assertEqual('stack_details_test', info['name']) self.assertEqual('stack_details_test', info['name'])
self.assertEqual(json.loads(resources), info['resources']) self.assertEqual(json.loads(resources), info['resources'])
self.assertEqual(None, info['status']) self.assertIsNone(info['status'])
self.assertEqual(tpl, info['template']) self.assertEqual(tpl, info['template'])
@utils.stack_delete_after @utils.stack_delete_after
@ -962,19 +962,19 @@ class StackTest(HeatTestCase):
def test_created_time(self): def test_created_time(self):
self.stack = parser.Stack(self.ctx, 'creation_time_test', self.stack = parser.Stack(self.ctx, 'creation_time_test',
parser.Template({})) parser.Template({}))
self.assertEqual(self.stack.created_time, None) self.assertIsNone(self.stack.created_time)
self.stack.store() self.stack.store()
self.assertNotEqual(self.stack.created_time, None) self.assertIsNotNone(self.stack.created_time)
@utils.stack_delete_after @utils.stack_delete_after
def test_updated_time(self): def test_updated_time(self):
self.stack = parser.Stack(self.ctx, 'update_time_test', self.stack = parser.Stack(self.ctx, 'update_time_test',
parser.Template({})) parser.Template({}))
self.assertEqual(self.stack.updated_time, None) self.assertIsNone(self.stack.updated_time)
self.stack.store() self.stack.store()
stored_time = self.stack.updated_time stored_time = self.stack.updated_time
self.stack.state_set(self.stack.CREATE, self.stack.IN_PROGRESS, 'test') self.stack.state_set(self.stack.CREATE, self.stack.IN_PROGRESS, 'test')
self.assertNotEqual(self.stack.updated_time, None) self.assertIsNotNone(self.stack.updated_time)
self.assertNotEqual(self.stack.updated_time, stored_time) self.assertNotEqual(self.stack.updated_time, stored_time)
@utils.stack_delete_after @utils.stack_delete_after
@ -984,12 +984,12 @@ class StackTest(HeatTestCase):
stack_id = self.stack.store() stack_id = self.stack.store()
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertNotEqual(db_s, None) self.assertIsNotNone(db_s)
self.stack.delete() self.stack.delete()
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertEqual(db_s, None) self.assertIsNone(db_s)
self.assertEqual(self.stack.state, self.assertEqual(self.stack.state,
(parser.Stack.DELETE, parser.Stack.COMPLETE)) (parser.Stack.DELETE, parser.Stack.COMPLETE))
@ -1007,12 +1007,12 @@ class StackTest(HeatTestCase):
stack_id = self.stack.store() stack_id = self.stack.store()
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertNotEqual(db_s, None) self.assertIsNotNone(db_s)
self.stack.delete() self.stack.delete()
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertEqual(db_s, None) self.assertIsNone(db_s)
self.assertEqual(self.stack.state, self.assertEqual(self.stack.state,
(parser.Stack.DELETE, parser.Stack.COMPLETE)) (parser.Stack.DELETE, parser.Stack.COMPLETE))
@ -1178,12 +1178,12 @@ class StackTest(HeatTestCase):
stack_id = self.stack.store() stack_id = self.stack.store()
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertNotEqual(db_s, None) self.assertIsNotNone(db_s)
self.stack.delete(action=self.stack.ROLLBACK) self.stack.delete(action=self.stack.ROLLBACK)
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertEqual(db_s, None) self.assertIsNone(db_s)
self.assertEqual(self.stack.state, self.assertEqual(self.stack.state,
(parser.Stack.ROLLBACK, parser.Stack.COMPLETE)) (parser.Stack.ROLLBACK, parser.Stack.COMPLETE))
@ -1194,12 +1194,12 @@ class StackTest(HeatTestCase):
stack_id = self.stack.store() stack_id = self.stack.store()
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertNotEqual(db_s, None) self.assertIsNotNone(db_s)
self.stack.delete(action="wibble") self.stack.delete(action="wibble")
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertNotEqual(db_s, None) self.assertIsNotNone(db_s)
self.assertEqual(self.stack.state, self.assertEqual(self.stack.state,
(parser.Stack.DELETE, parser.Stack.FAILED)) (parser.Stack.DELETE, parser.Stack.FAILED))
@ -1228,7 +1228,7 @@ class StackTest(HeatTestCase):
self.assertIn('AResource', self.stack) self.assertIn('AResource', self.stack)
rsrc = self.stack['AResource'] rsrc = self.stack['AResource']
rsrc.resource_id_set('aaaa') rsrc.resource_id_set('aaaa')
self.assertNotEqual(None, resource) self.assertIsNotNone(resource)
for action, status in ( for action, status in (
(rsrc.CREATE, rsrc.IN_PROGRESS), (rsrc.CREATE, rsrc.IN_PROGRESS),
@ -1242,8 +1242,8 @@ class StackTest(HeatTestCase):
rsrc.state_set(rsrc.DELETE, rsrc.IN_PROGRESS) rsrc.state_set(rsrc.DELETE, rsrc.IN_PROGRESS)
try: try:
self.assertEqual(None, self.stack.resource_by_refid('aaaa')) self.assertIsNone(self.stack.resource_by_refid('aaaa'))
self.assertEqual(None, self.stack.resource_by_refid('bbbb')) self.assertIsNone(self.stack.resource_by_refid('bbbb'))
finally: finally:
rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE) rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE)
@ -1896,7 +1896,7 @@ class StackTest(HeatTestCase):
stack_id = stack.store() stack_id = stack.store()
db_s = db_api.stack_get(self.ctx, stack_id) db_s = db_api.stack_get(self.ctx, stack_id)
self.assertNotEqual(db_s, None) self.assertIsNotNone(db_s)
self.m.StubOutWithMock(scheduler.DependencyTaskGroup, '__call__') self.m.StubOutWithMock(scheduler.DependencyTaskGroup, '__call__')
self.m.StubOutWithMock(scheduler, 'wallclock') self.m.StubOutWithMock(scheduler, 'wallclock')
@ -2026,7 +2026,7 @@ class StackTest(HeatTestCase):
(rsrc.DELETE, rsrc.COMPLETE), (rsrc.DELETE, rsrc.COMPLETE),
(rsrc.UPDATE, rsrc.FAILED)): (rsrc.UPDATE, rsrc.FAILED)):
rsrc.state_set(action, status) rsrc.state_set(action, status)
self.assertEqual(None, self.stack.output('TestOutput')) self.assertIsNone(self.stack.output('TestOutput'))
@utils.stack_delete_after @utils.stack_delete_after
def test_resource_required_by(self): def test_resource_required_by(self):

View File

@ -57,11 +57,10 @@ class PluginLoaderTest(testtools.TestCase):
loaded = plugin_loader._import_module(importer, loaded = plugin_loader._import_module(importer,
'heat.engine.service', 'heat.engine.service',
heat.engine) heat.engine)
self.assertTrue(loaded is existing) self.assertIs(existing, loaded)
def test_import_module_garbage(self): def test_import_module_garbage(self):
importer = pkgutil.ImpImporter(heat.engine.__path__[0]) importer = pkgutil.ImpImporter(heat.engine.__path__[0])
self.assertEqual(plugin_loader._import_module(importer, self.assertIsNone(plugin_loader._import_module(importer,
'wibble', 'wibble',
heat.engine), heat.engine))
None)

View File

@ -141,8 +141,8 @@ class PropertySchemaTest(testtools.TestCase):
'Type': 'String', 'Type': 'String',
}) })
self.assertEqual(properties.Schema.STRING, s.type) self.assertEqual(properties.Schema.STRING, s.type)
self.assertEqual(None, s.description) self.assertIsNone(s.description)
self.assertEqual(None, s.default) self.assertIsNone(s.default)
self.assertFalse(s.required) self.assertFalse(s.required)
self.assertEqual(0, len(s.constraints)) self.assertEqual(0, len(s.constraints))
@ -173,7 +173,7 @@ class PropertySchemaTest(testtools.TestCase):
c = s.constraints[0] c = s.constraints[0]
self.assertIsInstance(c, constraints.Length) self.assertIsInstance(c, constraints.Length)
self.assertEqual(4, c.min) self.assertEqual(4, c.min)
self.assertEqual(None, c.max) self.assertIsNone(c.max)
def test_from_legacy_max_length(self): def test_from_legacy_max_length(self):
s = properties.Schema.from_legacy({ s = properties.Schema.from_legacy({
@ -183,7 +183,7 @@ class PropertySchemaTest(testtools.TestCase):
self.assertEqual(1, len(s.constraints)) self.assertEqual(1, len(s.constraints))
c = s.constraints[0] c = s.constraints[0]
self.assertIsInstance(c, constraints.Length) self.assertIsInstance(c, constraints.Length)
self.assertEqual(None, c.min) self.assertIsNone(c.min)
self.assertEqual(8, c.max) self.assertEqual(8, c.max)
def test_from_legacy_minmax_length(self): def test_from_legacy_minmax_length(self):
@ -219,7 +219,7 @@ class PropertySchemaTest(testtools.TestCase):
c = s.constraints[0] c = s.constraints[0]
self.assertIsInstance(c, constraints.Range) self.assertIsInstance(c, constraints.Range)
self.assertEqual(4, c.min) self.assertEqual(4, c.min)
self.assertEqual(None, c.max) self.assertIsNone(c.max)
def test_from_legacy_max_value(self): def test_from_legacy_max_value(self):
s = properties.Schema.from_legacy({ s = properties.Schema.from_legacy({
@ -229,7 +229,7 @@ class PropertySchemaTest(testtools.TestCase):
self.assertEqual(1, len(s.constraints)) self.assertEqual(1, len(s.constraints))
c = s.constraints[0] c = s.constraints[0]
self.assertIsInstance(c, constraints.Range) self.assertIsInstance(c, constraints.Range)
self.assertEqual(None, c.min) self.assertIsNone(c.min)
self.assertEqual(8, c.max) self.assertEqual(8, c.max)
def test_from_legacy_minmax_value(self): def test_from_legacy_minmax_value(self):
@ -332,7 +332,7 @@ class PropertySchemaTest(testtools.TestCase):
self.assertEqual(properties.Schema.STRING, schema.type) self.assertEqual(properties.Schema.STRING, schema.type)
self.assertEqual(description, schema.description) self.assertEqual(description, schema.description)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
self.assertEqual(1, len(schema.constraints)) self.assertEqual(1, len(schema.constraints))
@ -357,7 +357,7 @@ class PropertySchemaTest(testtools.TestCase):
self.assertEqual(properties.Schema.STRING, schema.type) self.assertEqual(properties.Schema.STRING, schema.type)
self.assertEqual(description, schema.description) self.assertEqual(description, schema.description)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
self.assertEqual(1, len(schema.constraints)) self.assertEqual(1, len(schema.constraints))
@ -383,7 +383,7 @@ class PropertySchemaTest(testtools.TestCase):
self.assertEqual(properties.Schema.STRING, schema.type) self.assertEqual(properties.Schema.STRING, schema.type)
self.assertEqual(description, schema.description) self.assertEqual(description, schema.description)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
self.assertEqual(2, len(schema.constraints)) self.assertEqual(2, len(schema.constraints))
@ -391,7 +391,7 @@ class PropertySchemaTest(testtools.TestCase):
allowed_constraint = schema.constraints[1] allowed_constraint = schema.constraints[1]
self.assertEqual(7, len_constraint.min) self.assertEqual(7, len_constraint.min)
self.assertEqual(None, len_constraint.max) self.assertIsNone(len_constraint.max)
self.assertEqual(allowed_pattern, allowed_constraint.pattern) self.assertEqual(allowed_pattern, allowed_constraint.pattern)
self.assertEqual(constraint_desc, allowed_constraint.description) self.assertEqual(constraint_desc, allowed_constraint.description)
@ -410,7 +410,7 @@ class PropertySchemaTest(testtools.TestCase):
len_constraint = schema.constraints[0] len_constraint = schema.constraints[0]
self.assertEqual(7, len_constraint.min) self.assertEqual(7, len_constraint.min)
self.assertEqual(None, len_constraint.max) self.assertIsNone(len_constraint.max)
def test_from_param_string_max_len(self): def test_from_param_string_max_len(self):
param = parameters.ParamSchema({ param = parameters.ParamSchema({
@ -426,7 +426,7 @@ class PropertySchemaTest(testtools.TestCase):
len_constraint = schema.constraints[0] len_constraint = schema.constraints[0]
self.assertEqual(None, len_constraint.min) self.assertIsNone(len_constraint.min)
self.assertEqual(11, len_constraint.max) self.assertEqual(11, len_constraint.max)
def test_from_param_string_min_max_len(self): def test_from_param_string_min_max_len(self):
@ -455,7 +455,7 @@ class PropertySchemaTest(testtools.TestCase):
schema = properties.Schema.from_parameter(param) schema = properties.Schema.from_parameter(param)
self.assertTrue(schema.required) self.assertTrue(schema.required)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertEqual(0, len(schema.constraints)) self.assertEqual(0, len(schema.constraints))
def test_from_number_param_min(self): def test_from_number_param_min(self):
@ -469,14 +469,14 @@ class PropertySchemaTest(testtools.TestCase):
schema = properties.Schema.from_parameter(param) schema = properties.Schema.from_parameter(param)
self.assertEqual(properties.Schema.NUMBER, schema.type) self.assertEqual(properties.Schema.NUMBER, schema.type)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
self.assertEqual(1, len(schema.constraints)) self.assertEqual(1, len(schema.constraints))
value_constraint = schema.constraints[0] value_constraint = schema.constraints[0]
self.assertEqual(10, value_constraint.min) self.assertEqual(10, value_constraint.min)
self.assertEqual(None, value_constraint.max) self.assertIsNone(value_constraint.max)
def test_from_number_param_max(self): def test_from_number_param_max(self):
default = "42" default = "42"
@ -489,13 +489,13 @@ class PropertySchemaTest(testtools.TestCase):
schema = properties.Schema.from_parameter(param) schema = properties.Schema.from_parameter(param)
self.assertEqual(properties.Schema.NUMBER, schema.type) self.assertEqual(properties.Schema.NUMBER, schema.type)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
self.assertEqual(1, len(schema.constraints)) self.assertEqual(1, len(schema.constraints))
value_constraint = schema.constraints[0] value_constraint = schema.constraints[0]
self.assertEqual(None, value_constraint.min) self.assertIsNone(value_constraint.min)
self.assertEqual(100, value_constraint.max) self.assertEqual(100, value_constraint.max)
def test_from_number_param_min_max(self): def test_from_number_param_min_max(self):
@ -510,7 +510,7 @@ class PropertySchemaTest(testtools.TestCase):
schema = properties.Schema.from_parameter(param) schema = properties.Schema.from_parameter(param)
self.assertEqual(properties.Schema.NUMBER, schema.type) self.assertEqual(properties.Schema.NUMBER, schema.type)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
self.assertEqual(1, len(schema.constraints)) self.assertEqual(1, len(schema.constraints))
@ -532,7 +532,7 @@ class PropertySchemaTest(testtools.TestCase):
schema = properties.Schema.from_parameter(param) schema = properties.Schema.from_parameter(param)
self.assertEqual(properties.Schema.NUMBER, schema.type) self.assertEqual(properties.Schema.NUMBER, schema.type)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
self.assertEqual(1, len(schema.constraints)) self.assertEqual(1, len(schema.constraints))
@ -550,7 +550,7 @@ class PropertySchemaTest(testtools.TestCase):
schema = properties.Schema.from_parameter(param) schema = properties.Schema.from_parameter(param)
self.assertEqual(properties.Schema.LIST, schema.type) self.assertEqual(properties.Schema.LIST, schema.type)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
def test_from_json_param(self): def test_from_json_param(self):
@ -562,7 +562,7 @@ class PropertySchemaTest(testtools.TestCase):
schema = properties.Schema.from_parameter(param) schema = properties.Schema.from_parameter(param)
self.assertEqual(properties.Schema.MAP, schema.type) self.assertEqual(properties.Schema.MAP, schema.type)
self.assertEqual(None, schema.default) self.assertIsNone(schema.default)
self.assertFalse(schema.required) self.assertFalse(schema.required)
@ -763,15 +763,15 @@ class PropertyTest(testtools.TestCase):
def test_boolean_true(self): def test_boolean_true(self):
p = properties.Property({'Type': 'Boolean'}) p = properties.Property({'Type': 'Boolean'})
self.assertEqual(p.validate_data('True'), True) self.assertIs(True, p.validate_data('True'))
self.assertEqual(p.validate_data('true'), True) self.assertIs(True, p.validate_data('true'))
self.assertEqual(p.validate_data(True), True) self.assertIs(True, p.validate_data(True))
def test_boolean_false(self): def test_boolean_false(self):
p = properties.Property({'Type': 'Boolean'}) p = properties.Property({'Type': 'Boolean'})
self.assertEqual(p.validate_data('False'), False) self.assertIs(False, p.validate_data('False'))
self.assertEqual(p.validate_data('false'), False) self.assertIs(False, p.validate_data('false'))
self.assertEqual(p.validate_data(False), False) self.assertIs(False, p.validate_data(False))
def test_boolean_invalid(self): def test_boolean_invalid(self):
p = properties.Property({'Type': 'Boolean'}) p = properties.Property({'Type': 'Boolean'})
@ -908,7 +908,7 @@ class PropertiesTest(testtools.TestCase):
self.assertRaises(ValueError, self.props.get, 'bad_int') self.assertRaises(ValueError, self.props.get, 'bad_int')
def test_missing(self): def test_missing(self):
self.assertEqual(self.props['missing'], None) self.assertIsNone(self.props['missing'])
def test_default(self): def test_default(self):
self.assertEqual(self.props['defaulted'], 1) self.assertEqual(self.props['defaulted'], 1)
@ -937,7 +937,7 @@ class PropertiesTest(testtools.TestCase):
def test_none_boolean(self): def test_none_boolean(self):
schema = {'foo': {'Type': 'Boolean'}} schema = {'foo': {'Type': 'Boolean'}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(False, props['foo']) self.assertIs(False, props['foo'])
def test_none_map(self): def test_none_map(self):
schema = {'foo': {'Type': 'Map'}} schema = {'foo': {'Type': 'Map'}}
@ -983,7 +983,7 @@ class PropertiesTest(testtools.TestCase):
def test_none_default_boolean(self): def test_none_default_boolean(self):
schema = {'foo': {'Type': 'Boolean', 'Default': True}} schema = {'foo': {'Type': 'Boolean', 'Default': True}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(True, props['foo']) self.assertIs(True, props['foo'])
def test_none_default_map(self): def test_none_default_map(self):
schema = {'foo': {'Type': 'Map', 'Default': {'bar': 'baz'}}} schema = {'foo': {'Type': 'Map', 'Default': {'bar': 'baz'}}}
@ -1360,7 +1360,7 @@ class PropertiesValidationTest(testtools.TestCase):
def test_required(self): def test_required(self):
schema = {'foo': {'Type': 'String', 'Required': True}} schema = {'foo': {'Type': 'String', 'Required': True}}
props = properties.Properties(schema, {'foo': 'bar'}) props = properties.Properties(schema, {'foo': 'bar'})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_missing_required(self): def test_missing_required(self):
schema = {'foo': {'Type': 'String', 'Required': True}} schema = {'foo': {'Type': 'String', 'Required': True}}
@ -1370,7 +1370,7 @@ class PropertiesValidationTest(testtools.TestCase):
def test_missing_unimplemented(self): def test_missing_unimplemented(self):
schema = {'foo': {'Type': 'String', 'Implemented': False}} schema = {'foo': {'Type': 'String', 'Implemented': False}}
props = properties.Properties(schema, {}) props = properties.Properties(schema, {})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_present_unimplemented(self): def test_present_unimplemented(self):
schema = {'foo': {'Type': 'String', 'Implemented': False}} schema = {'foo': {'Type': 'String', 'Implemented': False}}
@ -1380,7 +1380,7 @@ class PropertiesValidationTest(testtools.TestCase):
def test_missing(self): def test_missing(self):
schema = {'foo': {'Type': 'String'}} schema = {'foo': {'Type': 'String'}}
props = properties.Properties(schema, {}) props = properties.Properties(schema, {})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_bad_data(self): def test_bad_data(self):
schema = {'foo': {'Type': 'String'}} schema = {'foo': {'Type': 'String'}}
@ -1395,62 +1395,62 @@ class PropertiesValidationTest(testtools.TestCase):
def test_none_string(self): def test_none_string(self):
schema = {'foo': {'Type': 'String'}} schema = {'foo': {'Type': 'String'}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_integer(self): def test_none_integer(self):
schema = {'foo': {'Type': 'Integer'}} schema = {'foo': {'Type': 'Integer'}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_number(self): def test_none_number(self):
schema = {'foo': {'Type': 'Number'}} schema = {'foo': {'Type': 'Number'}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_boolean(self): def test_none_boolean(self):
schema = {'foo': {'Type': 'Boolean'}} schema = {'foo': {'Type': 'Boolean'}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_map(self): def test_none_map(self):
schema = {'foo': {'Type': 'Map'}} schema = {'foo': {'Type': 'Map'}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_list(self): def test_none_list(self):
schema = {'foo': {'Type': 'List'}} schema = {'foo': {'Type': 'List'}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_default_string(self): def test_none_default_string(self):
schema = {'foo': {'Type': 'String', 'Default': 'bar'}} schema = {'foo': {'Type': 'String', 'Default': 'bar'}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_default_integer(self): def test_none_default_integer(self):
schema = {'foo': {'Type': 'Integer', 'Default': 42}} schema = {'foo': {'Type': 'Integer', 'Default': 42}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_default_number(self): def test_none_default_number(self):
schema = {'foo': {'Type': 'Number', 'Default': 42.0}} schema = {'foo': {'Type': 'Number', 'Default': 42.0}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_default_boolean(self): def test_none_default_boolean(self):
schema = {'foo': {'Type': 'Boolean', 'Default': True}} schema = {'foo': {'Type': 'Boolean', 'Default': True}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_default_map(self): def test_none_default_map(self):
schema = {'foo': {'Type': 'Map', 'Default': {'bar': 'baz'}}} schema = {'foo': {'Type': 'Map', 'Default': {'bar': 'baz'}}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_none_default_list(self): def test_none_default_list(self):
schema = {'foo': {'Type': 'List', 'Default': ['one', 'two']}} schema = {'foo': {'Type': 'List', 'Default': ['one', 'two']}}
props = properties.Properties(schema, {'foo': None}) props = properties.Properties(schema, {'foo': None})
self.assertEqual(props.validate(), None) self.assertIsNone(props.validate())
def test_schema_to_template_nested_map_map_schema(self): def test_schema_to_template_nested_map_map_schema(self):
nested_schema = {'Key': {'Type': 'String', nested_schema = {'Key': {'Type': 'String',

View File

@ -188,7 +188,7 @@ class ProviderTemplateTest(HeatTestCase):
temp_res = template_resource.TemplateResource('test_t_res', temp_res = template_resource.TemplateResource('test_t_res',
json_snippet, stack) json_snippet, stack)
self.assertEqual(None, temp_res.validate()) self.assertIsNone(temp_res.validate())
def test_attributes_missing(self): def test_attributes_missing(self):
provider = { provider = {
@ -251,7 +251,7 @@ class ProviderTemplateTest(HeatTestCase):
temp_res = template_resource.TemplateResource('test_t_res', temp_res = template_resource.TemplateResource('test_t_res',
json_snippet, stack) json_snippet, stack)
self.assertEqual(None, temp_res.validate()) self.assertIsNone(temp_res.validate())
def test_properties_missing(self): def test_properties_missing(self):
provider = { provider = {
@ -427,7 +427,7 @@ class ProviderTemplateTest(HeatTestCase):
temp_res = template_resource.TemplateResource('test_t_res', temp_res = template_resource.TemplateResource('test_t_res',
{"Type": 'Test::Frodo'}, {"Type": 'Test::Frodo'},
stack) stack)
self.assertEqual(None, temp_res.validate()) self.assertIsNone(temp_res.validate())
self.m.VerifyAll() self.m.VerifyAll()
def test_user_template_not_retrieved_by_file(self): def test_user_template_not_retrieved_by_file(self):

View File

@ -51,7 +51,7 @@ Resources:
def create_stack(self, template): def create_stack(self, template):
t = template_format.parse(template) t = template_format.parse(template)
self.stack = self.parse_stack(t) self.stack = self.parse_stack(t)
self.assertEqual(None, self.stack.create()) self.assertIsNone(self.stack.create())
return self.stack return self.stack
def parse_stack(self, t): def parse_stack(self, t):

View File

@ -188,9 +188,9 @@ class ResourceTest(HeatTestCase):
def test_created_time(self): def test_created_time(self):
tmpl = {'Type': 'Foo'} tmpl = {'Type': 'Foo'}
res = generic_rsrc.GenericResource('test_res_new', tmpl, self.stack) res = generic_rsrc.GenericResource('test_res_new', tmpl, self.stack)
self.assertEqual(res.created_time, None) self.assertIsNone(res.created_time)
res._store() res._store()
self.assertNotEqual(res.created_time, None) self.assertIsNotNone(res.created_time)
def test_updated_time(self): def test_updated_time(self):
tmpl = {'Type': 'Foo'} tmpl = {'Type': 'Foo'}
@ -198,17 +198,17 @@ class ResourceTest(HeatTestCase):
res._store() res._store()
stored_time = res.updated_time stored_time = res.updated_time
res.state_set(res.CREATE, res.IN_PROGRESS, 'testing') res.state_set(res.CREATE, res.IN_PROGRESS, 'testing')
self.assertNotEqual(res.updated_time, None) self.assertIsNotNone(res.updated_time)
self.assertNotEqual(res.updated_time, stored_time) self.assertNotEqual(res.updated_time, stored_time)
def test_store_or_update(self): def test_store_or_update(self):
tmpl = {'Type': 'Foo'} tmpl = {'Type': 'Foo'}
res = generic_rsrc.GenericResource('test_res_upd', tmpl, self.stack) res = generic_rsrc.GenericResource('test_res_upd', tmpl, self.stack)
res._store_or_update(res.CREATE, res.IN_PROGRESS, 'test_store') res._store_or_update(res.CREATE, res.IN_PROGRESS, 'test_store')
self.assertNotEqual(None, res.id) self.assertIsNotNone(res.id)
self.assertEqual(res.action, res.CREATE) self.assertEqual(res.CREATE, res.action)
self.assertEqual(res.status, res.IN_PROGRESS) self.assertEqual(res.IN_PROGRESS, res.status)
self.assertEqual(res.status_reason, 'test_store') self.assertEqual('test_store', res.status_reason)
db_res = db_api.resource_get(res.context, res.id) db_res = db_api.resource_get(res.context, res.id)
self.assertEqual(db_res.action, res.CREATE) self.assertEqual(db_res.action, res.CREATE)
@ -1198,4 +1198,4 @@ class SupportStatusTest(HeatTestCase):
self.assertEqual('UNKNOWN', status.status) self.assertEqual('UNKNOWN', status.status)
self.assertEqual('Specified status is invalid, defaulting to UNKNOWN', self.assertEqual('Specified status is invalid, defaulting to UNKNOWN',
status.message) status.message)
self.assertEqual(None, status.version) self.assertIsNone(status.version)

View File

@ -71,7 +71,7 @@ class RestarterTest(common.HeatTestCase):
rsrc.stack.restart_resource = mock.Mock(return_value=None) rsrc.stack.restart_resource = mock.Mock(return_value=None)
self.assertEqual(None, rsrc.handle_signal()) self.assertIsNone(rsrc.handle_signal())
rsrc.stack.restart_resource.assert_called_once_with('instance') rsrc.stack.restart_resource.assert_called_once_with('instance')
def test_handle_signal_alarm(self): def test_handle_signal_alarm(self):
@ -82,7 +82,7 @@ class RestarterTest(common.HeatTestCase):
rsrc.stack.restart_resource = mock.Mock(return_value=None) rsrc.stack.restart_resource = mock.Mock(return_value=None)
self.assertEqual(None, rsrc.handle_signal({'state': 'Alarm'})) self.assertIsNone(rsrc.handle_signal({'state': 'Alarm'}))
rsrc.stack.restart_resource.assert_called_once_with('instance') rsrc.stack.restart_resource.assert_called_once_with('instance')
def test_handle_signal_not_alarm(self): def test_handle_signal_not_alarm(self):
@ -93,7 +93,7 @@ class RestarterTest(common.HeatTestCase):
rsrc.stack.restart_resource = mock.Mock(return_value=None) rsrc.stack.restart_resource = mock.Mock(return_value=None)
self.assertEqual(None, rsrc.handle_signal({'state': 'spam'})) self.assertIsNone(rsrc.handle_signal({'state': 'spam'}))
self.assertEqual([], rsrc.stack.restart_resource.mock_calls) self.assertEqual([], rsrc.stack.restart_resource.mock_calls)
def test_handle_signal_no_instance(self): def test_handle_signal_no_instance(self):
@ -102,5 +102,5 @@ class RestarterTest(common.HeatTestCase):
rsrc.stack.restart_resource = mock.Mock(return_value=None) rsrc.stack.restart_resource = mock.Mock(return_value=None)
self.assertEqual(None, rsrc.handle_signal()) self.assertIsNone(rsrc.handle_signal())
self.assertEqual([], rsrc.stack.restart_resource.mock_calls) self.assertEqual([], rsrc.stack.restart_resource.mock_calls)

View File

@ -127,7 +127,7 @@ Resources:
def create_stack(self, template): def create_stack(self, template):
t = template_format.parse(template) t = template_format.parse(template)
self.stack = self.parse_stack(t) self.stack = self.parse_stack(t)
self.assertEqual(None, self.stack.create()) self.assertIsNone(self.stack.create())
return self.stack return self.stack
def parse_stack(self, t): def parse_stack(self, t):
@ -138,7 +138,7 @@ Resources:
return stack return stack
def assertResourceState(self, rsrc, ref_id, metadata={}): def assertResourceState(self, rsrc, ref_id, metadata={}):
self.assertEqual(None, rsrc.validate()) self.assertIsNone(rsrc.validate())
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state) self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
self.assertEqual(ref_id, rsrc.FnGetRefId()) self.assertEqual(ref_id, rsrc.FnGetRefId())
self.assertEqual(metadata, dict(rsrc.metadata)) self.assertEqual(metadata, dict(rsrc.metadata))

View File

@ -342,7 +342,7 @@ class ServersTest(HeatTestCase):
uuidutils.is_uuid_like('1').AndReturn(True) uuidutils.is_uuid_like('1').AndReturn(True)
self.m.ReplayAll() self.m.ReplayAll()
self.assertEqual(server.validate(), None) self.assertIsNone(server.validate())
self.m.VerifyAll() self.m.VerifyAll()
@ -368,9 +368,9 @@ class ServersTest(HeatTestCase):
return server return server
server = create_server(u'vda') server = create_server(u'vda')
self.assertEqual(server.validate(), None) self.assertIsNone(server.validate())
server = create_server('vda') server = create_server('vda')
self.assertEqual(server.validate(), None) self.assertIsNone(server.validate())
server = create_server('vdb') server = create_server('vdb')
ex = self.assertRaises(exception.StackValidationFailed, ex = self.assertRaises(exception.StackValidationFailed,
server.validate) server.validate)
@ -441,7 +441,7 @@ class ServersTest(HeatTestCase):
self.m.ReplayAll() self.m.ReplayAll()
scheduler.TaskRunner(server.delete)() scheduler.TaskRunner(server.delete)()
self.assertTrue(server.resource_id is None) self.assertIsNone(server.resource_id)
self.assertEqual(server.state, (server.DELETE, server.COMPLETE)) self.assertEqual(server.state, (server.DELETE, server.COMPLETE))
self.m.VerifyAll() self.m.VerifyAll()
@ -460,7 +460,7 @@ class ServersTest(HeatTestCase):
mox.Replay(get) mox.Replay(get)
scheduler.TaskRunner(server.delete)() scheduler.TaskRunner(server.delete)()
self.assertTrue(server.resource_id is None) self.assertIsNone(server.resource_id)
self.assertEqual(server.state, (server.DELETE, server.COMPLETE)) self.assertEqual(server.state, (server.DELETE, server.COMPLETE))
self.m.VerifyAll() self.m.VerifyAll()
@ -1035,8 +1035,8 @@ class ServersTest(HeatTestCase):
return_server = self.fc.servers.list()[1] return_server = self.fc.servers.list()[1]
server = self._create_test_server(return_server, server = self._create_test_server(return_server,
'test_server_create') 'test_server_create')
self.assertEqual(None, server._build_nics([])) self.assertIsNone(server._build_nics([]))
self.assertEqual(None, server._build_nics(None)) self.assertIsNone(server._build_nics(None))
self.assertEqual([{'port-id': 'aaaabbbb'}, self.assertEqual([{'port-id': 'aaaabbbb'},
{'v4-fixed-ip': '192.0.2.0'}], {'v4-fixed-ip': '192.0.2.0'}],
server._build_nics([{'port': 'aaaabbbb'}, server._build_nics([{'port': 'aaaabbbb'},
@ -1070,10 +1070,8 @@ class ServersTest(HeatTestCase):
self.assertEqual(server.FnGetAtt('first_address'), '') self.assertEqual(server.FnGetAtt('first_address'), '')
def test_build_block_device_mapping(self): def test_build_block_device_mapping(self):
self.assertEqual( self.assertIsNone(servers.Server._build_block_device_mapping([]))
None, servers.Server._build_block_device_mapping([])) self.assertIsNone(servers.Server._build_block_device_mapping(None))
self.assertEqual(
None, servers.Server._build_block_device_mapping(None))
self.assertEqual({ self.assertEqual({
'vda': '1234:', 'vda': '1234:',

View File

@ -217,7 +217,7 @@ class ServerTagsTest(HeatTestCase):
# create the launch configuration # create the launch configuration
conf = stack['Config'] conf = stack['Config']
self.assertEqual(None, conf.validate()) self.assertIsNone(conf.validate())
scheduler.TaskRunner(conf.create)() scheduler.TaskRunner(conf.create)()
self.assertEqual((conf.CREATE, conf.COMPLETE), conf.state) self.assertEqual((conf.CREATE, conf.COMPLETE), conf.state)
@ -264,7 +264,7 @@ class ServerTagsTest(HeatTestCase):
# create the launch configuration # create the launch configuration
conf = stack['Config'] conf = stack['Config']
self.assertEqual(None, conf.validate()) self.assertIsNone(conf.validate())
scheduler.TaskRunner(conf.create)() scheduler.TaskRunner(conf.create)()
self.assertEqual((conf.CREATE, conf.COMPLETE), conf.state) self.assertEqual((conf.CREATE, conf.COMPLETE), conf.state)
group = stack['WebServer'] group = stack['WebServer']

View File

@ -789,7 +789,7 @@ class DBAPIStackTest(HeatTestCase):
self.assertEqual(self.user_creds.id, stack.user_creds_id) self.assertEqual(self.user_creds.id, stack.user_creds_id)
self.assertIsNone(stack.owner_id) self.assertIsNone(stack.owner_id)
self.assertEqual('60', stack.timeout) self.assertEqual('60', stack.timeout)
self.assertEqual(False, stack.disable_rollback) self.assertFalse(stack.disable_rollback)
def test_stack_delete(self): def test_stack_delete(self):
stack = create_stack(self.ctx, self.template, self.user_creds) stack = create_stack(self.ctx, self.template, self.user_creds)

View File

@ -186,8 +186,8 @@ class StackResourceTest(HeatTestCase):
updater = self.parent_resource.update_with_template( updater = self.parent_resource.update_with_template(
new_templ, {}) new_templ, {})
updater.run_to_completion() updater.run_to_completion()
self.assertEqual(True, self.assertIs(True,
self.parent_resource.check_update_complete(updater)) self.parent_resource.check_update_complete(updater))
self.assertEqual(self.stack.state, ('UPDATE', 'COMPLETE')) self.assertEqual(self.stack.state, ('UPDATE', 'COMPLETE'))
self.assertEqual(set(self.stack.keys()), self.assertEqual(set(self.stack.keys()),
set(["WebServer", "WebServer2"])) set(["WebServer", "WebServer2"]))

View File

@ -102,7 +102,7 @@ class UserTest(UserPolicyTestCase):
rsrc = user.User(resource_name, rsrc = user.User(resource_name,
t['Resources'][resource_name], t['Resources'][resource_name],
stack) stack)
self.assertEqual(None, rsrc.validate()) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state) self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
return rsrc return rsrc
@ -126,8 +126,8 @@ class UserTest(UserPolicyTestCase):
self.assertRaises(resource.UpdateReplace, self.assertRaises(resource.UpdateReplace,
rsrc.handle_update, {}, {}, {}) rsrc.handle_update, {}, {}, {})
self.assertEqual(None, rsrc.handle_suspend()) self.assertIsNone(rsrc.handle_suspend())
self.assertEqual(None, rsrc.handle_resume()) self.assertIsNone(rsrc.handle_resume())
rsrc.resource_id = None rsrc.resource_id = None
scheduler.TaskRunner(rsrc.delete)() scheduler.TaskRunner(rsrc.delete)()
@ -261,14 +261,14 @@ class AccessKeyTest(UserPolicyTestCase):
rsrc = user.AccessKey(resource_name, rsrc = user.AccessKey(resource_name,
t['Resources'][resource_name], t['Resources'][resource_name],
stack) stack)
self.assertEqual(None, rsrc.validate()) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state) self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
return rsrc return rsrc
def create_user(self, t, stack, resource_name): def create_user(self, t, stack, resource_name):
rsrc = stack[resource_name] rsrc = stack[resource_name]
self.assertEqual(None, rsrc.validate()) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state) self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
return rsrc return rsrc

View File

@ -552,7 +552,7 @@ class validateTest(HeatTestCase):
stack = parser.Stack(self.ctx, 'test_stack', parser.Template(t)) stack = parser.Stack(self.ctx, 'test_stack', parser.Template(t))
volumeattach = stack['MountPoint'] volumeattach = stack['MountPoint']
self.assertTrue(volumeattach.validate() is None) self.assertIsNone(volumeattach.validate())
def test_validate_volumeattach_invalid(self): def test_validate_volumeattach_invalid(self):
t = template_format.parse(test_template_volumeattach % 'sda') t = template_format.parse(test_template_volumeattach % 'sda')

View File

@ -93,7 +93,7 @@ class VolumeTest(HeatTestCase):
data = t['Resources'][resource_name] data = t['Resources'][resource_name]
data['Properties']['AvailabilityZone'] = 'nova' data['Properties']['AvailabilityZone'] = 'nova'
rsrc = vol.Volume(resource_name, data, stack) rsrc = vol.Volume(resource_name, data, stack)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE)) self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))
return rsrc return rsrc
@ -102,7 +102,7 @@ class VolumeTest(HeatTestCase):
rsrc = vol.VolumeAttachment(resource_name, rsrc = vol.VolumeAttachment(resource_name,
t['Resources'][resource_name], t['Resources'][resource_name],
stack) stack)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE)) self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))
return rsrc return rsrc
@ -204,7 +204,7 @@ class VolumeTest(HeatTestCase):
stack = utils.parse_stack(t, stack_name=stack_name) stack = utils.parse_stack(t, stack_name=stack_name)
rsrc = stack['DataVolume'] rsrc = stack['DataVolume']
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(stack.create)() scheduler.TaskRunner(stack.create)()
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE)) self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))
@ -637,7 +637,7 @@ class VolumeTest(HeatTestCase):
rsrc = vol.CinderVolume('DataVolume', rsrc = vol.CinderVolume('DataVolume',
t['Resources']['DataVolume'], t['Resources']['DataVolume'],
stack) stack)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE)) self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))
self.assertEqual(fv.status, 'available') self.assertEqual(fv.status, 'available')
@ -675,7 +675,7 @@ class VolumeTest(HeatTestCase):
rsrc = vol.CinderVolume('DataVolume', rsrc = vol.CinderVolume('DataVolume',
t['Resources']['DataVolume'], t['Resources']['DataVolume'],
stack) stack)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE)) self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))
self.assertEqual(fv.status, 'available') self.assertEqual(fv.status, 'available')
@ -706,7 +706,7 @@ class VolumeTest(HeatTestCase):
rsrc = vol.CinderVolume('DataVolume', rsrc = vol.CinderVolume('DataVolume',
t['Resources']['DataVolume'], t['Resources']['DataVolume'],
stack) stack)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE)) self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))
self.assertEqual(fv.status, 'available') self.assertEqual(fv.status, 'available')
@ -797,7 +797,7 @@ class VolumeTest(HeatTestCase):
rsrc = vol.CinderVolumeAttachment('MountPoint', rsrc = vol.CinderVolumeAttachment('MountPoint',
t['Resources']['MountPoint'], t['Resources']['MountPoint'],
stack) stack)
self.assertEqual(rsrc.validate(), None) self.assertIsNone(rsrc.validate())
scheduler.TaskRunner(rsrc.create)() scheduler.TaskRunner(rsrc.create)()
self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE)) self.assertEqual(rsrc.state, (rsrc.CREATE, rsrc.COMPLETE))

View File

@ -68,7 +68,7 @@ class VPCTestBase(HeatTestCase):
def create_stack(self, template): def create_stack(self, template):
t = template_format.parse(template) t = template_format.parse(template)
stack = self.parse_stack(t) stack = self.parse_stack(t)
self.assertEqual(None, stack.create()) self.assertIsNone(stack.create())
return stack return stack
def parse_stack(self, t): def parse_stack(self, t):
@ -341,7 +341,7 @@ class VPCTestBase(HeatTestCase):
neutronclient.Client.remove_gateway_router('ffff').AndReturn(None) neutronclient.Client.remove_gateway_router('ffff').AndReturn(None)
def assertResourceState(self, resource, ref_id): def assertResourceState(self, resource, ref_id):
self.assertEqual(None, resource.validate()) self.assertIsNone(resource.validate())
self.assertEqual((resource.CREATE, resource.COMPLETE), resource.state) self.assertEqual((resource.CREATE, resource.COMPLETE), resource.state)
self.assertEqual(ref_id, resource.FnGetRefId()) self.assertEqual(ref_id, resource.FnGetRefId())

View File

@ -325,7 +325,7 @@ class WatchRuleTest(HeatTestCase):
self.wr.store() self.wr.store()
dbwr = db_api.watch_rule_get_by_name(self.ctx, 'storetest') dbwr = db_api.watch_rule_get_by_name(self.ctx, 'storetest')
self.assertNotEqual(dbwr, None) self.assertIsNotNone(dbwr)
self.assertEqual(dbwr.name, 'storetest') self.assertEqual(dbwr.name, 'storetest')
self.assertEqual(dbwr.state, watchrule.WatchRule.NODATA) self.assertEqual(dbwr.state, watchrule.WatchRule.NODATA)
self.assertEqual(dbwr.rule, rule) self.assertEqual(dbwr.rule, rule)

View File

@ -94,13 +94,13 @@ class RequestTest(HeatTestCase):
self.stubs.SmartSet(request.accept_language, self.stubs.SmartSet(request.accept_language,
'best_match', fake_best_match) 'best_match', fake_best_match)
self.assertEqual(request.best_match_language(), None) self.assertIsNone(request.best_match_language())
# If Accept-Language is missing or empty, match should be None # If Accept-Language is missing or empty, match should be None
request.headers = {'Accept-Language': ''} request.headers = {'Accept-Language': ''}
self.assertEqual(request.best_match_language(), None) self.assertIsNone(request.best_match_language())
request.headers.pop('Accept-Language') request.headers.pop('Accept-Language')
self.assertEqual(request.best_match_language(), None) self.assertIsNone(request.best_match_language())
class ResourceTest(HeatTestCase): class ResourceTest(HeatTestCase):