Fix comparison with singletons

Many plases in tests code use assertEqual(AA, None),
the same with True and False and negatives of such comparisons.

As comparison to singletons must use `is` operator, appropriate usage
is assertIs, assertIsNot, assertIsNone, assertIsNotNone

These assertions are provided by the `testtools` package,
so this change is not breaking backward compatibility with Python 2.6

This first patch inlcudes roughly half of the files touched by these changes
(up to and including test_n* sans `contrib` code) to ease the review.

Partial-Bug: #1259023

Change-Id: If6779c9230cf73ab93165a00040d1ca32d087c80
changes/47/61447/5
Pavlo Shchelokovskyy 9 years ago
parent 494f3eaaaf
commit b7f3c62f65
  1. 2
      heat/tests/test_api_cfn_v1.py
  2. 2
      heat/tests/test_api_cloudwatch.py
  3. 4
      heat/tests/test_api_openstack_v1.py
  4. 2
      heat/tests/test_attributes.py
  5. 16
      heat/tests/test_autoscaling.py
  6. 10
      heat/tests/test_cloudwatch.py
  7. 2
      heat/tests/test_cw_alarm.py
  8. 2
      heat/tests/test_dbinstance.py
  9. 8
      heat/tests/test_eip.py
  10. 33
      heat/tests/test_engine_service.py
  11. 11
      heat/tests/test_environment.py
  12. 8
      heat/tests/test_event.py
  13. 8
      heat/tests/test_instance.py
  14. 6
      heat/tests/test_instance_group.py
  15. 6
      heat/tests/test_loadbalancer.py
  16. 2
      heat/tests/test_loguserdata.py
  17. 2
      heat/tests/test_metadata_refresh.py
  18. 4
      heat/tests/test_nested_stack.py
  19. 32
      heat/tests/test_neutron.py
  20. 8
      heat/tests/test_neutron_firewall.py
  21. 6
      heat/tests/test_neutron_loadbalancer.py
  22. 4
      heat/tests/test_neutron_security_group.py
  23. 4
      heat/tests/test_neutron_vpnservice.py

@ -100,7 +100,7 @@ class CfnStackControllerTest(HeatTestCase):
dummy_req = self._dummy_GET_request(params)
self._stub_enforce(dummy_req, 'ListStacks')
response = self.controller._enforce(dummy_req, 'ListStacks')
self.assertEqual(response, None)
self.assertIsNone(response)
def test_enforce_denied(self):
self.m.ReplayAll()

@ -57,7 +57,7 @@ class WatchControllerTest(HeatTestCase):
dummy_req = self._dummy_GET_request(params)
self.controller.policy.policy_path = None
response = self.controller._enforce(dummy_req, 'ListMetrics')
self.assertEqual(response, None)
self.assertIsNone(response)
self.m.VerifyAll()
def test_enforce_denied(self):

@ -2559,7 +2559,7 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
stack_name=stack_identity.stack_name,
stack_id=stack_identity.stack_id,
body=body)
self.assertEqual(result, None)
self.assertIsNone(result)
self.m.VerifyAll()
def test_action_resume(self):
@ -2583,7 +2583,7 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
stack_name=stack_identity.stack_name,
stack_id=stack_identity.stack_id,
body=body)
self.assertEqual(result, None)
self.assertIsNone(result)
self.m.VerifyAll()
def test_action_badaction(self):

@ -58,7 +58,7 @@ class AttributesTest(common.HeatTestCase):
attribs = attributes.Attributes('test resource',
self.attributes_schema,
test_resolver)
self.assertEqual(None, attribs['test1'])
self.assertIsNone(attribs['test1'])
def test_get_attribute_nonexist(self):
"""Test that we get the attribute values we expect."""

