Use six to translate exception message in tests
Use six to translate exception message in tests Change-Id: I129de2f350ef31c6a8ef10355ada20d7789049a9
This commit is contained in:
parent
442e79b559
commit
fcba3fa9c8
@ -195,7 +195,7 @@ class ValidateGetAttTest(HeatTestCase):
|
|||||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||||
func.validate)
|
func.validate)
|
||||||
self.assertEqual('The specified reference "test_rsrc" (in unknown) '
|
self.assertEqual('The specified reference "test_rsrc" (in unknown) '
|
||||||
'is incorrect.', str(ex))
|
'is incorrect.', six.text_type(ex))
|
||||||
|
|
||||||
def test_resource_no_attribute_with_default_fn_get_att(self):
|
def test_resource_no_attribute_with_default_fn_get_att(self):
|
||||||
func = functions.GetAtt(self.stack, 'Fn::GetAtt',
|
func = functions.GetAtt(self.stack, 'Fn::GetAtt',
|
||||||
@ -203,7 +203,7 @@ class ValidateGetAttTest(HeatTestCase):
|
|||||||
ex = self.assertRaises(exception.InvalidTemplateAttribute,
|
ex = self.assertRaises(exception.InvalidTemplateAttribute,
|
||||||
func.validate)
|
func.validate)
|
||||||
self.assertEqual('The Referenced Attribute (test_rsrc Bar) '
|
self.assertEqual('The Referenced Attribute (test_rsrc Bar) '
|
||||||
'is incorrect.', str(ex))
|
'is incorrect.', six.text_type(ex))
|
||||||
|
|
||||||
def test_resource_no_attribute_with_overwritten_fn_get_att(self):
|
def test_resource_no_attribute_with_overwritten_fn_get_att(self):
|
||||||
res_defn = rsrc_defn.ResourceDefinition('test_rsrc',
|
res_defn = rsrc_defn.ResourceDefinition('test_rsrc',
|
||||||
|
@ -433,7 +433,7 @@ class InstancesTest(HeatTestCase):
|
|||||||
instance._check_active = mock.Mock(return_value=False)
|
instance._check_active = mock.Mock(return_value=False)
|
||||||
|
|
||||||
exc = self.assertRaises(exception.Error, instance.handle_check)
|
exc = self.assertRaises(exception.Error, instance.handle_check)
|
||||||
self.assertIn('foo', str(exc))
|
self.assertIn('foo', six.text_type(exc))
|
||||||
|
|
||||||
class FakeVolumeAttach(object):
|
class FakeVolumeAttach(object):
|
||||||
def started(self):
|
def started(self):
|
||||||
@ -450,7 +450,7 @@ class InstancesTest(HeatTestCase):
|
|||||||
(return_server, self.FakeVolumeAttach()))
|
(return_server, self.FakeVolumeAttach()))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Instance is not active - Unknown status BOGUS',
|
'Instance is not active - Unknown status BOGUS',
|
||||||
str(e))
|
six.text_type(e))
|
||||||
|
|
||||||
def test_instance_create_error_status(self):
|
def test_instance_create_error_status(self):
|
||||||
return_server = self.fc.servers.list()[1]
|
return_server = self.fc.servers.list()[1]
|
||||||
@ -471,7 +471,7 @@ class InstancesTest(HeatTestCase):
|
|||||||
(return_server, self.FakeVolumeAttach()))
|
(return_server, self.FakeVolumeAttach()))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Went to status ERROR due to "Message: NoValidHost, Code: 500"',
|
'Went to status ERROR due to "Message: NoValidHost, Code: 500"',
|
||||||
str(e))
|
six.text_type(e))
|
||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
@ -508,13 +508,13 @@ class NeutronTest(HeatTestCase):
|
|||||||
})
|
})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Went to status ERROR due to "Unknown"',
|
'Went to status ERROR due to "Unknown"',
|
||||||
str(e))
|
six.text_type(e))
|
||||||
e = self.assertRaises(resource.ResourceUnknownStatus, qr.is_built, {
|
e = self.assertRaises(resource.ResourceUnknownStatus, qr.is_built, {
|
||||||
'status': 'FROBULATING'
|
'status': 'FROBULATING'
|
||||||
})
|
})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Resource is not built - Unknown status FROBULATING',
|
'Resource is not built - Unknown status FROBULATING',
|
||||||
str(e))
|
six.text_type(e))
|
||||||
|
|
||||||
def test_resolve_attribute(self):
|
def test_resolve_attribute(self):
|
||||||
class SomeNeutronResource(qr):
|
class SomeNeutronResource(qr):
|
||||||
|
@ -4192,7 +4192,7 @@ class StackTest(HeatTestCase):
|
|||||||
|
|
||||||
self.assertEqual('Output validation error: The Referenced Attribute '
|
self.assertEqual('Output validation error: The Referenced Attribute '
|
||||||
'(AResource Bar) is incorrect.',
|
'(AResource Bar) is incorrect.',
|
||||||
str(ex))
|
six.text_type(ex))
|
||||||
|
|
||||||
def test_incorrect_outputs_hot_get_attr(self):
|
def test_incorrect_outputs_hot_get_attr(self):
|
||||||
tmpl = {'heat_template_version': '2013-05-23',
|
tmpl = {'heat_template_version': '2013-05-23',
|
||||||
@ -4212,4 +4212,4 @@ class StackTest(HeatTestCase):
|
|||||||
|
|
||||||
self.assertEqual('Output validation error: The Referenced Attribute '
|
self.assertEqual('Output validation error: The Referenced Attribute '
|
||||||
'(AResource Bar) is incorrect.',
|
'(AResource Bar) is incorrect.',
|
||||||
str(ex))
|
six.text_type(ex))
|
||||||
|
@ -573,7 +573,7 @@ class ResourceTest(HeatTestCase):
|
|||||||
estr = ('ResourceInError: Went to status ERROR due to "just because"')
|
estr = ('ResourceInError: Went to status ERROR due to "just because"')
|
||||||
create = scheduler.TaskRunner(res.create)
|
create = scheduler.TaskRunner(res.create)
|
||||||
err = self.assertRaises(exception.ResourceFailure, create)
|
err = self.assertRaises(exception.ResourceFailure, create)
|
||||||
self.assertEqual(estr, str(err))
|
self.assertEqual(estr, six.text_type(err))
|
||||||
self.assertEqual((res.CREATE, res.FAILED), res.state)
|
self.assertEqual((res.CREATE, res.FAILED), res.state)
|
||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
@ -410,7 +410,7 @@ class ServersTest(HeatTestCase):
|
|||||||
return_server)
|
return_server)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Server is not active - Unknown status BOGUS',
|
'Server is not active - Unknown status BOGUS',
|
||||||
str(e))
|
six.text_type(e))
|
||||||
|
|
||||||
def test_server_create_error_status(self):
|
def test_server_create_error_status(self):
|
||||||
return_server = self.fc.servers.list()[1]
|
return_server = self.fc.servers.list()[1]
|
||||||
@ -431,7 +431,7 @@ class ServersTest(HeatTestCase):
|
|||||||
return_server)
|
return_server)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'Went to status ERROR due to "Message: NoValidHost, Code: 500"',
|
'Went to status ERROR due to "Message: NoValidHost, Code: 500"',
|
||||||
str(e))
|
six.text_type(e))
|
||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
@ -844,12 +844,12 @@ class SqlAlchemyTest(HeatTestCase):
|
|||||||
db_api.software_config_get,
|
db_api.software_config_get,
|
||||||
self.ctx,
|
self.ctx,
|
||||||
config_id)
|
config_id)
|
||||||
self.assertIn(config_id, str(err))
|
self.assertIn(config_id, six.text_type(err))
|
||||||
|
|
||||||
err = self.assertRaises(
|
err = self.assertRaises(
|
||||||
exception.NotFound, db_api.software_config_delete,
|
exception.NotFound, db_api.software_config_delete,
|
||||||
self.ctx, config_id)
|
self.ctx, config_id)
|
||||||
self.assertIn(config_id, str(err))
|
self.assertIn(config_id, six.text_type(err))
|
||||||
|
|
||||||
def _deployment_values(self):
|
def _deployment_values(self):
|
||||||
tenant_id = self.ctx.tenant_id
|
tenant_id = self.ctx.tenant_id
|
||||||
|
Loading…
Reference in New Issue
Block a user