Replace str() with six.text_type() where exception is used
When switching to oslo.i18n, tests where used str(exc) will failed with unicodeerror, so before switching to oslo.i18n, need to replace str with six.text_type where exception is used. And it's recommanded to use six.text_type instead of str in openstack. Change-Id: Ie37a6ef74a12b2580ce72afc75c99bcd19d4cf97
This commit is contained in:
parent
70c36b9afa
commit
10a00d3ee4
@ -11,6 +11,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine import attributes
|
||||
from heat.engine import constraints
|
||||
@ -137,7 +139,7 @@ class Order(resource.Resource):
|
||||
except clients.barbican_client.HTTPClientError as exc:
|
||||
# This is the only exception the client raises
|
||||
# Inspecting the message to see if it's a 'Not Found'
|
||||
if 'Not Found' in str(exc):
|
||||
if 'Not Found' in six.text_type(exc):
|
||||
self.resource_id_set(None)
|
||||
else:
|
||||
raise
|
||||
@ -147,7 +149,7 @@ class Order(resource.Resource):
|
||||
order = self.barbican().orders.get(self.resource_id)
|
||||
except clients.barbican_client.HTTPClientError as exc:
|
||||
LOG.warn(_("Order '%(name)s' not found: %(exc)s") %
|
||||
{'name': self.resource_id, 'exc': str(exc)})
|
||||
{'name': self.resource_id, 'exc': six.text_type(exc)})
|
||||
return ''
|
||||
|
||||
return getattr(order, name)
|
||||
|
@ -11,6 +11,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine import attributes
|
||||
from heat.engine import constraints
|
||||
@ -142,7 +144,7 @@ class Secret(resource.Resource):
|
||||
except clients.barbican_client.HTTPClientError as exc:
|
||||
# This is the only exception the client raises
|
||||
# Inspecting the message to see if it's a 'Not Found'
|
||||
if 'Not Found' in str(exc):
|
||||
if 'Not Found' in six.text_type(exc):
|
||||
self.resource_id_set(None)
|
||||
else:
|
||||
raise
|
||||
@ -159,7 +161,7 @@ class Secret(resource.Resource):
|
||||
except clients.barbican_client.HTTPClientError as e:
|
||||
msg = _("Failed to resolve '%(name)s' for %(res)s '%(id)s': %(e)s")
|
||||
LOG.warn(msg % {'name': name, 'res': self.__class__.__name__,
|
||||
'id': self.resource_id, 'e': str(e)})
|
||||
'id': self.resource_id, 'e': six.text_type(e)})
|
||||
return ''
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -165,7 +166,7 @@ class TestOrder(HeatTestCase):
|
||||
self.barbican.orders.delete.side_effect = exc
|
||||
exc = self.assertRaises(exception.ResourceFailure,
|
||||
scheduler.TaskRunner(res.delete))
|
||||
self.assertIn('Boom.', str(exc))
|
||||
self.assertIn('Boom.', six.text_type(exc))
|
||||
|
||||
def test_check_create_complete(self):
|
||||
res = order.Order('foo', self.res_template, self.stack)
|
||||
@ -183,5 +184,5 @@ class TestOrder(HeatTestCase):
|
||||
self.barbican.orders.get.return_value = mock_not_active
|
||||
exc = self.assertRaises(exception.Error,
|
||||
res.check_create_complete, 'foo')
|
||||
self.assertIn('foo', str(exc))
|
||||
self.assertIn('500', str(exc))
|
||||
self.assertIn('foo', six.text_type(exc))
|
||||
self.assertIn('500', six.text_type(exc))
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -144,15 +145,15 @@ class TestSecret(HeatTestCase):
|
||||
props)
|
||||
res = self._create_resource(defn.name, defn, self.stack)
|
||||
exc = self.assertRaises(exception.StackValidationFailed, res.validate)
|
||||
self.assertIn('payload', str(exc))
|
||||
self.assertIn('payload_content_type', str(exc))
|
||||
self.assertIn('payload', six.text_type(exc))
|
||||
self.assertIn('payload_content_type', six.text_type(exc))
|
||||
|
||||
defn = rsrc_defn.ResourceDefinition('notype', 'OS::Barbican::Secret',
|
||||
{'payload': 'foo'})
|
||||
res = self._create_resource(defn.name, defn, self.stack)
|
||||
exc = self.assertRaises(exception.StackValidationFailed, res.validate)
|
||||
self.assertIn('payload', str(exc))
|
||||
self.assertIn('payload_content_type', str(exc))
|
||||
self.assertIn('payload', six.text_type(exc))
|
||||
self.assertIn('payload_content_type', six.text_type(exc))
|
||||
|
||||
def test_delete_secret(self):
|
||||
self.assertEqual('foo_id', self.res.resource_id)
|
||||
@ -178,4 +179,4 @@ class TestSecret(HeatTestCase):
|
||||
self.barbican.secrets.delete.side_effect = exc
|
||||
exc = self.assertRaises(exception.ResourceFailure,
|
||||
scheduler.TaskRunner(self.res.delete))
|
||||
self.assertIn('Boom.', str(exc))
|
||||
self.assertIn('Boom.', six.text_type(exc))
|
||||
|
@ -11,6 +11,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
from heat.engine import parser
|
||||
@ -131,7 +133,7 @@ class MarconiMessageQueueTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.ResourceFailure,
|
||||
scheduler.TaskRunner(queue.create))
|
||||
self.assertEqual("Error: Message queue myqueue already exists.",
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_create_failed(self):
|
||||
@ -156,7 +158,7 @@ class MarconiMessageQueueTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.ResourceFailure,
|
||||
scheduler.TaskRunner(queue.create))
|
||||
self.assertEqual("Error: Message queue myqueue creation failed.",
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_delete(self):
|
||||
@ -233,6 +235,6 @@ class MarconiMessageQueueTest(HeatTestCase):
|
||||
scheduler.TaskRunner(queue.update,
|
||||
new_queue))
|
||||
msg = 'The Resource MyQueue2 requires replacement.'
|
||||
self.assertEqual(msg, str(err))
|
||||
self.assertEqual(msg, six.text_type(err))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
@ -15,6 +15,7 @@
|
||||
import copy
|
||||
import json
|
||||
import mock
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from heat.common.exception import StackValidationFailed
|
||||
@ -401,7 +402,7 @@ class LoadBalancerTest(HeatTestCase):
|
||||
expected)
|
||||
|
||||
exc = self.assertRaises(StackValidationFailed, rsrc.validate)
|
||||
self.assertIn("Property certificate not assigned", str(exc))
|
||||
self.assertIn("Property certificate not assigned", six.text_type(exc))
|
||||
|
||||
ssl_termination['certificate'] = 'dfaewfwef'
|
||||
template = self._set_template(template,
|
||||
|
@ -11,6 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
@ -120,7 +121,7 @@ class CloudNetworkTest(HeatTestCase):
|
||||
self._parse_stack()
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
self.stack.validate)
|
||||
self.assertIn("Invalid cidr", str(exc))
|
||||
self.assertIn("Invalid cidr", six.text_type(exc))
|
||||
|
||||
def test_delete(self, mock_client):
|
||||
self._setup_stack(mock_client)
|
||||
@ -129,7 +130,7 @@ class CloudNetworkTest(HeatTestCase):
|
||||
scheduler.TaskRunner(res.delete)()
|
||||
self.assertEqual((res.DELETE, res.COMPLETE), res.state)
|
||||
exc = self.assertRaises(NotFound, self.fake_cnw.get, res_id)
|
||||
self.assertIn(res_id, str(exc))
|
||||
self.assertIn(res_id, six.text_type(exc))
|
||||
|
||||
def test_delete_not_complete(self, mock_client):
|
||||
self._setup_stack(mock_client)
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import mock
|
||||
import mox
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -169,7 +170,8 @@ class CloudServersTest(HeatTestCase):
|
||||
self.m.ReplayAll()
|
||||
create = scheduler.TaskRunner(server.create)
|
||||
exc = self.assertRaises(exception.ResourceFailure, create)
|
||||
self.assertEqual('Error: RackConnect automation FAILED', str(exc))
|
||||
self.assertEqual('Error: RackConnect automation FAILED',
|
||||
six.text_type(exc))
|
||||
|
||||
def test_rackconnect_unprocessable(self):
|
||||
return_server = self.fc.servers.list()[1]
|
||||
@ -200,7 +202,7 @@ class CloudServersTest(HeatTestCase):
|
||||
create = scheduler.TaskRunner(server.create)
|
||||
exc = self.assertRaises(exception.ResourceFailure, create)
|
||||
self.assertEqual('Error: Unknown RackConnect automation status: FOO',
|
||||
str(exc))
|
||||
six.text_type(exc))
|
||||
|
||||
def test_rackconnect_deploying(self):
|
||||
return_server = self.fc.servers.list()[0]
|
||||
@ -298,7 +300,8 @@ class CloudServersTest(HeatTestCase):
|
||||
self.m.ReplayAll()
|
||||
create = scheduler.TaskRunner(server.create)
|
||||
exc = self.assertRaises(exception.ResourceFailure, create)
|
||||
self.assertEqual('Error: Managed Cloud automation failed', str(exc))
|
||||
self.assertEqual('Error: Managed Cloud automation failed',
|
||||
six.text_type(exc))
|
||||
|
||||
def test_managed_cloud_unknown(self):
|
||||
return_server = self.fc.servers.list()[1]
|
||||
@ -312,7 +315,7 @@ class CloudServersTest(HeatTestCase):
|
||||
create = scheduler.TaskRunner(server.create)
|
||||
exc = self.assertRaises(exception.ResourceFailure, create)
|
||||
self.assertEqual('Error: Unknown Managed Cloud automation status: FOO',
|
||||
str(exc))
|
||||
six.text_type(exc))
|
||||
|
||||
@mock.patch.object(nova.NovaClientPlugin, '_create')
|
||||
@mock.patch.object(resource.Resource, 'data_set')
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
|
||||
import json
|
||||
import six
|
||||
|
||||
from oslo.config import cfg
|
||||
import requests
|
||||
@ -449,7 +450,7 @@ class Ec2TokenTest(HeatTestCase):
|
||||
self.m.ReplayAll()
|
||||
ex = self.assertRaises(exception.HeatInternalFailureError,
|
||||
ec2.__call__, dummy_req)
|
||||
self.assertEqual('Service misconfigured', str(ex))
|
||||
self.assertEqual('Service misconfigured', six.text_type(ex))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
@ -89,7 +89,7 @@ parameters:
|
||||
parse_ex = self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
stacks.InstantiationData.format_parse,
|
||||
bad_temp, 'foo')
|
||||
self.assertIn('line 4, column 3', str(parse_ex))
|
||||
self.assertIn('line 4, column 3', six.text_type(parse_ex))
|
||||
|
||||
def test_stack_name(self):
|
||||
body = {'stack_name': 'wibble'}
|
||||
@ -637,7 +637,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
req, tenant_id=self.tenant)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
@mock.patch.object(rpc_client.EngineClient, 'call')
|
||||
def test_index_rmt_interr(self, mock_call, mock_enforce):
|
||||
@ -846,7 +846,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
req, tenant_id=self.tenant, body=body)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_create_err_engine(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'create', True)
|
||||
@ -990,7 +990,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_name=stack_name)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_lookup_resource(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'lookup', True)
|
||||
@ -1054,7 +1054,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
path='resources')
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_show(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'show', True)
|
||||
@ -1162,7 +1162,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_id=identity.stack_id)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_show_err_denied_policy(self, mock_enforce):
|
||||
@ -1178,7 +1178,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_id=identity.stack_id)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_get_template(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'template', True)
|
||||
@ -1214,7 +1214,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_id=identity.stack_id)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_get_template_err_notfound(self, mock_enforce):
|
||||
@ -1334,7 +1334,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
body=body)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_delete(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'delete', True)
|
||||
@ -1370,7 +1370,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_id=identity.stack_id)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_abandon(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'abandon', True)
|
||||
@ -1406,7 +1406,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_id=identity.stack_id)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_delete_bad_name(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'delete', True)
|
||||
@ -1502,7 +1502,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
body=body)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_list_resource_types(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'list_resource_types', True)
|
||||
@ -1552,7 +1552,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
req, tenant_id=self.tenant)
|
||||
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_resource_schema(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'resource_schema', True)
|
||||
@ -1612,7 +1612,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
req, tenant_id=self.tenant,
|
||||
type_name=type_name)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_generate_template(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'generate_template', True)
|
||||
@ -1658,7 +1658,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
req, tenant_id=self.tenant,
|
||||
type_name='blah')
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
|
||||
class StackSerializerTest(HeatTestCase):
|
||||
@ -1814,7 +1814,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_name=stack_identity.stack_name,
|
||||
stack_id=stack_identity.stack_id)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_show(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'show', True)
|
||||
@ -2032,7 +2032,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_id=stack_identity.stack_id,
|
||||
resource_name=res_name)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_metadata_show(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'metadata', True)
|
||||
@ -2154,7 +2154,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_id=stack_identity.stack_id,
|
||||
resource_name=res_name)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_signal(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'signal', True)
|
||||
@ -2399,7 +2399,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_name=stack_identity.stack_name,
|
||||
stack_id=stack_identity.stack_id)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_index_resource_nonexist(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'index', True)
|
||||
@ -2764,7 +2764,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
|
||||
resource_name=res_name,
|
||||
event_id=event_id)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
|
||||
class RoutesTest(HeatTestCase):
|
||||
@ -3331,7 +3331,7 @@ class ActionControllerTest(ControllerTest, HeatTestCase):
|
||||
stack_id=stack_identity.stack_id,
|
||||
body=body)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
def test_action_badaction_ise(self, mock_enforce):
|
||||
self._mock_enforce_setup(mock_enforce, 'action', True)
|
||||
@ -3404,7 +3404,7 @@ class BuildInfoControllerTest(ControllerTest, HeatTestCase):
|
||||
self.controller.build_info,
|
||||
req, tenant_id=self.tenant)
|
||||
self.assertEqual(403, resp.status_int)
|
||||
self.assertIn('403 Forbidden', str(resp))
|
||||
self.assertIn('403 Forbidden', six.text_type(resp))
|
||||
|
||||
|
||||
class SoftwareConfigControllerTest(ControllerTest, HeatTestCase):
|
||||
|
@ -17,6 +17,7 @@ import datetime
|
||||
import mock
|
||||
import mox
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import short_id
|
||||
@ -860,7 +861,7 @@ class AutoScalingTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
"Error: Unsupported resource 'ElasticLoadBalancer' in "
|
||||
"LoadBalancerNames",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -1198,7 +1199,7 @@ class AutoScalingTest(HeatTestCase):
|
||||
self.assertIsNotNone(alarm_url)
|
||||
ex = self.assertRaises(exception.ResourceFailure, up_policy.signal)
|
||||
self.assertIn('Alarm WebServerScaleUpPolicy could '
|
||||
'not find scaling group', str(ex))
|
||||
'not find scaling group', six.text_type(ex))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -1633,7 +1634,7 @@ class AutoScalingTest(HeatTestCase):
|
||||
stack, 'WebServerGroup')
|
||||
|
||||
expected_msg = "The size of AutoScalingGroup can not be less than zero"
|
||||
self.assertEqual(expected_msg, str(e))
|
||||
self.assertEqual(expected_msg, six.text_type(e))
|
||||
|
||||
def test_invalid_max_size(self):
|
||||
t = template_format.parse(as_template)
|
||||
@ -1648,7 +1649,7 @@ class AutoScalingTest(HeatTestCase):
|
||||
stack, 'WebServerGroup')
|
||||
|
||||
expected_msg = "MinSize can not be greater than MaxSize"
|
||||
self.assertEqual(expected_msg, str(e))
|
||||
self.assertEqual(expected_msg, six.text_type(e))
|
||||
|
||||
def test_invalid_desiredcapacity(self):
|
||||
t = template_format.parse(as_template)
|
||||
@ -1664,7 +1665,7 @@ class AutoScalingTest(HeatTestCase):
|
||||
stack, 'WebServerGroup')
|
||||
|
||||
expected_msg = "DesiredCapacity must be between MinSize and MaxSize"
|
||||
self.assertEqual(expected_msg, str(e))
|
||||
self.assertEqual(expected_msg, six.text_type(e))
|
||||
|
||||
def test_invalid_desiredcapacity_zero(self):
|
||||
t = template_format.parse(as_template)
|
||||
@ -1680,7 +1681,7 @@ class AutoScalingTest(HeatTestCase):
|
||||
stack, 'WebServerGroup')
|
||||
|
||||
expected_msg = "DesiredCapacity must be between MinSize and MaxSize"
|
||||
self.assertEqual(expected_msg, str(e))
|
||||
self.assertEqual(expected_msg, six.text_type(e))
|
||||
|
||||
def test_child_template_uses_min_size(self):
|
||||
t = template_format.parse(as_template)
|
||||
|
@ -17,6 +17,7 @@ import json
|
||||
from ceilometerclient import exc as ceilometerclient_exc
|
||||
import mox
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -285,7 +286,7 @@ class CeilometerAlarmTest(HeatTestCase):
|
||||
rsrc.validate)
|
||||
self.assertEqual(
|
||||
"Property error : MEMAlarmHigh: %s Value '60a' is not an "
|
||||
"integer" % p, str(error))
|
||||
"integer" % p, six.text_type(error))
|
||||
|
||||
def test_mem_alarm_high_not_integer_parameters(self):
|
||||
snippet = template_format.parse(not_string_alarm_template)
|
||||
@ -300,7 +301,7 @@ class CeilometerAlarmTest(HeatTestCase):
|
||||
rsrc.validate)
|
||||
self.assertEqual(
|
||||
"Property error : MEMAlarmHigh: %s int() argument must be "
|
||||
"a string or a number, not 'list'" % p, str(error))
|
||||
"a string or a number, not 'list'" % p, six.text_type(error))
|
||||
|
||||
def test_mem_alarm_high_check_not_required_parameters(self):
|
||||
snippet = template_format.parse(not_string_alarm_template)
|
||||
@ -314,7 +315,7 @@ class CeilometerAlarmTest(HeatTestCase):
|
||||
rsrc.validate)
|
||||
self.assertEqual(
|
||||
"Property error : MEMAlarmHigh: Property meter_name not assigned",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
for p in ('period', 'evaluation_periods', 'statistic',
|
||||
'comparison_operator'):
|
||||
@ -389,7 +390,7 @@ class CombinationAlarmTest(HeatTestCase):
|
||||
rsrc.validate)
|
||||
self.assertEqual(
|
||||
"Property error : CombinAlarm: alarm_ids length (0) is out of "
|
||||
"range (min: 1, max: None)", str(error))
|
||||
"range (min: 1, max: None)", six.text_type(error))
|
||||
|
||||
def test_update(self):
|
||||
rsrc = self.create_alarm()
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from heat.common import exception
|
||||
@ -195,14 +196,16 @@ class SchemaTest(testtools.TestCase):
|
||||
constraints=[constraints.Range(1, 10)])
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
schema.validate)
|
||||
self.assertIn('Range constraint invalid for String', str(err))
|
||||
self.assertIn('Range constraint invalid for String',
|
||||
six.text_type(err))
|
||||
|
||||
def test_length_invalid_type(self):
|
||||
schema = constraints.Schema('Integer',
|
||||
constraints=[constraints.Length(1, 10)])
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
schema.validate)
|
||||
self.assertIn('Length constraint invalid for Integer', str(err))
|
||||
self.assertIn('Length constraint invalid for Integer',
|
||||
six.text_type(err))
|
||||
|
||||
def test_allowed_pattern_invalid_type(self):
|
||||
schema = constraints.Schema(
|
||||
@ -212,7 +215,7 @@ class SchemaTest(testtools.TestCase):
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
schema.validate)
|
||||
self.assertIn('AllowedPattern constraint invalid for Integer',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_range_vals_invalid_type(self):
|
||||
self.assertRaises(exception.InvalidSchemaError,
|
||||
@ -237,7 +240,8 @@ class SchemaTest(testtools.TestCase):
|
||||
default='wibble', required=True,
|
||||
constraints=[constraints.Range(max=4)])
|
||||
err = self.assertRaises(exception.InvalidSchemaError, s.validate)
|
||||
self.assertIn('Range constraint invalid for String', str(err))
|
||||
self.assertIn('Range constraint invalid for String',
|
||||
six.text_type(err))
|
||||
|
||||
def test_schema_nested_validate_good(self):
|
||||
nested = constraints.Schema(constraints.Schema.STRING, 'A string',
|
||||
@ -254,7 +258,8 @@ class SchemaTest(testtools.TestCase):
|
||||
s = constraints.Schema(constraints.Schema.MAP, 'A map',
|
||||
schema={'Foo': nested})
|
||||
err = self.assertRaises(exception.InvalidSchemaError, s.validate)
|
||||
self.assertIn('Range constraint invalid for String', str(err))
|
||||
self.assertIn('Range constraint invalid for String',
|
||||
six.text_type(err))
|
||||
|
||||
def test_allowed_values_numeric_int(self):
|
||||
'''
|
||||
@ -274,11 +279,13 @@ class SchemaTest(testtools.TestCase):
|
||||
self.assertIsNone(schema.validate_constraints(1))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, 3)
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]', str(err))
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]',
|
||||
six.text_type(err))
|
||||
self.assertIsNone(schema.validate_constraints('1'))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, '3')
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]', str(err))
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]',
|
||||
six.text_type(err))
|
||||
|
||||
# Allowed values defined as integer strings
|
||||
schema = constraints.Schema(
|
||||
@ -289,11 +296,13 @@ class SchemaTest(testtools.TestCase):
|
||||
self.assertIsNone(schema.validate_constraints(1))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, 3)
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]', str(err))
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]',
|
||||
six.text_type(err))
|
||||
self.assertIsNone(schema.validate_constraints('1'))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, '3')
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]', str(err))
|
||||
self.assertEqual('"3" is not an allowed value [1, 2, 4]',
|
||||
six.text_type(err))
|
||||
|
||||
def test_allowed_values_numeric_float(self):
|
||||
'''
|
||||
@ -314,12 +323,12 @@ class SchemaTest(testtools.TestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, 3.3)
|
||||
self.assertEqual('"3.3" is not an allowed value [1.1, 2.2, 4.4]',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
self.assertIsNone(schema.validate_constraints('1.1'))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, '3.3')
|
||||
self.assertEqual('"3.3" is not an allowed value [1.1, 2.2, 4.4]',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
# Allowed values defined as strings
|
||||
schema = constraints.Schema(
|
||||
@ -331,12 +340,12 @@ class SchemaTest(testtools.TestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, 3.3)
|
||||
self.assertEqual('"3.3" is not an allowed value [1.1, 2.2, 4.4]',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
self.assertIsNone(schema.validate_constraints('1.1'))
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
schema.validate_constraints, '3.3')
|
||||
self.assertEqual('"3.3" is not an allowed value [1.1, 2.2, 4.4]',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_to_schema_type_int(self):
|
||||
'''Test Schema.to_schema_type method for type Integer.'''
|
||||
@ -349,14 +358,14 @@ class SchemaTest(testtools.TestCase):
|
||||
# test invalid numeric values, i.e. floating point numbers
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 1.5)
|
||||
self.assertEqual('Value "1.5" is invalid for data type "Integer".',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, '1.5')
|
||||
self.assertEqual('Value "1.5" is invalid for data type "Integer".',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
# test invalid string values
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 'foo')
|
||||
self.assertEqual('Value "foo" is invalid for data type "Integer".',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_to_schema_type_num(self):
|
||||
'''Test Schema.to_schema_type method for type Number.'''
|
||||
@ -372,7 +381,7 @@ class SchemaTest(testtools.TestCase):
|
||||
self.assertEqual(1.5, res)
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 'foo')
|
||||
self.assertEqual('Value "foo" is invalid for data type "Number".',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_to_schema_type_string(self):
|
||||
'''Test Schema.to_schema_type method for type String.'''
|
||||
@ -383,7 +392,7 @@ class SchemaTest(testtools.TestCase):
|
||||
self.assertIsInstance(res, basestring)
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 1)
|
||||
self.assertEqual('Value "1" is invalid for data type "String".',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_to_schema_type_boolean(self):
|
||||
'''Test Schema.to_schema_type method for type Boolean.'''
|
||||
@ -403,7 +412,7 @@ class SchemaTest(testtools.TestCase):
|
||||
|
||||
err = self.assertRaises(ValueError, schema.to_schema_type, 'foo')
|
||||
self.assertEqual('Value "foo" is invalid for data type "Boolean".',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_to_schema_type_map(self):
|
||||
'''Test Schema.to_schema_type method for type Map.'''
|
||||
@ -434,10 +443,12 @@ class CustomConstraintTest(testtools.TestCase):
|
||||
self.env.register_constraint("zero", ZeroConstraint)
|
||||
|
||||
constraint = constraints.CustomConstraint("zero", environment=self.env)
|
||||
self.assertEqual("Value must be of type zero", str(constraint))
|
||||
self.assertEqual("Value must be of type zero",
|
||||
six.text_type(constraint))
|
||||
self.assertIsNone(constraint.validate(0))
|
||||
error = self.assertRaises(ValueError, constraint.validate, 1)
|
||||
self.assertEqual('"1" does not validate zero', str(error))
|
||||
self.assertEqual('"1" does not validate zero',
|
||||
six.text_type(error))
|
||||
|
||||
def test_custom_error(self):
|
||||
class ZeroConstraint(object):
|
||||
@ -452,7 +463,7 @@ class CustomConstraintTest(testtools.TestCase):
|
||||
|
||||
constraint = constraints.CustomConstraint("zero", environment=self.env)
|
||||
error = self.assertRaises(ValueError, constraint.validate, 1)
|
||||
self.assertEqual("1 is not 0", str(error))
|
||||
self.assertEqual("1 is not 0", six.text_type(error))
|
||||
|
||||
def test_custom_message(self):
|
||||
class ZeroConstraint(object):
|
||||
@ -464,13 +475,13 @@ class CustomConstraintTest(testtools.TestCase):
|
||||
self.env.register_constraint("zero", ZeroConstraint)
|
||||
|
||||
constraint = constraints.CustomConstraint("zero", environment=self.env)
|
||||
self.assertEqual("Only zero!", str(constraint))
|
||||
self.assertEqual("Only zero!", six.text_type(constraint))
|
||||
|
||||
def test_unknown_constraint(self):
|
||||
constraint = constraints.CustomConstraint("zero", environment=self.env)
|
||||
error = self.assertRaises(ValueError, constraint.validate, 1)
|
||||
self.assertEqual('"1" does not validate zero (constraint not found)',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
def test_constraints(self):
|
||||
class ZeroConstraint(object):
|
||||
|
@ -25,6 +25,7 @@ from oslo import messaging
|
||||
from oslo.messaging.rpc import client as rpc_client
|
||||
from oslo.messaging.rpc import dispatcher
|
||||
from oslotest import mockpatch
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import identifier
|
||||
@ -481,7 +482,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
self._test_stack_create, stack_name)
|
||||
self.assertEqual(ex.exc_info[0], exception.RequestLimitExceeded)
|
||||
self.assertIn("You have reached the maximum stacks per tenant",
|
||||
str(ex.exc_info[1]))
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
def test_stack_create_verify_err(self):
|
||||
stack_name = 'service_create_verify_err_test_stack'
|
||||
@ -568,7 +569,8 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
template, params, None, {})
|
||||
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError)
|
||||
self.assertEqual(
|
||||
'Missing required credential: X-Auth-Key', str(ex.exc_info[1]))
|
||||
'Missing required credential: X-Auth-Key',
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
ex = self.assertRaises(dispatcher.ExpectedException,
|
||||
self.man.create_stack,
|
||||
@ -576,7 +578,8 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
template, params, None, {})
|
||||
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError)
|
||||
self.assertEqual(
|
||||
'Missing required credential: X-Auth-User', str(ex.exc_info[1]))
|
||||
'Missing required credential: X-Auth-User',
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
def test_stack_create_total_resources_equals_max(self):
|
||||
stack_name = 'service_create_stack_total_resources_equals_max'
|
||||
@ -631,7 +634,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
tpl, params, None, {})
|
||||
self.assertEqual(ex.exc_info[0], exception.RequestLimitExceeded)
|
||||
self.assertIn(exception.StackResourceLimitExceeded.msg_fmt,
|
||||
str(ex.exc_info[1]))
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
def test_stack_validate(self):
|
||||
stack_name = 'service_create_test_validate'
|
||||
@ -1088,7 +1091,7 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
None, {})
|
||||
self.assertEqual(ex.exc_info[0], exception.RequestLimitExceeded)
|
||||
self.assertIn(exception.StackResourceLimitExceeded.msg_fmt,
|
||||
str(ex.exc_info[1]))
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
def test_stack_update_verify_err(self):
|
||||
stack_name = 'service_update_verify_err_test_stack'
|
||||
@ -1183,7 +1186,8 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
template, params, None, api_args)
|
||||
self.assertEqual(ex.exc_info[0], exception.MissingCredentialError)
|
||||
self.assertEqual(
|
||||
'Missing required credential: X-Auth-Key', str(ex.exc_info[1]))
|
||||
'Missing required credential: X-Auth-Key',
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -1216,14 +1220,16 @@ class StackServiceCreateUpdateDeleteTest(HeatTestCase):
|
||||
ex = self.assertRaises(exception.MissingCredentialError,
|
||||
self.man._validate_deferred_auth_context,
|
||||
ctx, stack)
|
||||
self.assertEqual('Missing required credential: X-Auth-User', str(ex))
|
||||
self.assertEqual('Missing required credential: X-Auth-User',
|
||||
six.text_type(ex))
|
||||
|
||||
# missing password
|
||||
ctx = utils.dummy_context(password=None)
|
||||
ex = self.assertRaises(exception.MissingCredentialError,
|
||||
self.man._validate_deferred_auth_context,
|
||||
ctx, stack)
|
||||
self.assertEqual('Missing required credential: X-Auth-Key', str(ex))
|
||||
self.assertEqual('Missing required credential: X-Auth-Key',
|
||||
six.text_type(ex))
|
||||
|
||||
|
||||
class StackServiceUpdateSuspendedNotSupportedTest(HeatTestCase):
|
||||
|
@ -17,6 +17,7 @@ import sys
|
||||
import fixtures
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
|
||||
from heat.common import environment_format
|
||||
from heat.engine import environment
|
||||
@ -151,7 +152,7 @@ def constraint_mapping():
|
||||
env = environment.Environment({})
|
||||
error = self.assertRaises(ValueError,
|
||||
resources._load_global_environment, env)
|
||||
self.assertEqual("oops", str(error))
|
||||
self.assertEqual("oops", six.text_type(error))
|
||||
|
||||
def test_constraints_registry_stevedore(self):
|
||||
env = environment.Environment({})
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import six
|
||||
|
||||
from heat.engine import function
|
||||
from heat.tests.common import HeatTestCase
|
||||
@ -97,7 +98,7 @@ class ValidateTest(HeatTestCase):
|
||||
self.assertIsNone(function.validate(self.func))
|
||||
self.func = TestFunction(None, 'foo', ['bar'])
|
||||
ex = self.assertRaises(Exception, function.validate, self.func)
|
||||
self.assertEqual('Need more arguments', str(ex))
|
||||
self.assertEqual('Need more arguments', six.text_type(ex))
|
||||
|
||||
def test_validate_dict(self):
|
||||
snippet = {'foo': 'bar', 'blarg': self.func}
|
||||
@ -106,7 +107,7 @@ class ValidateTest(HeatTestCase):
|
||||
self.func = TestFunction(None, 'foo', ['bar'])
|
||||
snippet = {'foo': 'bar', 'blarg': self.func}
|
||||
ex = self.assertRaises(Exception, function.validate, snippet)
|
||||
self.assertEqual('Need more arguments', str(ex))
|
||||
self.assertEqual('Need more arguments', six.text_type(ex))
|
||||
|
||||
def test_validate_list(self):
|
||||
snippet = ['foo', 'bar', 'baz', 'blarg', self.func]
|
||||
@ -115,7 +116,7 @@ class ValidateTest(HeatTestCase):
|
||||
self.func = TestFunction(None, 'foo', ['bar'])
|
||||
snippet = {'foo': 'bar', 'blarg': self.func}
|
||||
ex = self.assertRaises(Exception, function.validate, snippet)
|
||||
self.assertEqual('Need more arguments', str(ex))
|
||||
self.assertEqual('Need more arguments', six.text_type(ex))
|
||||
|
||||
def test_validate_all(self):
|
||||
snippet = ['foo', {'bar': ['baz', {'blarg': self.func}]}]
|
||||
@ -124,7 +125,7 @@ class ValidateTest(HeatTestCase):
|
||||
self.func = TestFunction(None, 'foo', ['bar'])
|
||||
snippet = {'foo': 'bar', 'blarg': self.func}
|
||||
ex = self.assertRaises(Exception, function.validate, snippet)
|
||||
self.assertEqual('Need more arguments', str(ex))
|
||||
self.assertEqual('Need more arguments', six.text_type(ex))
|
||||
|
||||
|
||||
class DependenciesTest(HeatTestCase):
|
||||
|
@ -11,6 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from glanceclient import exc as glance_exceptions
|
||||
@ -86,7 +87,7 @@ class GlanceUtilsTests(HeatTestCase):
|
||||
e = self.assertRaises(exception.Error,
|
||||
self.glance_plugin.get_image_id_by_name,
|
||||
img_name)
|
||||
self.assertEqual(expected_error, str(e))
|
||||
self.assertEqual(expected_error, six.text_type(e))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_get_image_id_not_found(self):
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import json
|
||||
import mox
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from keystoneclient.auth.identity import v3 as ks_auth_v3
|
||||
@ -199,7 +200,7 @@ class KeystoneClientTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.Error,
|
||||
heat_ks_client.create_stack_user,
|
||||
'auser', password='password')
|
||||
self.assertIn('Can\'t find role heat_stack_user', str(err))
|
||||
self.assertIn('Can\'t find role heat_stack_user', six.text_type(err))
|
||||
|
||||
def _mock_roles_list(self, heat_stack_user='heat_stack_user'):
|
||||
mock_roles_list = []
|
||||
@ -283,7 +284,7 @@ class KeystoneClientTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.Error,
|
||||
heat_ks_client.create_stack_domain_user,
|
||||
username='duser', project_id='aproject')
|
||||
self.assertIn('Can\'t find role heat_stack_user', str(err))
|
||||
self.assertIn('Can\'t find role heat_stack_user', six.text_type(err))
|
||||
|
||||
def test_delete_stack_domain_user(self):
|
||||
"""Test deleting a stack domain user."""
|
||||
@ -555,7 +556,7 @@ class KeystoneClientTest(HeatTestCase):
|
||||
'"stack_user_domain_id" or "stack_user_domain_name" '
|
||||
'without "stack_domain_admin" and '
|
||||
'"stack_domain_admin_password"')
|
||||
self.assertIn(exp_msg, str(err))
|
||||
self.assertIn(exp_msg, six.text_type(err))
|
||||
|
||||
def test_init_admin_client(self):
|
||||
|
||||
|
@ -178,7 +178,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.RESOURCES)
|
||||
self.assertEqual('u\'"Type" is not a valid keyword '
|
||||
'inside a resource definition\'',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_translate_resources_bad_properties(self):
|
||||
"""Test translation of resources including invalid keyword."""
|
||||
@ -202,7 +202,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.RESOURCES)
|
||||
self.assertEqual('u\'"Properties" is not a valid keyword '
|
||||
'inside a resource definition\'',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_translate_resources_bad_metadata(self):
|
||||
"""Test translation of resources including invalid keyword."""
|
||||
@ -226,7 +226,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.RESOURCES)
|
||||
self.assertEqual('u\'"Metadata" is not a valid keyword '
|
||||
'inside a resource definition\'',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_translate_resources_bad_depends_on(self):
|
||||
"""Test translation of resources including invalid keyword."""
|
||||
@ -250,7 +250,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.RESOURCES)
|
||||
self.assertEqual('u\'"DependsOn" is not a valid keyword '
|
||||
'inside a resource definition\'',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_translate_resources_bad_deletion_polciy(self):
|
||||
"""Test translation of resources including invalid keyword."""
|
||||
@ -274,7 +274,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.RESOURCES)
|
||||
self.assertEqual('u\'"DeletionPolicy" is not a valid keyword '
|
||||
'inside a resource definition\'',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_translate_resources_bad_update_policy(self):
|
||||
"""Test translation of resources including invalid keyword."""
|
||||
@ -298,7 +298,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.RESOURCES)
|
||||
self.assertEqual('u\'"UpdatePolicy" is not a valid keyword '
|
||||
'inside a resource definition\'',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_translate_outputs_good(self):
|
||||
"""Test translation of outputs into internal engine format."""
|
||||
@ -329,7 +329,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
|
||||
tmpl = parser.Template(hot_tpl)
|
||||
err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.OUTPUTS)
|
||||
self.assertIn('Description', str(err))
|
||||
self.assertIn('Description', six.text_type(err))
|
||||
|
||||
def test_translate_outputs_bad_value(self):
|
||||
"""Test translation of outputs into internal engine format."""
|
||||
@ -344,7 +344,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
|
||||
tmpl = parser.Template(hot_tpl)
|
||||
err = self.assertRaises(KeyError, tmpl.__getitem__, tmpl.OUTPUTS)
|
||||
self.assertIn('Value', str(err))
|
||||
self.assertIn('Value', six.text_type(err))
|
||||
|
||||
def test_str_replace(self):
|
||||
"""Test str_replace function."""
|
||||
@ -610,7 +610,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
self.resolve,
|
||||
snippet,
|
||||
stack.t, stack)
|
||||
self.assertIn(snippet.keys()[0], str(error))
|
||||
self.assertIn(snippet.keys()[0], six.text_type(error))
|
||||
|
||||
def test_resource_facade_missing_deletion_policy(self):
|
||||
snippet = {'resource_facade': 'deletion_policy'}
|
||||
@ -633,7 +633,7 @@ class HOTemplateTest(HeatTestCase):
|
||||
error = self.assertRaises(exception.InvalidTemplateVersion,
|
||||
function.validate,
|
||||
stack.t.parse(stack, snippet))
|
||||
self.assertIn(snippet.keys()[0], str(error))
|
||||
self.assertIn(snippet.keys()[0], six.text_type(error))
|
||||
|
||||
def test_add_resource(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -960,7 +960,7 @@ class StackGetAttrValidationTest(HeatTestCase):
|
||||
try:
|
||||
stack.validate()
|
||||
except exception.StackValidationFailed as exc:
|
||||
self.fail("Validation should have passed: %s" % str(exc))
|
||||
self.fail("Validation should have passed: %s" % six.text_type(exc))
|
||||
self.assertEqual([],
|
||||
stack.resources['resource2'].properties['a_list'])
|
||||
self.assertEqual({},
|
||||
@ -1088,19 +1088,19 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
|
||||
value = 'wp'
|
||||
err = self.assertRaises(exception.StackValidationFailed, v, value)
|
||||
self.assertIn(len_desc, str(err))
|
||||
self.assertIn(len_desc, six.text_type(err))
|
||||
|
||||
value = 'abcdefghijklmnopq'
|
||||
err = self.assertRaises(exception.StackValidationFailed, v, value)
|
||||
self.assertIn(len_desc, str(err))
|
||||
self.assertIn(len_desc, six.text_type(err))
|
||||
|
||||
value = 'abcdefgh1'
|
||||
err = self.assertRaises(exception.StackValidationFailed, v, value)
|
||||
self.assertIn(pattern_desc1, str(err))
|
||||
self.assertIn(pattern_desc1, six.text_type(err))
|
||||
|
||||
value = 'Abcdefghi'
|
||||
err = self.assertRaises(exception.StackValidationFailed, v, value)
|
||||
self.assertIn(pattern_desc2, str(err))
|
||||
self.assertIn(pattern_desc2, six.text_type(err))
|
||||
|
||||
value = 'abcdefghi'
|
||||
self.assertTrue(v(value))
|
||||
@ -1138,22 +1138,22 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
value = 'wp'
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
run_parameters, value)
|
||||
self.assertIn(len_desc, str(err))
|
||||
self.assertIn(len_desc, six.text_type(err))
|
||||
|
||||
value = 'abcdefghijklmnopq'
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
run_parameters, value)
|
||||
self.assertIn(len_desc, str(err))
|
||||
self.assertIn(len_desc, six.text_type(err))
|
||||
|
||||
value = 'abcdefgh1'
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
run_parameters, value)
|
||||
self.assertIn(pattern_desc1, str(err))
|
||||
self.assertIn(pattern_desc1, six.text_type(err))
|
||||
|
||||
value = 'Abcdefghi'
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
run_parameters, value)
|
||||
self.assertIn(pattern_desc2, str(err))
|
||||
self.assertIn(pattern_desc2, six.text_type(err))
|
||||
|
||||
value = 'abcdefghi'
|
||||
self.assertTrue(run_parameters(value))
|
||||
@ -1183,11 +1183,11 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
|
||||
value = 29999
|
||||
err = self.assertRaises(exception.StackValidationFailed, v, value)
|
||||
self.assertIn(range_desc, str(err))
|
||||
self.assertIn(range_desc, six.text_type(err))
|
||||
|
||||
value = 50001
|
||||
err = self.assertRaises(exception.StackValidationFailed, v, value)
|
||||
self.assertIn(range_desc, str(err))
|
||||
self.assertIn(range_desc, six.text_type(err))
|
||||
|
||||
value = 30000
|
||||
self.assertTrue(v(value))
|
||||
@ -1226,11 +1226,11 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
|
||||
value = "1"
|
||||
err = self.assertRaises(exception.StackValidationFailed, v, value)
|
||||
self.assertEqual(desc, str(err))
|
||||
self.assertEqual(desc, six.text_type(err))
|
||||
|
||||
value = "2"
|
||||
err = self.assertRaises(exception.StackValidationFailed, v, value)
|
||||
self.assertEqual(desc, str(err))
|
||||
self.assertEqual(desc, six.text_type(err))
|
||||
|
||||
value = "0"
|
||||
self.assertTrue(v(value))
|
||||
@ -1250,7 +1250,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
param['db_port'])
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
schema.validate)
|
||||
self.assertIn(range_desc, str(err))
|
||||
self.assertIn(range_desc, six.text_type(err))
|
||||
|
||||
def test_validate_schema_wrong_key(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1263,7 +1263,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual("Invalid key 'foo' for parameter (param1)",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
def test_validate_schema_no_type(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1276,7 +1276,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual("Missing parameter type for parameter: param1",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
def test_validate_schema_unknown_type(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1289,7 +1289,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"Invalid type (Unicode)", str(error))
|
||||
"Invalid type (Unicode)", six.text_type(error))
|
||||
|
||||
def test_validate_schema_constraints(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1306,7 +1306,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"Invalid key 'allowed_valus' for parameter constraints",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
def test_validate_schema_constraints_not_list(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1322,7 +1322,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"Invalid parameter constraints for parameter param1, "
|
||||
"expected a list", str(error))
|
||||
"expected a list", six.text_type(error))
|
||||
|
||||
def test_validate_schema_constraints_not_mapping(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1337,7 +1337,8 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"Invalid parameter constraints, expected a mapping", str(error))
|
||||
"Invalid parameter constraints, expected a mapping",
|
||||
six.text_type(error))
|
||||
|
||||
def test_validate_schema_empty_constraints(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1352,7 +1353,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
error = self.assertRaises(
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual("No constraint expressed", str(error))
|
||||
self.assertEqual("No constraint expressed", six.text_type(error))
|
||||
|
||||
def test_validate_schema_constraints_range_wrong_format(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1368,7 +1369,8 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"Invalid range constraint, expected a mapping", str(error))
|
||||
"Invalid range constraint, expected a mapping",
|
||||
six.text_type(error))
|
||||
|
||||
def test_validate_schema_constraints_range_invalid_key(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1384,7 +1386,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"Invalid key 'foo' for range constraint", str(error))
|
||||
"Invalid key 'foo' for range constraint", six.text_type(error))
|
||||
|
||||
def test_validate_schema_constraints_length_wrong_format(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1400,7 +1402,8 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"Invalid length constraint, expected a mapping", str(error))
|
||||
"Invalid length constraint, expected a mapping",
|
||||
six.text_type(error))
|
||||
|
||||
def test_validate_schema_constraints_length_invalid_key(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1416,7 +1419,7 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"Invalid key 'foo' for length constraint", str(error))
|
||||
"Invalid key 'foo' for length constraint", six.text_type(error))
|
||||
|
||||
def test_validate_schema_constraints_wrong_allowed_pattern(self):
|
||||
hot_tpl = template_format.parse('''
|
||||
@ -1432,4 +1435,4 @@ class HOTParamValidatorTest(HeatTestCase):
|
||||
exception.InvalidSchemaError, parameters.Parameters,
|
||||
"stack_testit", parser.Template(hot_tpl))
|
||||
self.assertEqual(
|
||||
"AllowedPattern must be a string", str(error))
|
||||
"AllowedPattern must be a string", six.text_type(error))
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from glanceclient import exc as glance_exceptions
|
||||
@ -187,7 +188,7 @@ class InstancesTest(HeatTestCase):
|
||||
'StackValidationFailed: Property error : WebServer: '
|
||||
'ImageId Error validating value \'Slackware\': '
|
||||
'The Image (Slackware) could not be found.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -214,7 +215,7 @@ class InstancesTest(HeatTestCase):
|
||||
'StackValidationFailed: Property error : WebServer: '
|
||||
'ImageId Multiple physical resources were '
|
||||
'found with name (CentOS 5.2).',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -237,7 +238,7 @@ class InstancesTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
'StackValidationFailed: Property error : WebServer: '
|
||||
'ImageId 404 (HTTP 404)',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -290,7 +291,7 @@ class InstancesTest(HeatTestCase):
|
||||
(return_server, self.FakeVolumeAttach()))
|
||||
self.assertEqual(
|
||||
'Creation of server sample-server2 failed: Unknown (500)',
|
||||
str(e))
|
||||
six.text_type(e))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -429,7 +430,7 @@ class InstancesTest(HeatTestCase):
|
||||
error = self.assertRaises(exception.ResourceFailure, updater)
|
||||
self.assertEqual(
|
||||
"Error: Resizing to 'm1.small' failed, status 'ACTIVE'",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((instance.UPDATE, instance.FAILED), instance.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import copy
|
||||
import json
|
||||
import six
|
||||
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
@ -379,7 +380,7 @@ Outputs:
|
||||
ex = self.assertRaises(exception.RequestLimitExceeded,
|
||||
rsrc.handle_update, new_res, {}, prop_diff)
|
||||
self.assertIn(exception.StackResourceLimitExceeded.msg_fmt,
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
rsrc.delete()
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import six
|
||||
|
||||
import mock
|
||||
import mox
|
||||
@ -1528,7 +1529,7 @@ class NeutronRouterTest(HeatTestCase):
|
||||
stack)
|
||||
ex = self.assertRaises(exception.StackValidationFailed, res.validate)
|
||||
self.assertEqual("Either subnet or port_id must be specified.",
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
|
||||
def test_gateway_router(self):
|
||||
neutron_utils.neutronV20.find_resourceid_by_name_or_id(
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import six
|
||||
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
|
||||
@ -130,7 +131,7 @@ class FirewallTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -168,7 +169,7 @@ class FirewallTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -192,7 +193,7 @@ class FirewallTest(HeatTestCase):
|
||||
rsrc.FnGetAtt, 'subnet_id')
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (firewall subnet_id) is '
|
||||
'incorrect.', str(error))
|
||||
'incorrect.', six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
@ -257,7 +258,7 @@ class FirewallPolicyTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -295,7 +296,7 @@ class FirewallPolicyTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -318,7 +319,7 @@ class FirewallPolicyTest(HeatTestCase):
|
||||
rsrc.FnGetAtt, 'subnet_id')
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (firewall_policy subnet_id) is '
|
||||
'incorrect.', str(error))
|
||||
'incorrect.', six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
@ -385,7 +386,7 @@ class FirewallRuleTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -423,7 +424,7 @@ class FirewallRuleTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -446,7 +447,7 @@ class FirewallRuleTest(HeatTestCase):
|
||||
rsrc.FnGetAtt, 'subnet_id')
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (firewall_rule subnet_id) is '
|
||||
'incorrect.', str(error))
|
||||
'incorrect.', six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import copy
|
||||
import mox
|
||||
import six
|
||||
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
|
||||
@ -264,7 +265,7 @@ class HealthMonitorTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -302,7 +303,7 @@ class HealthMonitorTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -325,7 +326,7 @@ class HealthMonitorTest(HeatTestCase):
|
||||
rsrc.FnGetAtt, 'subnet_id')
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (monitor subnet_id) is incorrect.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
@ -506,7 +507,7 @@ class PoolTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
'Error: neutron reported unexpected pool '
|
||||
'resource[5678] status[ERROR]',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -545,7 +546,7 @@ class PoolTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
'Error: neutron reported unexpected vip '
|
||||
'resource[xyz] status[ERROR]',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -573,7 +574,7 @@ class PoolTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -630,7 +631,7 @@ class PoolTest(HeatTestCase):
|
||||
|
||||
error = self.assertRaises(exception.StackValidationFailed,
|
||||
resource.validate)
|
||||
self.assertEqual(msg, str(error))
|
||||
self.assertEqual(msg, six.text_type(error))
|
||||
|
||||
def test_validation_not_failing_without_session_persistence(self):
|
||||
snippet = template_format.parse(pool_template)
|
||||
@ -726,7 +727,7 @@ class PoolTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -743,7 +744,7 @@ class PoolTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -776,7 +777,7 @@ class PoolTest(HeatTestCase):
|
||||
rsrc.FnGetAtt, 'net_id')
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (pool net_id) is incorrect.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -100,7 +101,7 @@ class MeteringLabelTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -138,7 +139,7 @@ class MeteringLabelTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -213,7 +214,7 @@ class MeteringRuleTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -251,7 +252,7 @@ class MeteringRuleTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
@ -18,6 +18,7 @@ import mox
|
||||
from mox import IgnoreArg
|
||||
from neutronclient.common import exceptions as qe
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -456,7 +457,7 @@ class NeutronNetworkGatewayTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.assertIsNone(scheduler.TaskRunner(rsrc.delete)())
|
||||
self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
|
||||
@ -480,7 +481,7 @@ class NeutronNetworkGatewayTest(HeatTestCase):
|
||||
|
||||
self.assertEqual(
|
||||
'segmentation_id must be specified for using vlan',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -501,7 +502,7 @@ class NeutronNetworkGatewayTest(HeatTestCase):
|
||||
|
||||
self.assertEqual(
|
||||
'segmentation_id cannot be specified except 0 for using flat',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -521,6 +522,6 @@ class NeutronNetworkGatewayTest(HeatTestCase):
|
||||
rsrc.FnGetAtt, 'hoge')
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (test_network_gateway hoge) is '
|
||||
'incorrect.', str(error))
|
||||
'incorrect.', six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
@ -14,6 +14,7 @@
|
||||
import copy
|
||||
import mox
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -223,7 +224,7 @@ class VPNServiceTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -258,7 +259,7 @@ class VPNServiceTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -284,7 +285,7 @@ class VPNServiceTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (vpnservice non-existent_property) is '
|
||||
'incorrect.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
@ -370,7 +371,7 @@ class IPsecSiteConnectionTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -405,7 +406,7 @@ class IPsecSiteConnectionTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -441,7 +442,7 @@ class IPsecSiteConnectionTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (ipsec_site_connection '
|
||||
'non-existent_property) is incorrect.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
@ -516,7 +517,7 @@ class IKEPolicyTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -551,7 +552,7 @@ class IKEPolicyTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -581,7 +582,7 @@ class IKEPolicyTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (ikepolicy non-existent_property) is '
|
||||
'incorrect.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
@ -657,7 +658,7 @@ class IPsecPolicyTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.create))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -692,7 +693,7 @@ class IPsecPolicyTest(HeatTestCase):
|
||||
scheduler.TaskRunner(rsrc.delete))
|
||||
self.assertEqual(
|
||||
'NeutronClientException: An unknown exception occurred.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -722,7 +723,7 @@ class IPsecPolicyTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (ipsecpolicy non-existent_property) is '
|
||||
'incorrect.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_update(self):
|
||||
|
@ -14,6 +14,7 @@
|
||||
"""Tests for :module:'heat.engine.resources.nova_utls'."""
|
||||
|
||||
import mock
|
||||
import six
|
||||
import uuid
|
||||
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
@ -119,7 +120,8 @@ class NovaUtilsTests(HeatTestCase):
|
||||
}
|
||||
task = scheduler.TaskRunner(nova_utils.delete_server, server)
|
||||
err = self.assertRaises(exception.Error, task)
|
||||
self.assertIn("myserver delete failed: (None) test error", str(err))
|
||||
self.assertIn("myserver delete failed: (None) test error",
|
||||
six.text_type(err))
|
||||
|
||||
|
||||
class NovaUtilsRefreshServerTests(HeatTestCase):
|
||||
|
@ -12,6 +12,7 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import six
|
||||
|
||||
import testtools
|
||||
|
||||
@ -76,7 +77,7 @@ class ParameterTest(testtools.TestCase):
|
||||
'Default': 'bar'}
|
||||
err = self.assertRaises(exception.InvalidSchemaError,
|
||||
self.new_parameter, 'p', schema, 'foo')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_no_echo_true(self):
|
||||
p = self.new_parameter('anechoic',
|
||||
@ -126,7 +127,7 @@ class ParameterTest(testtools.TestCase):
|
||||
'MinLength': '4'}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, 'foo')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_string_overflow(self):
|
||||
schema = {'Type': 'String',
|
||||
@ -134,7 +135,7 @@ class ParameterTest(testtools.TestCase):
|
||||
'MaxLength': '2'}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, 'foo')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_string_pattern_good(self):
|
||||
schema = {'Type': 'String',
|
||||
@ -148,7 +149,7 @@ class ParameterTest(testtools.TestCase):
|
||||
'AllowedPattern': '[a-z]*'}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, '1foo')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_string_pattern_bad_suffix(self):
|
||||
schema = {'Type': 'String',
|
||||
@ -156,7 +157,7 @@ class ParameterTest(testtools.TestCase):
|
||||
'AllowedPattern': '[a-z]*'}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, 'foo1')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_string_value_list_good(self):
|
||||
schema = {'Type': 'String',
|
||||
@ -175,7 +176,7 @@ class ParameterTest(testtools.TestCase):
|
||||
'AllowedValues': ['foo', 'bar', 'baz']}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, 'blarg')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_number_int_good(self):
|
||||
schema = {'Type': 'Number',
|
||||
@ -204,7 +205,7 @@ class ParameterTest(testtools.TestCase):
|
||||
'MinValue': '4'}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, '3')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_number_high(self):
|
||||
schema = {'Type': 'Number',
|
||||
@ -212,13 +213,13 @@ class ParameterTest(testtools.TestCase):
|
||||
'MaxValue': '2'}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, '3')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_number_bad(self):
|
||||
schema = {'Type': 'Number'}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, 'str')
|
||||
self.assertIn('float', str(err))
|
||||
self.assertIn('float', six.text_type(err))
|
||||
|
||||
def test_number_value_list_good(self):
|
||||
schema = {'Type': 'Number',
|
||||
@ -232,7 +233,7 @@ class ParameterTest(testtools.TestCase):
|
||||
'AllowedValues': ['1', '3', '5']}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, '2')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_list_value_list_default_empty(self):
|
||||
schema = {'Type': 'CommaDelimitedList'}
|
||||
@ -259,7 +260,7 @@ class ParameterTest(testtools.TestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema,
|
||||
'foo,baz,blarg')
|
||||
self.assertIn('wibble', str(err))
|
||||
self.assertIn('wibble', six.text_type(err))
|
||||
|
||||
def test_map_value(self):
|
||||
'''Happy path for value that's already a map.'''
|
||||
@ -276,7 +277,7 @@ class ParameterTest(testtools.TestCase):
|
||||
val = {"foo": "bar", "not_json": len}
|
||||
err = self.assertRaises(ValueError,
|
||||
self.new_parameter, 'p', schema, val)
|
||||
self.assertIn('Value must be valid JSON', str(err))
|
||||
self.assertIn('Value must be valid JSON', six.text_type(err))
|
||||
|
||||
def test_map_value_parse(self):
|
||||
'''Happy path for value that's a string.'''
|
||||
@ -294,7 +295,7 @@ class ParameterTest(testtools.TestCase):
|
||||
val = "I am not a map"
|
||||
err = self.assertRaises(ValueError,
|
||||
self.new_parameter, 'p', schema, val)
|
||||
self.assertIn('Value must be valid JSON', str(err))
|
||||
self.assertIn('Value must be valid JSON', six.text_type(err))
|
||||
|
||||
def test_map_underrun(self):
|
||||
'''Test map length under MIN_LEN.'''
|
||||
@ -303,7 +304,7 @@ class ParameterTest(testtools.TestCase):
|
||||
val = {"foo": "bar", "items": [1, 2, 3]}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, val)
|
||||
self.assertIn('out of range', str(err))
|
||||
self.assertIn('out of range', six.text_type(err))
|
||||
|
||||
def test_map_overrun(self):
|
||||
'''Test map length over MAX_LEN.'''
|
||||
@ -312,7 +313,7 @@ class ParameterTest(testtools.TestCase):
|
||||
val = {"foo": "bar", "items": [1, 2, 3]}
|
||||
err = self.assertRaises(exception.StackValidationFailed,
|
||||
self.new_parameter, 'p', schema, val)
|
||||
self.assertIn('out of range', str(err))
|
||||
self.assertIn('out of range', six.text_type(err))
|
||||
|
||||
def test_bool_value_true(self):
|
||||
schema = {'Type': 'Boolean'}
|
||||
@ -482,7 +483,7 @@ class ParameterSchemaTest(testtools.TestCase):
|
||||
parameters.Schema.from_dict, 'param_name',
|
||||
{"foo": "bar"})
|
||||
self.assertEqual("Invalid key 'foo' for parameter (param_name)",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
def test_validate_schema_no_type(self):
|
||||
error = self.assertRaises(exception.InvalidSchemaError,
|
||||
@ -490,4 +491,4 @@ class ParameterSchemaTest(testtools.TestCase):
|
||||
'broken',
|
||||
{"Description": "Hi!"})
|
||||
self.assertEqual("Missing parameter type for parameter: broken",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
@ -204,7 +204,7 @@ class TemplateTest(HeatTestCase):
|
||||
'"heat_template_version: 2012-12-12". '
|
||||
'"heat_template_version" should be one of: %s'
|
||||
% ', '.join(valid_versions))
|
||||
self.assertEqual(ex_error_msg, str(init_ex))
|
||||
self.assertEqual(ex_error_msg, six.text_type(init_ex))
|
||||
|
||||
def test_invalid_version_not_in_hot_versions(self):
|
||||
invalid_hot_version_tmp = template_format.parse(
|
||||
@ -224,7 +224,7 @@ class TemplateTest(HeatTestCase):
|
||||
'"heat_template_version: 2012-12-12". '
|
||||
'"heat_template_version" should be '
|
||||
'one of: 2013-05-23, 2013-06-23')
|
||||
self.assertEqual(ex_error_msg, str(init_ex))
|
||||
self.assertEqual(ex_error_msg, six.text_type(init_ex))
|
||||
template._template_classes = temp_copy
|
||||
|
||||
def test_invalid_aws_version(self):
|
||||
@ -237,7 +237,7 @@ class TemplateTest(HeatTestCase):
|
||||
ex_error_msg = ('The template version is invalid: '
|
||||
'"AWSTemplateFormatVersion: 2012-12-12". '
|
||||
'"AWSTemplateFormatVersion" should be: 2010-09-09')
|
||||
self.assertEqual(ex_error_msg, str(init_ex))
|
||||
self.assertEqual(ex_error_msg, six.text_type(init_ex))
|
||||
|
||||
def test_invalid_version_not_in_aws_versions(self):
|
||||
invalid_aws_version_tmp = template_format.parse(
|
||||
@ -257,7 +257,7 @@ class TemplateTest(HeatTestCase):
|
||||
'"AWSTemplateFormatVersion: 2012-12-12". '
|
||||
'"AWSTemplateFormatVersion" should be '
|
||||
'one of: 2010-09-09, 2011-06-23')
|
||||
self.assertEqual(ex_error_msg, str(init_ex))
|
||||
self.assertEqual(ex_error_msg, six.text_type(init_ex))
|
||||
template._template_classes = temp_copy
|
||||
|
||||
def test_invalid_heat_version(self):
|
||||
@ -270,7 +270,7 @@ class TemplateTest(HeatTestCase):
|
||||
ex_error_msg = ('The template version is invalid: '
|
||||
'"HeatTemplateFormatVersion: 2010-09-09". '
|
||||
'"HeatTemplateFormatVersion" should be: 2012-12-12')
|
||||
self.assertEqual(ex_error_msg, str(init_ex))
|
||||
self.assertEqual(ex_error_msg, six.text_type(init_ex))
|
||||
|
||||
def test_invalid_version_not_in_heat_versions(self):
|
||||
invalid_heat_version_tmp = template_format.parse(
|
||||
@ -290,7 +290,7 @@ class TemplateTest(HeatTestCase):
|
||||
'"HeatTemplateFormatVersion: 2010-09-09". '
|
||||
'"HeatTemplateFormatVersion" should be '
|
||||
'one of: 2012-12-12, 2014-12-12')
|
||||
self.assertEqual(ex_error_msg, str(init_ex))
|
||||
self.assertEqual(ex_error_msg, six.text_type(init_ex))
|
||||
|
||||
template._template_classes = temp_copy
|
||||
|
||||
@ -595,7 +595,7 @@ Mappings:
|
||||
self.resolve,
|
||||
snippet,
|
||||
stack.t, stack)
|
||||
self.assertIn(snippet.keys()[0], str(error))
|
||||
self.assertIn(snippet.keys()[0], six.text_type(error))
|
||||
|
||||
def test_resource_facade_missing_deletion_policy(self):
|
||||
snippet = {'Fn::ResourceFacade': 'DeletionPolicy'}
|
||||
@ -619,7 +619,7 @@ Mappings:
|
||||
{'foo': {'Type': 'String', 'Required': True}}})
|
||||
self.assertEqual(expected_description, tmpl['Description'])
|
||||
keyError = self.assertRaises(KeyError, tmpl.__getitem__, 'Parameters')
|
||||
self.assertIn("can not be accessed directly", str(keyError))
|
||||
self.assertIn("can not be accessed directly", six.text_type(keyError))
|
||||
|
||||
def test_parameters_section_not_iterable(self):
|
||||
expected_description = "This can be accessed"
|
||||
@ -774,7 +774,7 @@ class TemplateFnErrorTest(HeatTestCase):
|
||||
error = self.assertRaises(self.expect,
|
||||
resolve,
|
||||
self.snippet)
|
||||
self.assertIn(self.snippet.keys()[0], str(error))
|
||||
self.assertIn(self.snippet.keys()[0], six.text_type(error))
|
||||
|
||||
|
||||
class ResolveDataTest(HeatTestCase):
|
||||
|
@ -11,6 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from heat.common import exception
|
||||
@ -690,7 +691,7 @@ class PropertyTest(testtools.TestCase):
|
||||
p = properties.Property(schema)
|
||||
ex = self.assertRaises(TypeError, p.get_value, [1])
|
||||
self.assertEqual("int() argument must be a string or a number, "
|
||||
"not 'list'", str(ex))
|
||||
"not 'list'", six.text_type(ex))
|
||||
|
||||
def test_int_from_str_good(self):
|
||||
schema = {'Type': 'Integer'}
|
||||
@ -701,7 +702,7 @@ class PropertyTest(testtools.TestCase):
|
||||
schema = {'Type': 'Integer'}
|
||||
p = properties.Property(schema)
|
||||
ex = self.assertRaises(TypeError, p.get_value, '3a')
|
||||
self.assertEqual("Value '3a' is not an integer", str(ex))
|
||||
self.assertEqual("Value '3a' is not an integer", six.text_type(ex))
|
||||
|
||||
def test_integer_low(self):
|
||||
schema = {'Type': 'Integer',
|
||||
@ -852,7 +853,7 @@ class PropertyTest(testtools.TestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
p.get_value, {'valid': 'fish'}, True)
|
||||
self.assertEqual('Property error : valid "fish" is not '
|
||||
'a valid boolean', str(ex))
|
||||
'a valid boolean', six.text_type(ex))
|
||||
|
||||
def test_map_schema_missing_data(self):
|
||||
map_schema = {'valid': {'Type': 'Boolean'}}
|
||||
@ -865,7 +866,7 @@ class PropertyTest(testtools.TestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
p.get_value, {}, True)
|
||||
self.assertEqual('Property error : Property valid not assigned',
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
|
||||
def test_list_schema_good(self):
|
||||
map_schema = {'valid': {'Type': 'Boolean'}}
|
||||
@ -884,7 +885,7 @@ class PropertyTest(testtools.TestCase):
|
||||
p.get_value,
|
||||
[{'valid': 'True'}, {'valid': 'fish'}], True)
|
||||
self.assertEqual('Property error : 1 Property error : 1: valid '
|
||||
'"fish" is not a valid boolean', str(ex))
|
||||
'"fish" is not a valid boolean', six.text_type(ex))
|
||||
|
||||
def test_list_schema_int_good(self):
|
||||
list_schema = {'Type': 'Integer'}
|
||||
@ -897,7 +898,7 @@ class PropertyTest(testtools.TestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
p.get_value, [42, 'fish'], True)
|
||||
self.assertEqual('Property error : 1 Value \'fish\' is not '
|
||||
'an integer', str(ex))
|
||||
'an integer', six.text_type(ex))
|
||||
|
||||
|
||||
class PropertiesTest(testtools.TestCase):
|
||||
@ -1029,7 +1030,7 @@ class PropertiesTest(testtools.TestCase):
|
||||
|
||||
props = properties.Properties(schema, {'foo': 'baz'}, bad_resolver)
|
||||
err = self.assertRaises(ValueError, props.get, 'foo')
|
||||
self.assertEqual('foo resolution failed!', str(err))
|
||||
self.assertEqual('foo resolution failed!', six.text_type(err))
|
||||
|
||||
def test_resolve_returns_none(self):
|
||||
schema = {'foo': {'Type': 'String', "MinLength": "5"}}
|
||||
@ -1603,7 +1604,7 @@ class PropertiesValidationTest(testtools.TestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
props.validate)
|
||||
self.assertEqual('Property error : foo Property error : foo: 0 '
|
||||
'Unknown Property bar', str(ex))
|
||||
'Unknown Property bar', six.text_type(ex))
|
||||
|
||||
def test_nested_properties_schema_invalid_property_in_map(self):
|
||||
child_schema = {'Key': {'Type': 'String',
|
||||
@ -1623,7 +1624,7 @@ class PropertiesValidationTest(testtools.TestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
props.validate)
|
||||
self.assertEqual('Property error : foo Property error : foo: boo '
|
||||
'Unknown Property bar', str(ex))
|
||||
'Unknown Property bar', six.text_type(ex))
|
||||
|
||||
def test_more_nested_properties_schema_invalid_property_in_list(self):
|
||||
nested_child_schema = {'Key': {'Type': 'String',
|
||||
@ -1642,7 +1643,7 @@ class PropertiesValidationTest(testtools.TestCase):
|
||||
props.validate)
|
||||
self.assertEqual('Property error : foo Property error : foo: 0 '
|
||||
'Property error : 0: doo Unknown Property bar',
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
|
||||
def test_more_nested_properties_schema_invalid_property_in_map(self):
|
||||
nested_child_schema = {'Key': {'Type': 'String',
|
||||
@ -1661,7 +1662,7 @@ class PropertiesValidationTest(testtools.TestCase):
|
||||
props.validate)
|
||||
self.assertEqual('Property error : foo Property error : foo: boo '
|
||||
'Property error : boo: doo Unknown Property bar',
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
|
||||
def test_schema_to_template_empty_schema(self):
|
||||
schema = {}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import json
|
||||
import os
|
||||
import six
|
||||
import uuid
|
||||
import yaml
|
||||
|
||||
@ -358,7 +359,7 @@ class ProviderTemplateTest(HeatTestCase):
|
||||
temp_res.validate)
|
||||
self.assertEqual("Property Foo type mismatch between facade "
|
||||
"DummyResource (Map) and provider (String)",
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
|
||||
def test_boolean_type_provider(self):
|
||||
provider = {
|
||||
|
@ -93,7 +93,8 @@ class ResourceTest(HeatTestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
resource.Resource, resource_name,
|
||||
snippet, self.stack)
|
||||
self.assertIn(_('Resource "%s" has no type') % resource_name, str(ex))
|
||||
self.assertIn(_('Resource "%s" has no type') % resource_name,
|
||||
six.text_type(ex))
|
||||
|
||||
def test_state_defaults(self):
|
||||
tmpl = rsrc_defn.ResourceDefinition('test_res_def', 'Foo')
|
||||
@ -438,7 +439,7 @@ class ResourceTest(HeatTestCase):
|
||||
estr = 'Property error : test_resource: Property Foo not assigned'
|
||||
create = scheduler.TaskRunner(res.create)
|
||||
err = self.assertRaises(exception.ResourceFailure, create)
|
||||
self.assertIn(estr, str(err))
|
||||
self.assertIn(estr, six.text_type(err))
|
||||
self.assertEqual((res.CREATE, res.FAILED), res.state)
|
||||
|
||||
def test_create_fail_prop_typo(self):
|
||||
@ -450,7 +451,7 @@ class ResourceTest(HeatTestCase):
|
||||
estr = 'StackValidationFailed: Unknown Property Food'
|
||||
create = scheduler.TaskRunner(res.create)
|
||||
err = self.assertRaises(exception.ResourceFailure, create)
|
||||
self.assertIn(estr, str(err))
|
||||
self.assertIn(estr, six.text_type(err))
|
||||
self.assertEqual((res.CREATE, res.FAILED), res.state)
|
||||
|
||||
def test_create_fail_metadata_parse_error(self):
|
||||
@ -1066,7 +1067,7 @@ class ResourceDependenciesTest(HeatTestCase):
|
||||
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
stack.validate)
|
||||
self.assertIn('"baz" (in bar.Properties.Foo)', str(ex))
|
||||
self.assertIn('"baz" (in bar.Properties.Foo)', six.text_type(ex))
|
||||
|
||||
def test_getatt(self):
|
||||
tmpl = template.Template({
|
||||
@ -1222,7 +1223,7 @@ class ResourceDependenciesTest(HeatTestCase):
|
||||
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
getattr, stack, 'dependencies')
|
||||
self.assertIn('"baz" (in bar.Properties.Foo)', str(ex))
|
||||
self.assertIn('"baz" (in bar.Properties.Foo)', six.text_type(ex))
|
||||
|
||||
def test_hot_getatt_fail(self):
|
||||
tmpl = template.Template({
|
||||
@ -1240,7 +1241,7 @@ class ResourceDependenciesTest(HeatTestCase):
|
||||
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
getattr, stack, 'dependencies')
|
||||
self.assertIn('"baz" (in bar.Properties.Foo)', str(ex))
|
||||
self.assertIn('"baz" (in bar.Properties.Foo)', six.text_type(ex))
|
||||
|
||||
def test_getatt_fail_nested_deep(self):
|
||||
tmpl = template.Template({
|
||||
@ -1263,7 +1264,8 @@ class ResourceDependenciesTest(HeatTestCase):
|
||||
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
getattr, stack, 'dependencies')
|
||||
self.assertIn('"baz" (in bar.Properties.Foo.Fn::Join[1][3])', str(ex))
|
||||
self.assertIn('"baz" (in bar.Properties.Foo.Fn::Join[1][3])',
|
||||
six.text_type(ex))
|
||||
|
||||
def test_hot_getatt_fail_nested_deep(self):
|
||||
tmpl = template.Template({
|
||||
@ -1286,7 +1288,8 @@ class ResourceDependenciesTest(HeatTestCase):
|
||||
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
getattr, stack, 'dependencies')
|
||||
self.assertIn('"baz" (in bar.Properties.Foo.Fn::Join[1][3])', str(ex))
|
||||
self.assertIn('"baz" (in bar.Properties.Foo.Fn::Join[1][3])',
|
||||
six.text_type(ex))
|
||||
|
||||
def test_dependson(self):
|
||||
tmpl = template.Template({
|
||||
@ -1341,7 +1344,7 @@ class ResourceDependenciesTest(HeatTestCase):
|
||||
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
|
||||
ex = self.assertRaises(exception.InvalidTemplateReference,
|
||||
getattr, stack, 'dependencies')
|
||||
self.assertIn('"wibble" (in foo)', str(ex))
|
||||
self.assertIn('"wibble" (in foo)', six.text_type(ex))
|
||||
|
||||
|
||||
class MetadataTest(HeatTestCase):
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import copy
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine import resource
|
||||
@ -150,7 +151,7 @@ class ResourceGroupTest(common.HeatTestCase):
|
||||
resg = resource_group.ResourceGroup('test', snip, stack)
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
resg.validate)
|
||||
self.assertIn('Unknown resource Type', str(exc))
|
||||
self.assertIn('Unknown resource Type', six.text_type(exc))
|
||||
|
||||
def test_reference_attr(self):
|
||||
stack = utils.parse_stack(template2)
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import collections
|
||||
import copy
|
||||
import six
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
@ -343,7 +344,7 @@ class ServersTest(HeatTestCase):
|
||||
'StackValidationFailed: Property error : WebServer: '
|
||||
'image Error validating value \'Slackware\': '
|
||||
'The Image (Slackware) could not be found.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -369,7 +370,7 @@ class ServersTest(HeatTestCase):
|
||||
'StackValidationFailed: Property error : WebServer: '
|
||||
'image Multiple physical resources were '
|
||||
'found with name (CentOS 5.2).',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -394,7 +395,7 @@ class ServersTest(HeatTestCase):
|
||||
'StackValidationFailed: Property error : WebServer: '
|
||||
'image Error validating value \'1\': '
|
||||
'The Image (1) could not be found.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -728,7 +729,7 @@ class ServersTest(HeatTestCase):
|
||||
error = self.assertRaises(exception.StackValidationFailed,
|
||||
servers.Server._check_maximum,
|
||||
2, 1, msg)
|
||||
self.assertEqual(msg, str(error))
|
||||
self.assertEqual(msg, six.text_type(error))
|
||||
|
||||
def test_server_validate(self):
|
||||
stack_name = 'srv_val'
|
||||
@ -784,7 +785,8 @@ class ServersTest(HeatTestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
server.validate)
|
||||
self.assertEqual('Neither image nor bootable volume is specified for '
|
||||
'instance server_with_bootable_volume', str(ex))
|
||||
'instance server_with_bootable_volume',
|
||||
six.text_type(ex))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_server_validate_with_nova_keypair_resource(self):
|
||||
@ -854,7 +856,7 @@ class ServersTest(HeatTestCase):
|
||||
self.assertEqual(
|
||||
'Property error : WebServer: key_name Error validating '
|
||||
'value \'test2\': The Key (test2) could not be found.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_server_validate_with_networks(self):
|
||||
@ -884,7 +886,7 @@ class ServersTest(HeatTestCase):
|
||||
'"%(server)s". The "uuid" property is deprecated. '
|
||||
'Use only "network" property.'
|
||||
'') % dict(network=network_name, server=server.name),
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_server_validate_net_security_groups(self):
|
||||
@ -912,7 +914,7 @@ class ServersTest(HeatTestCase):
|
||||
server.validate)
|
||||
self.assertEqual("Cannot define the following properties at the same "
|
||||
"time: security_groups, networks/port.",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_server_delete(self):
|
||||
@ -984,7 +986,8 @@ class ServersTest(HeatTestCase):
|
||||
|
||||
resf = self.assertRaises(exception.ResourceFailure,
|
||||
scheduler.TaskRunner(server.delete))
|
||||
self.assertIn("Server sample-server delete failed", str(resf))
|
||||
self.assertIn("Server sample-server delete failed",
|
||||
six.text_type(resf))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -1172,7 +1175,7 @@ class ServersTest(HeatTestCase):
|
||||
error = self.assertRaises(exception.ResourceFailure, updater)
|
||||
self.assertEqual(
|
||||
"Error: Resizing to 'm1.small' failed, status 'ACTIVE'",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((server.UPDATE, server.FAILED), server.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -1329,7 +1332,7 @@ class ServersTest(HeatTestCase):
|
||||
error = self.assertRaises(exception.ResourceFailure, updater)
|
||||
self.assertEqual(
|
||||
"Error: Rebuilding server failed, status 'ERROR'",
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
self.assertEqual((server.UPDATE, server.FAILED), server.state)
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -1375,7 +1378,7 @@ class ServersTest(HeatTestCase):
|
||||
scheduler.TaskRunner(server.suspend))
|
||||
self.assertEqual('Error: Cannot suspend srv_sus1, '
|
||||
'resource_id not set',
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
self.assertEqual((server.SUSPEND, server.FAILED), server.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
@ -1395,7 +1398,7 @@ class ServersTest(HeatTestCase):
|
||||
ex = self.assertRaises(exception.ResourceFailure,
|
||||
scheduler.TaskRunner(server.suspend))
|
||||
self.assertEqual('NotFound: Failed to find server 1234',
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
self.assertEqual((server.SUSPEND, server.FAILED), server.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
@ -1494,7 +1497,7 @@ class ServersTest(HeatTestCase):
|
||||
scheduler.TaskRunner(server.suspend))
|
||||
self.assertEqual('Error: Suspend of server sample-server failed '
|
||||
'with unknown status: TRANSMOGRIFIED',
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
self.assertEqual((server.SUSPEND, server.FAILED), server.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
@ -1540,7 +1543,7 @@ class ServersTest(HeatTestCase):
|
||||
scheduler.TaskRunner(server.resume))
|
||||
self.assertEqual('Error: Cannot resume srv_susp_norid, '
|
||||
'resource_id not set',
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
self.assertEqual((server.RESUME, server.FAILED), server.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
@ -1565,7 +1568,7 @@ class ServersTest(HeatTestCase):
|
||||
ex = self.assertRaises(exception.ResourceFailure,
|
||||
scheduler.TaskRunner(server.resume))
|
||||
self.assertEqual('NotFound: Failed to find server 1234',
|
||||
str(ex))
|
||||
six.text_type(ex))
|
||||
self.assertEqual((server.RESUME, server.FAILED), server.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
@ -1748,7 +1751,7 @@ class ServersTest(HeatTestCase):
|
||||
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
server.validate)
|
||||
self.assertIn("Value '10a' is not an integer", str(exc))
|
||||
self.assertIn("Value '10a' is not an integer", six.text_type(exc))
|
||||
|
||||
def test_validate_conflict_block_device_mapping_props(self):
|
||||
stack_name = 'val_blkdev1'
|
||||
@ -1789,7 +1792,7 @@ class ServersTest(HeatTestCase):
|
||||
server.validate)
|
||||
msg = 'Either volume_id or snapshot_id must be specified for device' +\
|
||||
' mapping vdb'
|
||||
self.assertEqual(msg, str(ex))
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -1812,7 +1815,7 @@ class ServersTest(HeatTestCase):
|
||||
server.validate)
|
||||
msg = 'Neither image nor bootable volume is specified for instance %s'\
|
||||
% server.name
|
||||
self.assertEqual(msg, str(ex))
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@ -1839,7 +1842,7 @@ class ServersTest(HeatTestCase):
|
||||
ex = self.assertRaises(exception.StackValidationFailed,
|
||||
server.validate)
|
||||
self.assertIn('Instance metadata must not contain greater than 3 '
|
||||
'entries', str(ex))
|
||||
'entries', six.text_type(ex))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_validate_metadata_okay(self):
|
||||
@ -1891,7 +1894,7 @@ class ServersTest(HeatTestCase):
|
||||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
server.validate)
|
||||
self.assertEqual("The personality property may not contain "
|
||||
"greater than 5 entries.", str(exc))
|
||||
"greater than 5 entries.", six.text_type(exc))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_server_validate_personality_okay(self):
|
||||
@ -1962,7 +1965,7 @@ class ServersTest(HeatTestCase):
|
||||
server.validate)
|
||||
self.assertEqual("The contents of personality file \"/fake/path1\" "
|
||||
"is larger than the maximum allowed personality "
|
||||
"file size (10240 bytes).", str(exc))
|
||||
"file size (10240 bytes).", six.text_type(exc))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_resolve_attribute_server_not_found(self):
|
||||
@ -2513,7 +2516,7 @@ class ServersTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.ResourceFailure, updater)
|
||||
self.assertEqual('StackValidationFailed: Property error : WebServer: '
|
||||
'image The Image (Update Image) could not be found.',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
from heatclient.exc import HTTPNotFound
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine import parser
|
||||
@ -91,7 +92,7 @@ class SoftwareConfigTest(HeatTestCase):
|
||||
heatclient, config_id)
|
||||
self.assertEqual(
|
||||
('The config (c8a19429-7fde-47ea-a42f-40045488226c) '
|
||||
'could not be found.'), str(err))
|
||||
'could not be found.'), six.text_type(err))
|
||||
|
||||
def test_resolve_attribute(self):
|
||||
self.assertIsNone(self.config._resolve_attribute('others'))
|
||||
|
@ -15,6 +15,7 @@ from heatclient.exc import HTTPNotFound
|
||||
|
||||
import copy
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine import parser
|
||||
@ -140,7 +141,7 @@ class SoftwareDeploymentTest(HeatTestCase):
|
||||
self.assertEqual("Resource server's property "
|
||||
"user_data_format should be set to "
|
||||
"SOFTWARE_CONFIG since there are "
|
||||
"software deployments on it.", str(err))
|
||||
"software deployments on it.", six.text_type(err))
|
||||
|
||||
def test_resource_mapping(self):
|
||||
self._create_stack(self.template)
|
||||
@ -302,7 +303,7 @@ class SoftwareDeploymentTest(HeatTestCase):
|
||||
err = self.assertRaises(
|
||||
exception.Error, self.deployment.check_create_complete, sd)
|
||||
self.assertEqual(
|
||||
'Deployment to server failed: something wrong', str(err))
|
||||
'Deployment to server failed: something wrong', six.text_type(err))
|
||||
|
||||
def test_handle_delete(self):
|
||||
self._create_stack(self.template)
|
||||
@ -595,7 +596,7 @@ class SoftwareDeploymentTest(HeatTestCase):
|
||||
self.deployment.FnGetAtt, 'foo2')
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (deployment_mysql foo2) is incorrect.',
|
||||
str(err))
|
||||
six.text_type(err))
|
||||
|
||||
def test_handle_action(self):
|
||||
self._create_stack(self.template)
|
||||
|
@ -15,6 +15,7 @@ from datetime import datetime
|
||||
from datetime import timedelta
|
||||
from json import dumps
|
||||
from json import loads
|
||||
import six
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
@ -890,7 +891,7 @@ class SqlAlchemyTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.NotFound,
|
||||
db_api.software_deployment_update,
|
||||
self.ctx, deployment_id, values={})
|
||||
self.assertIn(deployment_id, str(err))
|
||||
self.assertIn(deployment_id, six.text_type(err))
|
||||
values = self._deployment_values()
|
||||
deployment = db_api.software_deployment_create(self.ctx, values)
|
||||
deployment_id = deployment.id
|
||||
@ -905,7 +906,7 @@ class SqlAlchemyTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.NotFound,
|
||||
db_api.software_deployment_delete,
|
||||
self.ctx, deployment_id)
|
||||
self.assertIn(deployment_id, str(err))
|
||||
self.assertIn(deployment_id, six.text_type(err))
|
||||
values = self._deployment_values()
|
||||
deployment = db_api.software_deployment_create(self.ctx, values)
|
||||
deployment_id = deployment.id
|
||||
@ -919,7 +920,7 @@ class SqlAlchemyTest(HeatTestCase):
|
||||
self.ctx,
|
||||
deployment_id)
|
||||
|
||||
self.assertIn(deployment_id, str(err))
|
||||
self.assertIn(deployment_id, six.text_type(err))
|
||||
|
||||
def test_snapshot_create(self):
|
||||
template = create_raw_template(self.ctx)
|
||||
@ -983,7 +984,7 @@ class SqlAlchemyTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.NotFound,
|
||||
db_api.snapshot_update,
|
||||
self.ctx, snapshot_id, values={})
|
||||
self.assertIn(snapshot_id, str(err))
|
||||
self.assertIn(snapshot_id, six.text_type(err))
|
||||
|
||||
def test_snapshot_update(self):
|
||||
template = create_raw_template(self.ctx)
|
||||
@ -1003,7 +1004,7 @@ class SqlAlchemyTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.NotFound,
|
||||
db_api.snapshot_delete,
|
||||
self.ctx, snapshot_id)
|
||||
self.assertIn(snapshot_id, str(err))
|
||||
self.assertIn(snapshot_id, six.text_type(err))
|
||||
|
||||
def test_snapshot_delete(self):
|
||||
template = create_raw_template(self.ctx)
|
||||
@ -1023,7 +1024,7 @@ class SqlAlchemyTest(HeatTestCase):
|
||||
self.ctx,
|
||||
snapshot_id)
|
||||
|
||||
self.assertIn(snapshot_id, str(err))
|
||||
self.assertIn(snapshot_id, six.text_type(err))
|
||||
|
||||
|
||||
def create_raw_template(context, **kwargs):
|
||||
@ -1187,7 +1188,7 @@ class DBAPIUserCredsTest(HeatTestCase):
|
||||
self.ctx, user_creds.id)
|
||||
exp_msg = ('Attempt to delete user creds with id '
|
||||
'%s that does not exist' % user_creds.id)
|
||||
self.assertIn(exp_msg, str(err))
|
||||
self.assertIn(exp_msg, six.text_type(err))
|
||||
|
||||
|
||||
class DBAPIStackTest(HeatTestCase):
|
||||
|
@ -11,6 +11,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
@ -391,7 +392,7 @@ class StackResourceTest(HeatTestCase):
|
||||
ex = self.assertRaises(exception.Error,
|
||||
self.parent_resource.check_update_complete,
|
||||
updater)
|
||||
self.assertEqual('Nested stack UPDATE failed: ', str(ex))
|
||||
self.assertEqual('Nested stack UPDATE failed: ', six.text_type(ex))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
from heat.engine.cfn.template import CfnTemplate
|
||||
@ -82,7 +84,7 @@ class TestTemplateVersion(HeatTestCase):
|
||||
ex = self.assertRaises(exception.InvalidTemplateVersion,
|
||||
template.get_version, tmpl, self.versions)
|
||||
self.assertEqual('The template version is invalid: Template version '
|
||||
'was not provided', str(ex))
|
||||
'was not provided', six.text_type(ex))
|
||||
|
||||
def test_ambiguous_version(self):
|
||||
tmpl = {
|
||||
@ -150,7 +152,7 @@ class TestTemplateValidate(HeatTestCase):
|
||||
tmpl = template.Template(t)
|
||||
err = self.assertRaises(exception.InvalidTemplateSection,
|
||||
tmpl.validate)
|
||||
self.assertIn('Parameteers', str(err))
|
||||
self.assertIn('Parameteers', six.text_type(err))
|
||||
|
||||
def test_template_validate_cfn_empty(self):
|
||||
t = template_format.parse('''
|
||||
@ -196,4 +198,4 @@ Outputs:
|
||||
tmpl = template.Template(t)
|
||||
err = self.assertRaises(exception.InvalidTemplateSection,
|
||||
tmpl.validate)
|
||||
self.assertIn('parameteers', str(err))
|
||||
self.assertIn('parameteers', six.text_type(err))
|
||||
|
@ -95,7 +95,7 @@ class YamlMinimalTest(HeatTestCase):
|
||||
template_format.parse, long_yaml)
|
||||
msg = ('Request limit exceeded: Template exceeds maximum allowed size '
|
||||
'(1024 bytes)')
|
||||
self.assertEqual(msg, str(ex))
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
|
||||
def test_parse_no_version_format(self):
|
||||
yaml = ''
|
||||
|
@ -14,6 +14,7 @@
|
||||
from oslo.config import cfg
|
||||
import requests
|
||||
from requests import exceptions
|
||||
import six
|
||||
from six.moves import cStringIO
|
||||
from six.moves import urllib
|
||||
|
||||
@ -127,5 +128,5 @@ class UrlFetchTest(HeatTestCase):
|
||||
self.m.ReplayAll()
|
||||
exception = self.assertRaises(urlfetch.URLFetchError,
|
||||
urlfetch.get, url)
|
||||
self.assertIn("Template exceeds", str(exception))
|
||||
self.assertIn("Template exceeds", six.text_type(exception))
|
||||
self.m.VerifyAll()
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
from glanceclient import exc as glance_exceptions
|
||||
import mock
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
@ -1318,7 +1319,7 @@ class validateTest(HeatTestCase):
|
||||
stack.validate)
|
||||
|
||||
self.assertEqual(_('The InstanceType parameter must be assigned to '
|
||||
'one Parameter Group only.'), str(exc))
|
||||
'one Parameter Group only.'), six.text_type(exc))
|
||||
|
||||
def test_validate_invalid_parameter_in_group(self):
|
||||
t = template_format.parse(test_template_invalid_parameter_name)
|
||||
@ -1333,7 +1334,8 @@ class validateTest(HeatTestCase):
|
||||
stack.validate)
|
||||
|
||||
self.assertEqual(_('The Parameter name (SomethingNotHere) does not '
|
||||
'reference an existing parameter.'), str(exc))
|
||||
'reference an existing parameter.'),
|
||||
six.text_type(exc))
|
||||
|
||||
def test_validate_no_parameters_in_group(self):
|
||||
t = template_format.parse(test_template_no_parameters)
|
||||
@ -1343,7 +1345,7 @@ class validateTest(HeatTestCase):
|
||||
stack.validate)
|
||||
|
||||
self.assertEqual(_('Parameters must be provided for each Parameter '
|
||||
'Group.'), str(exc))
|
||||
'Group.'), six.text_type(exc))
|
||||
|
||||
def test_validate_allowed_values_integer(self):
|
||||
t = template_format.parse(test_template_allowed_integers)
|
||||
@ -1381,13 +1383,15 @@ class validateTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed, parser.Stack,
|
||||
self.ctx, 'test_stack', template,
|
||||
environment.Environment({'size': '3'}))
|
||||
self.assertIn('"3" is not an allowed value [1, 4, 8]', str(err))
|
||||
self.assertIn('"3" is not an allowed value [1, 4, 8]',
|
||||
six.text_type(err))
|
||||
|
||||
# test with size parameter provided as number
|
||||
err = self.assertRaises(exception.StackValidationFailed, parser.Stack,
|
||||
self.ctx, 'test_stack', template,
|
||||
environment.Environment({'size': 3}))
|
||||
self.assertIn('"3" is not an allowed value [1, 4, 8]', str(err))
|
||||
self.assertIn('"3" is not an allowed value [1, 4, 8]',
|
||||
six.text_type(err))
|
||||
|
||||
def test_validate_not_allowed_values_integer_str(self):
|
||||
t = template_format.parse(test_template_allowed_integers_str)
|
||||
@ -1397,10 +1401,12 @@ class validateTest(HeatTestCase):
|
||||
err = self.assertRaises(exception.StackValidationFailed, parser.Stack,
|
||||
self.ctx, 'test_stack', template,
|
||||
environment.Environment({'size': '3'}))
|
||||
self.assertIn('"3" is not an allowed value [1, 4, 8]', str(err))
|
||||
self.assertIn('"3" is not an allowed value [1, 4, 8]',
|
||||
six.text_type(err))
|
||||
|
||||
# test with size parameter provided as number
|
||||
err = self.assertRaises(exception.StackValidationFailed, parser.Stack,
|
||||
self.ctx, 'test_stack', template,
|
||||
environment.Environment({'size': 3}))
|
||||
self.assertIn('"3" is not an allowed value [1, 4, 8]', str(err))
|
||||
self.assertIn('"3" is not an allowed value [1, 4, 8]',
|
||||
six.text_type(err))
|
||||
|
@ -862,7 +862,7 @@ class VolumeTest(HeatTestCase):
|
||||
rsrc.validate)
|
||||
self.assertEqual(
|
||||
"Property error : DataVolume: size 0 is out of "
|
||||
"range (min: 1, max: None)", str(error))
|
||||
"range (min: 1, max: None)", six.text_type(error))
|
||||
|
||||
def test_volume_size_constraint_aws(self):
|
||||
t = template_format.parse(volume_template)
|
||||
@ -875,7 +875,7 @@ class VolumeTest(HeatTestCase):
|
||||
rsrc.validate)
|
||||
self.assertEqual(
|
||||
"Property error : DataVolume: Size 0 is out of "
|
||||
"range (min: 1, max: None)", str(error))
|
||||
"range (min: 1, max: None)", six.text_type(error))
|
||||
|
||||
def test_cinder_create_from_image(self):
|
||||
fv = FakeVolumeWithStateTransition('downloading', 'available')
|
||||
@ -998,7 +998,7 @@ class VolumeTest(HeatTestCase):
|
||||
rsrc.FnGetAtt, 'unknown')
|
||||
self.assertEqual(
|
||||
'The Referenced Attribute (DataVolume unknown) is incorrect.',
|
||||
str(error))
|
||||
six.text_type(error))
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
import copy
|
||||
import datetime
|
||||
import json
|
||||
import six
|
||||
import time
|
||||
import uuid
|
||||
|
||||
@ -700,7 +701,7 @@ class WaitConditionUpdateTest(HeatTestCase):
|
||||
self.assertEqual(5, rsrc.properties['Count'])
|
||||
ex = self.assertRaises(wc.WaitConditionTimeout,
|
||||
updater.run_to_completion)
|
||||
self.assertEqual("0 of 5 received", str(ex))
|
||||
self.assertEqual("0 of 5 received", six.text_type(ex))
|
||||
self.m.VerifyAll()
|
||||
self.m.UnsetStubs()
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
import json
|
||||
import six
|
||||
|
||||
from oslo.config import cfg
|
||||
import stubout
|
||||
@ -222,7 +223,7 @@ class ResourceTest(HeatTestCase):
|
||||
|
||||
e = self.assertRaises(exception.HTTPExceptionDisguise,
|
||||
resource, request)
|
||||
self.assertEqual(message_es, str(e.exc))
|
||||
self.assertEqual(message_es, six.text_type(e.exc))
|
||||
self.m.VerifyAll()
|
||||
|
||||
|
||||
@ -259,7 +260,7 @@ class ResourceExceptionHandlingTest(HeatTestCase):
|
||||
None)
|
||||
e = self.assertRaises(self.exception_catch, resource, request)
|
||||
e = e.exc if hasattr(e, 'exc') else e
|
||||
self.assertNotIn(str(e), self.LOG.output)
|
||||
self.assertNotIn(six.text_type(e), self.LOG.output)
|
||||
|
||||
|
||||
class JSONRequestDeserializerTest(HeatTestCase):
|
||||
@ -396,4 +397,4 @@ class JSONRequestDeserializerTest(HeatTestCase):
|
||||
msg = 'Request limit exceeded: JSON body size ' + \
|
||||
'(%s bytes) exceeds maximum allowed size (%s bytes).' % \
|
||||
(len(body), cfg.CONF.max_json_body_size)
|
||||
self.assertEqual(msg, str(error))
|
||||
self.assertEqual(msg, six.text_type(error))
|
||||
|
Loading…
Reference in New Issue
Block a user