@ -136,20 +136,20 @@ class AutoScalingTest(HeatTestCase):
def create_scaling_group(self, t, stack, resource_name):
# create the launch configuration resource
conf = stack['LaunchConfig']
self.assertEqual(None, conf.validate())
self.assertIsNone(conf.validate())
scheduler.TaskRunner(conf.create)()
self.assertEqual((conf.CREATE, conf.COMPLETE), conf.state)
# create the group resource
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
def create_scaling_policy(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
@ -211,7 +211,7 @@ class AutoScalingTest(HeatTestCase):
self._stub_lb_reload(0)
self.m.ReplayAll()
rsrc = self.create_scaling_group(t, stack, 'WebServerGroup')
self.assertEqual(None, rsrc.FnGetAtt("InstanceList"))
self.assertIsNone(rsrc.FnGetAtt("InstanceList"))
rsrc.delete()
self.m.VerifyAll()
@ -498,12 +498,12 @@ class AutoScalingTest(HeatTestCase):
self.m.ReplayAll()
conf = stack['LaunchConfig']
self.assertEqual(None, conf.validate())
self.assertIsNone(conf.validate())
scheduler.TaskRunner(conf.create)()
self.assertEqual((conf.CREATE, conf.COMPLETE), conf.state)
rsrc = stack['WebServerGroup']
self.assertEqual(None, rsrc.validate())
self.assertIsNone(rsrc.validate())
self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(rsrc.create))
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
@ -619,7 +619,7 @@ class AutoScalingTest(HeatTestCase):
del(update_snippet['Properties']['DesiredCapacity'])
scheduler.TaskRunner(rsrc.update, update_snippet)()
self.assertEqual(instance_names, rsrc.get_instance_names())
self.assertEqual(None, rsrc.properties['DesiredCapacity'])
self.assertIsNone(rsrc.properties['DesiredCapacity'])
rsrc.delete()
self.m.VerifyAll()
@ -1109,7 +1109,7 @@ class AutoScalingTest(HeatTestCase):
'WebServerScaleUpPolicy')
alarm_url = up_policy.FnGetAtt('AlarmUrl')
self.assertNotEqual(None, alarm_url)
self.assertIsNotNone(alarm_url)
up_policy.signal()
self.assertEqual(len(rsrc.get_instance_names()), 2)

@ -54,7 +54,7 @@ class CloudWatchAlarmTest(common.HeatTestCase):
@utils.stack_delete_after
def test_resource_create_good(self):
s = self.parse_stack()
self.assertEqual(None, scheduler.TaskRunner(s['test_me'].create)())
self.assertIsNone(scheduler.TaskRunner(s['test_me'].create)())
@utils.stack_delete_after
def test_resource_create_failed(self):
@ -67,8 +67,8 @@ class CloudWatchAlarmTest(common.HeatTestCase):
@utils.stack_delete_after
def test_resource_delete_good(self):
s = self.parse_stack()
self.assertEqual(None, scheduler.TaskRunner(s['test_me'].create)())
self.assertEqual(None, scheduler.TaskRunner(s['test_me'].delete)())
self.assertIsNone(scheduler.TaskRunner(s['test_me'].create)())
self.assertIsNone(scheduler.TaskRunner(s['test_me'].delete)())
@utils.stack_delete_after
@utils.wr_delete_after
@ -76,7 +76,7 @@ class CloudWatchAlarmTest(common.HeatTestCase):
# if a resource is not found, handle_delete() should not raise
# an exception.
s = self.parse_stack()
self.assertEqual(None, scheduler.TaskRunner(s['test_me'].create)())
self.assertIsNone(scheduler.TaskRunner(s['test_me'].create)())
res_name = self.stack['test_me'].physical_resource_name()
self.wr = watchrule.WatchRule.load(self.ctx,
watch_name=res_name)
@ -84,4 +84,4 @@ class CloudWatchAlarmTest(common.HeatTestCase):
with patch.object(watchrule.WatchRule, 'destroy') as bad_destroy:
watch_exc = exception.WatchRuleNotFound(watch_name='test')
bad_destroy.side_effect = watch_exc
self.assertEqual(None, scheduler.TaskRunner(s['test_me'].delete)())
self.assertIsNone(scheduler.TaskRunner(s['test_me'].delete)())

