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

View File

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

View File

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

View File

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

View File

@ -243,7 +243,7 @@ class RackspaceCloudServerTest(HeatTestCase):
cs = cloud_server.CloudServer('cs_create_image_err',
t['Resources']['WebServer'], stack)
self.assertEqual(None, cs.validate())
self.assertIsNone(cs.validate())
self.m.VerifyAll()
def test_cs_create_heatscript_nonzero_exit_status(self):
@ -316,7 +316,7 @@ class RackspaceCloudServerTest(HeatTestCase):
mox.Replay(get)
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.m.VerifyAll()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -188,9 +188,9 @@ class ResourceTest(HeatTestCase):
def test_created_time(self):
tmpl = {'Type': 'Foo'}
res = generic_rsrc.GenericResource('test_res_new', tmpl, self.stack)
self.assertEqual(res.created_time, None)
self.assertIsNone(res.created_time)
res._store()
self.assertNotEqual(res.created_time, None)
self.assertIsNotNone(res.created_time)
def test_updated_time(self):
tmpl = {'Type': 'Foo'}
@ -198,17 +198,17 @@ class ResourceTest(HeatTestCase):
res._store()
stored_time = res.updated_time
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)
def test_store_or_update(self):
tmpl = {'Type': 'Foo'}
res = generic_rsrc.GenericResource('test_res_upd', tmpl, self.stack)
res._store_or_update(res.CREATE, res.IN_PROGRESS, 'test_store')
self.assertNotEqual(None, res.id)
self.assertEqual(res.action, res.CREATE)
self.assertEqual(res.status, res.IN_PROGRESS)
self.assertEqual(res.status_reason, 'test_store')
self.assertIsNotNone(res.id)
self.assertEqual(res.CREATE, res.action)
self.assertEqual(res.IN_PROGRESS, res.status)
self.assertEqual('test_store', res.status_reason)
db_res = db_api.resource_get(res.context, res.id)
self.assertEqual(db_res.action, res.CREATE)
@ -1198,4 +1198,4 @@ class SupportStatusTest(HeatTestCase):
self.assertEqual('UNKNOWN', status.status)
self.assertEqual('Specified status is invalid, defaulting to UNKNOWN',
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)
self.assertEqual(None, rsrc.handle_signal())
self.assertIsNone(rsrc.handle_signal())
rsrc.stack.restart_resource.assert_called_once_with('instance')
def test_handle_signal_alarm(self):
@ -82,7 +82,7 @@ class RestarterTest(common.HeatTestCase):
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')
def test_handle_signal_not_alarm(self):
@ -93,7 +93,7 @@ class RestarterTest(common.HeatTestCase):
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)
def test_handle_signal_no_instance(self):
@ -102,5 +102,5 @@ class RestarterTest(common.HeatTestCase):
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)

View File

@ -127,7 +127,7 @@ Resources:
def create_stack(self, template):
t = template_format.parse(template)
self.stack = self.parse_stack(t)
self.assertEqual(None, self.stack.create())
self.assertIsNone(self.stack.create())
return self.stack
def parse_stack(self, t):
@ -138,7 +138,7 @@ Resources:
return stack
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(ref_id, rsrc.FnGetRefId())
self.assertEqual(metadata, dict(rsrc.metadata))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ class VPCTestBase(HeatTestCase):
def create_stack(self, template):
t = template_format.parse(template)
stack = self.parse_stack(t)
self.assertEqual(None, stack.create())
self.assertIsNone(stack.create())
return stack
def parse_stack(self, t):
@ -341,7 +341,7 @@ class VPCTestBase(HeatTestCase):
neutronclient.Client.remove_gateway_router('ffff').AndReturn(None)
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(ref_id, resource.FnGetRefId())

View File

@ -325,7 +325,7 @@ class WatchRuleTest(HeatTestCase):
self.wr.store()
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.state, watchrule.WatchRule.NODATA)
self.assertEqual(dbwr.rule, rule)

View File

@ -94,13 +94,13 @@ class RequestTest(HeatTestCase):
self.stubs.SmartSet(request.accept_language,
'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
request.headers = {'Accept-Language': ''}
self.assertEqual(request.best_match_language(), None)
self.assertIsNone(request.best_match_language())
request.headers.pop('Accept-Language')
self.assertEqual(request.best_match_language(), None)
self.assertIsNone(request.best_match_language())
class ResourceTest(HeatTestCase):