@ -59,7 +59,7 @@ class CloudWatchAlarmTest(HeatTestCase):
rsrc = cloud_watch.CloudWatchAlarm(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

@ -115,4 +115,4 @@ class DBInstanceTest(HeatTestCase):
templ)
res = stack['DatabaseServer']
self.assertEqual(None, res._validate_against_facade(DBInstance))
self.assertIsNone(res._validate_against_facade(DBInstance))

@ -166,7 +166,7 @@ class EIPTest(HeatTestCase):
rsrc = eip.ElasticIp(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
@ -175,7 +175,7 @@ class EIPTest(HeatTestCase):
rsrc = eip.ElasticIpAssociation(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
@ -318,7 +318,7 @@ class AllocTest(HeatTestCase):
rsrc = eip.ElasticIp(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
@ -327,7 +327,7 @@ class AllocTest(HeatTestCase):
rsrc = eip.ElasticIpAssociation(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

@ -270,7 +270,7 @@ class StackCreateTest(HeatTestCase):
stack.store()
stack.create()
self.assertNotEqual(stack['WebServer'], None)
self.assertIsNotNone(stack['WebServer'])
self.assertTrue(stack['WebServer'].resource_id > 0)
self.assertNotEqual(stack['WebServer'].ipaddress, '0.0.0.0')
@ -283,9 +283,9 @@ class StackCreateTest(HeatTestCase):
stack.create()
db_s = db_api.stack_get(ctx, stack_id)
self.assertNotEqual(db_s, None)
self.assertIsNotNone(db_s)
self.assertNotEqual(stack['WebServer'], None)
self.assertIsNotNone(stack['WebServer'])
self.assertTrue(stack['WebServer'].resource_id > 0)
self.m.StubOutWithMock(fc.client, 'get_servers_9999')
@ -297,7 +297,7 @@ class StackCreateTest(HeatTestCase):
rsrc = stack['WebServer']
self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
self.assertEqual((stack.DELETE, stack.COMPLETE), rsrc.state)
self.assertEqual(None, db_api.stack_get(ctx, stack_id))
self.assertIsNone(db_api.stack_get(ctx, stack_id))
self.assertEqual('DELETE', db_s.action)
self.assertEqual('COMPLETE', db_s.status, )
@ -548,8 +548,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
self.m.ReplayAll()
self.assertEqual(None,
self.man.delete_stack(self.ctx, stack.identifier()))
self.assertIsNone(self.man.delete_stack(self.ctx, stack.identifier()))
self.m.VerifyAll()
def test_stack_delete_nonexist(self):
@ -888,7 +887,7 @@ class StackServiceSuspendResumeTest(HeatTestCase):
self.m.ReplayAll()
result = self.man.stack_suspend(self.ctx, stack.identifier())
self.assertEqual(None, result)
self.assertIsNone(result)
self.m.VerifyAll()
@ -908,7 +907,7 @@ class StackServiceSuspendResumeTest(HeatTestCase):
self.m.ReplayAll()
result = self.man.stack_resume(self.ctx, self.stack.identifier())
self.assertEqual(None, result)
self.assertIsNone(result)
self.m.VerifyAll()
def test_stack_suspend_nonexist(self):
@ -990,7 +989,7 @@ class StackServiceTest(HeatTestCase):
db_api.stack_get_by_name(self.ctx,
self.stack.name).id)
ctx2 = utils.dummy_context(tenant_id='stack_service_test_tenant2')
self.assertEqual(None, db_api.stack_get_by_name(ctx2, self.stack.name))
self.assertIsNone(db_api.stack_get_by_name(ctx2, self.stack.name))
@stack_context('service_event_list_test_stack')
def test_stack_event_list(self):
@ -1161,7 +1160,7 @@ class StackServiceTest(HeatTestCase):
self.assertIn('creation_time', s)
self.assertIn('updated_time', s)
self.assertIn('stack_identity', s)
self.assertNotEqual(s['stack_identity'], None)
self.assertIsNotNone(s['stack_identity'])
self.assertIn('stack_name', s)
self.assertEqual(self.stack.name, s['stack_name'])
self.assertIn('stack_status', s)
@ -1262,7 +1261,7 @@ class StackServiceTest(HeatTestCase):
self.assertIn('creation_time', s)
self.assertIn('updated_time', s)
self.assertIn('stack_identity', s)
self.assertNotEqual(s['stack_identity'], None)
self.assertIsNotNone(s['stack_identity'])
self.assertIn('stack_name', s)
self.assertEqual(self.stack.name, s['stack_name'])
self.assertIn('stack_status', s)
@ -1283,7 +1282,7 @@ class StackServiceTest(HeatTestCase):
self.assertIn('creation_time', s)
self.assertIn('updated_time', s)
self.assertIn('stack_identity', s)
self.assertNotEqual(s['stack_identity'], None)
self.assertIsNotNone(s['stack_identity'])
self.assertIn('stack_name', s)
self.assertEqual(self.stack.name, s['stack_name'])
self.assertIn('stack_status', s)
@ -1336,7 +1335,7 @@ class StackServiceTest(HeatTestCase):
self.assertIn('description', r)
self.assertIn('updated_time', r)
self.assertIn('stack_identity', r)
self.assertNotEqual(r['stack_identity'], None)
self.assertIsNotNone(r['stack_identity'])
self.assertIn('stack_name', r)
self.assertEqual(self.stack.name, r['stack_name'])
self.assertIn('metadata', r)
@ -1439,7 +1438,7 @@ class StackServiceTest(HeatTestCase):
self.assertIn('description', r)
self.assertIn('updated_time', r)
self.assertIn('stack_identity', r)
self.assertNotEqual(r['stack_identity'], None)
self.assertIsNotNone(r['stack_identity'])
self.assertIn('stack_name', r)
self.assertEqual(self.stack.name, r['stack_name'])
self.assertIn('resource_status', r)
@ -1782,7 +1781,7 @@ class StackServiceTest(HeatTestCase):
# And add a metric datapoint
watch = db_api.watch_rule_get_by_name(self.ctx, 'show_watch_metric_1')
self.assertNotEqual(watch, None)
self.assertIsNotNone(watch)
values = {'watch_rule_id': watch.id,
'data': {u'Namespace': u'system/linux',
u'ServiceFailure': {
@ -1943,8 +1942,8 @@ class StackServiceTest(HeatTestCase):
stack = parser.Stack(self.ctx, stack_name, templ,
environment.Environment({}))
self.assertEqual(stack._resources, None)
self.assertEqual(stack._dependencies, None)
self.assertIsNone(stack._resources)
self.assertIsNone(stack._dependencies)
resources = stack.resources
self.assertEqual(type(resources), dict)

@ -101,9 +101,8 @@ class EnvironmentTest(common.HeatTestCase):
u'OS::Networking::FloatingIP': 'ip.yaml'}}}}
env = environment.Environment()
self.assertEqual(None,
env.get_resource_info('OS::Networking::FloatingIP',
'my_fip'))
self.assertIsNone(env.get_resource_info('OS::Networking::FloatingIP',
'my_fip'))
env.load(new_env)
self.assertEqual('ip.yaml',
@ -266,8 +265,7 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
resources._load_all(g_env)
# 3. assert our resource is in now gone.
self.assertEqual(None,
g_env.get_resource_info('OS::Nova::Server'))
self.assertIsNone(g_env.get_resource_info('OS::Nova::Server'))
# 4. make sure we haven't removed something we shouldn't have
self.assertEqual(resources.instance.Instance,
@ -292,8 +290,7 @@ class GlobalEnvLoadingTest(common.HeatTestCase):
resources._load_all(g_env)
# 3. assert our resources are now gone.
self.assertEqual(None,
g_env.get_resource_info('AWS::EC2::Instance'))
self.assertIsNone(g_env.get_resource_info('AWS::EC2::Instance'))
# 4. make sure we haven't removed something we shouldn't have
self.assertEqual(resources.server.Server,

@ -68,7 +68,7 @@ class EventTest(HeatTestCase):
self.resource.name, self.resource.type())
e.store()
self.assertNotEqual(e.id, None)
self.assertIsNotNone(e.id)
loaded_e = event.Event.load(self.ctx, e.id)
@ -78,7 +78,7 @@ class EventTest(HeatTestCase):
self.assertEqual('TEST', loaded_e.action)
self.assertEqual('IN_PROGRESS', loaded_e.status)
self.assertEqual('Testing', loaded_e.reason)
self.assertNotEqual(None, loaded_e.timestamp)
self.assertIsNotNone(loaded_e.timestamp)
self.assertEqual({'Foo': 'goo'}, loaded_e.resource_properties)
def test_load_given_stack_event(self):
@ -89,7 +89,7 @@ class EventTest(HeatTestCase):
self.resource.name, self.resource.type())
e.store()
self.assertNotEqual(e.id, None)
self.assertIsNotNone(e.id)
ev = db_api.event_get(self.ctx, e.id)
@ -101,7 +101,7 @@ class EventTest(HeatTestCase):
self.assertEqual('TEST', loaded_e.action)
self.assertEqual('IN_PROGRESS', loaded_e.status)
self.assertEqual('Testing', loaded_e.reason)
self.assertNotEqual(None, loaded_e.timestamp)
self.assertIsNotNone(loaded_e.timestamp)
self.assertEqual({'Foo': 'goo'}, loaded_e.resource_properties)
def test_store_caps_events(self):

@ -292,7 +292,7 @@ class InstancesTest(HeatTestCase):
uuidutils.is_uuid_like('1').AndReturn(True)
self.m.ReplayAll()
self.assertEqual(instance.validate(), None)
self.assertIsNone(instance.validate())
self.m.VerifyAll()
@ -311,7 +311,7 @@ class InstancesTest(HeatTestCase):
mox.Replay(get)
scheduler.TaskRunner(instance.delete)()
self.assertTrue(instance.resource_id is None)
self.assertIsNone(instance.resource_id)
self.assertEqual(instance.state, (instance.DELETE, instance.COMPLETE))
self.m.VerifyAll()
@ -641,8 +641,8 @@ class InstancesTest(HeatTestCase):
instance = self._create_test_instance(return_server,
'build_nics')
self.assertEqual(None, instance._build_nics([]))
self.assertEqual(None, instance._build_nics(None))
self.assertIsNone(instance._build_nics([]))
self.assertIsNone(instance._build_nics(None))
self.assertEqual([
{'port-id': 'id3'}, {'port-id': 'id1'}, {'port-id': 'id2'}],
instance._build_nics([

@ -84,7 +84,7 @@ class InstanceGroupTest(HeatTestCase):
# subsequent resources may need to reference previous created resources
# use the stack's resource objects instead of instantiating new ones
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
@ -191,8 +191,8 @@ class InstanceGroupTest(HeatTestCase):
update_snippet['Properties']['Size'] = '5'
tmpl_diff = {'Properties': {'Size': '5'}}
prop_diff = {'Size': '5'}
self.assertEqual(None, rsrc.handle_update(update_snippet, tmpl_diff,
prop_diff))
self.assertIsNone(rsrc.handle_update(update_snippet, tmpl_diff,
prop_diff))
self.assertEqual('10.0.0.2,10.0.0.3,10.0.0.4,10.0.0.5,10.0.0.6',
rsrc.FnGetAtt('InstanceList'))

@ -117,7 +117,7 @@ class LoadBalancerTest(HeatTestCase):
rsrc = lb.LoadBalancer(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
@ -169,7 +169,7 @@ class LoadBalancerTest(HeatTestCase):
'Interval': '30',
'Timeout': '5'}
rsrc.t['Properties']['HealthCheck'] = hc
self.assertEqual(None, rsrc.validate())
self.assertIsNone(rsrc.validate())
hc['Timeout'] = 35
self.assertEqual(
@ -204,7 +204,7 @@ class LoadBalancerTest(HeatTestCase):
except exception.InvalidTemplateAttribute:
pass
self.assertEqual(None, rsrc.handle_update({}, {}, {}))
self.assertIsNone(rsrc.handle_update({}, {}, {}))
self.m.VerifyAll()

@ -113,7 +113,7 @@ class LoguserdataTest(HeatTestCase):
OSError(errno.ENOEXEC, "empty script"))
self.m.ReplayAll()
self.assertEqual(None, loguserdata.main())
self.assertIsNone(loguserdata.main())
self.m.VerifyAll()

@ -249,7 +249,7 @@ class WaitCondMetadataUpdateTest(HeatTestCase):
def check_empty(sleep_time):
self.assertEqual(watch.FnGetAtt('Data'), '{}')
self.assertEqual(inst.metadata['test'], None)
self.assertIsNone(inst.metadata['test'])
def update_metadata(id, data, reason):
self.man.metadata_update(utils.dummy_context(),

@ -199,7 +199,7 @@ Outputs:
prop_diff = {'TemplateURL': 'https://server.test/new.template'}
updater = rsrc.handle_update(new_res, {}, prop_diff)
updater.run_to_completion()
self.assertEqual(True, rsrc.check_update_complete(updater))
self.assertIs(True, rsrc.check_update_complete(updater))
# Expect the physical resource name staying the same after update,
# so that the nested was actually updated instead of replaced.
@ -255,7 +255,7 @@ Outputs:
prop_diff = {'TemplateURL': 'https://server.test/new.template'}
updater = rsrc.handle_update(new_res, {}, prop_diff)
updater.run_to_completion()
self.assertEqual(True, rsrc.check_update_complete(updater))
self.assertIs(True, rsrc.check_update_complete(updater))
self.assertEqual('foo', rsrc.FnGetAtt('Outputs.Bar'))

@ -245,7 +245,7 @@ class NeutronTest(HeatTestCase):
data = {'admin_state_up': False,
'value_specs': vs}
p = properties.Properties(net.Net.properties_schema, data)
self.assertEqual(None, qr.validate_properties(p))
self.assertIsNone(qr.validate_properties(p))
vs['shared'] = True
self.assertEqual('shared not allowed in value_specs',
@ -263,7 +263,7 @@ class NeutronTest(HeatTestCase):
vs.pop('tenant_id')
vs['foo'] = '1234'
self.assertEqual(None, qr.validate_properties(p))
self.assertIsNone(qr.validate_properties(p))
def test_prepare_properties(self):
data = {'admin_state_up': False,
@ -429,7 +429,7 @@ class NeutronNetTest(HeatTestCase):
ref_id = rsrc.FnGetRefId()
self.assertEqual('fc68ea2c-b60b-4b4f-bd82-94ec81110766', ref_id)
self.assertEqual(None, rsrc.FnGetAtt('status'))
self.assertIsNone(rsrc.FnGetAtt('status'))
self.assertEqual('ACTIVE', rsrc.FnGetAtt('status'))
self.assertRaises(
exception.InvalidTemplateAttribute, rsrc.FnGetAtt, 'Foo')
@ -643,8 +643,7 @@ class NeutronSubnetTest(HeatTestCase):
ref_id = rsrc.FnGetRefId()
self.assertEqual('91e47a57-7508-46fe-afc9-fc454e8580e1', ref_id)
self.assertEqual(None,
rsrc.FnGetAtt('network_id'))
self.assertIsNone(rsrc.FnGetAtt('network_id'))
self.assertEqual('fc68ea2c-b60b-4b4f-bd82-94ec81110766',
rsrc.FnGetAtt('network_id'))
self.assertEqual('8.8.8.8', rsrc.FnGetAtt('dns_nameservers')[0])
@ -669,9 +668,9 @@ class NeutronSubnetTest(HeatTestCase):
}
rsrc.handle_update(update_snippet, {}, {})
self.assertEqual(scheduler.TaskRunner(rsrc.delete)(), None)
self.assertIsNone(scheduler.TaskRunner(rsrc.delete)())
rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE, 'to delete again')
self.assertEqual(scheduler.TaskRunner(rsrc.delete)(), None)
self.assertIsNone(scheduler.TaskRunner(rsrc.delete)())
self.m.VerifyAll()
def test_subnet_disable_dhcp(self):
@ -741,7 +740,7 @@ class NeutronSubnetTest(HeatTestCase):
ref_id = rsrc.FnGetRefId()
self.assertEqual('91e47a57-7508-46fe-afc9-fc454e8580e1', ref_id)
self.assertEqual(False, rsrc.FnGetAtt('enable_dhcp'))
self.assertIs(False, rsrc.FnGetAtt('enable_dhcp'))
scheduler.TaskRunner(rsrc.delete)()
self.m.VerifyAll()
@ -937,8 +936,7 @@ class NeutronRouterTest(HeatTestCase):
ref_id = rsrc.FnGetRefId()
self.assertEqual('3e46229d-8fce-4733-819a-b5fe630550f8', ref_id)
self.assertEqual(None,
rsrc.FnGetAtt('tenant_id'))
self.assertIsNone(rsrc.FnGetAtt('tenant_id'))
self.assertEqual('3e21026f2dc94372b105808c0e721661',
rsrc.FnGetAtt('tenant_id'))
@ -951,9 +949,9 @@ class NeutronRouterTest(HeatTestCase):
}
rsrc.handle_update(update_snippet, {}, {})
self.assertEqual(scheduler.TaskRunner(rsrc.delete)(), None)
self.assertIsNone(scheduler.TaskRunner(rsrc.delete)())
rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE, 'to delete again')
self.assertEqual(scheduler.TaskRunner(rsrc.delete)(), None)
self.assertIsNone(scheduler.TaskRunner(rsrc.delete)())
self.m.VerifyAll()
def test_router_interface(self):
@ -1069,13 +1067,13 @@ class NeutronRouterTest(HeatTestCase):
'port_id': '9577cafd-8e98-4059-a2e6-8a771b4d318e'}
stack = utils.parse_stack(t)
res = router.RouterInterface('router_interface', json, stack)
self.assertEqual(None, res.validate())
self.assertIsNone(res.validate())
json['Properties'] = {
'router_id': 'ae478782-53c0-4434-ab16-49900c88016c',
'subnet_id': '9577cafd-8e98-4059-a2e6-8a771b4d318e'}
stack = utils.parse_stack(t)
res = router.RouterInterface('router_interface', json, stack)
self.assertEqual(None, res.validate())
self.assertIsNone(res.validate())
json['Properties'] = {
'router_id': 'ae478782-53c0-4434-ab16-49900c88016c'}
stack = utils.parse_stack(t)
@ -1275,7 +1273,7 @@ class NeutronFloatingIPTest(HeatTestCase):
fip_id = fip.FnGetRefId()
self.assertEqual('fc68ea2c-b60b-4b4f-bd82-94ec81110766', fip_id)
self.assertEqual(None, fip.FnGetAtt('show'))
self.assertIsNone(fip.FnGetAtt('show'))
self.assertEqual('fc68ea2c-b60b-4b4f-bd82-94ec81110766',
fip.FnGetAtt('show')['id'])
try:
@ -1356,7 +1354,7 @@ class NeutronFloatingIPTest(HeatTestCase):
port_id = p.FnGetRefId()
self.assertEqual('fc68ea2c-b60b-4b4f-bd82-94ec81110766', port_id)
self.assertEqual(None, p.FnGetAtt('status'))
self.assertIsNone(p.FnGetAtt('status'))
self.assertEqual('ACTIVE', p.FnGetAtt('status'))
self.assertRaises(
exception.InvalidTemplateAttribute, p.FnGetAtt, 'Foo')
@ -1485,7 +1483,7 @@ class NeutronFloatingIPTest(HeatTestCase):
p.state_set(p.CREATE, p.COMPLETE, 'to delete again')
scheduler.TaskRunner(fipa.delete)()
self.assertEqual(scheduler.TaskRunner(p.delete)(), None)
self.assertIsNone(scheduler.TaskRunner(p.delete)())
scheduler.TaskRunner(fip.delete)()
self.m.VerifyAll()

@ -189,7 +189,7 @@ class FirewallTest(HeatTestCase):
'firewall_policy_id': 'policy-id'}})
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual(True, rsrc.FnGetAtt('admin_state_up'))
self.assertIs(True, rsrc.FnGetAtt('admin_state_up'))
self.assertEqual('policy-id', rsrc.FnGetAtt('firewall_policy_id'))
self.m.VerifyAll()
@ -319,8 +319,8 @@ class FirewallPolicyTest(HeatTestCase):
{'firewall_policy': {'audited': True, 'shared': True}})
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual(True, rsrc.FnGetAtt('audited'))
self.assertEqual(True, rsrc.FnGetAtt('shared'))
self.assertIs(True, rsrc.FnGetAtt('audited'))
self.assertIs(True, rsrc.FnGetAtt('shared'))
self.m.VerifyAll()
def test_attribute_failed(self):
@ -452,7 +452,7 @@ class FirewallRuleTest(HeatTestCase):
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual('tcp', rsrc.FnGetAtt('protocol'))
self.assertEqual(True, rsrc.FnGetAtt('shared'))
self.assertIs(True, rsrc.FnGetAtt('shared'))
self.m.VerifyAll()
def test_attribute_failed(self):

@ -205,7 +205,7 @@ class HealthMonitorTest(HeatTestCase):
{'health_monitor': {'admin_state_up': True, 'delay': 3}})
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual(True, rsrc.FnGetAtt('admin_state_up'))
self.assertIs(True, rsrc.FnGetAtt('admin_state_up'))
self.assertEqual(3, rsrc.FnGetAtt('delay'))
self.m.VerifyAll()
@ -473,7 +473,7 @@ class PoolTest(HeatTestCase):
{'pool': {'admin_state_up': True, 'lb_method': 'ROUND_ROBIN'}})
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual(True, rsrc.FnGetAtt('admin_state_up'))
self.assertIs(True, rsrc.FnGetAtt('admin_state_up'))
self.assertEqual('ROUND_ROBIN', rsrc.FnGetAtt('lb_method'))
self.m.VerifyAll()
@ -619,7 +619,7 @@ class PoolMemberTest(HeatTestCase):
{'member': {'admin_state_up': True, 'weight': 5}})
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual(True, rsrc.FnGetAtt('admin_state_up'))
self.assertIs(True, rsrc.FnGetAtt('admin_state_up'))
self.assertEqual(5, rsrc.FnGetAtt('weight'))
self.m.VerifyAll()

@ -109,7 +109,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):
@ -120,7 +120,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))

@ -242,7 +242,7 @@ class VPNServiceTest(HeatTestCase):
scheduler.TaskRunner(rsrc.create)()
self.assertEqual('VPNService', rsrc.FnGetAtt('name'))
self.assertEqual('My new VPN service', rsrc.FnGetAtt('description'))
self.assertEqual(True, rsrc.FnGetAtt('admin_state_up'))
self.assertIs(True, rsrc.FnGetAtt('admin_state_up'))
self.assertEqual('rou123', rsrc.FnGetAtt('router_id'))
self.assertEqual('sub123', rsrc.FnGetAtt('subnet_id'))
self.m.VerifyAll()
@ -410,7 +410,7 @@ class IPsecSiteConnectionTest(HeatTestCase):
self.assertEqual(120, rsrc.FnGetAtt('dpd')['timeout'])
self.assertEqual('secret', rsrc.FnGetAtt('psk'))
self.assertEqual('bi-directional', rsrc.FnGetAtt('initiator'))
self.assertEqual(True, rsrc.FnGetAtt('admin_state_up'))
self.assertIs(True, rsrc.FnGetAtt('admin_state_up'))
self.assertEqual('ike123', rsrc.FnGetAtt('ikepolicy_id'))
self.assertEqual('ips123', rsrc.FnGetAtt('ipsecpolicy_id'))
self.assertEqual('vpn123', rsrc.FnGetAtt('vpnservice_id'))

Loading…
Cancel
Save