Python3: exceptions no longer have a 'message' attribute.

This patch fixes theses tests:
- barbican.tests.api.test_init
- barbican.tests.plugin.interface.test_certificate_manager

Partially implements: blueprint barbican-py3

Change-Id: Ib0b057b1e503afadd1dae8edba45160cd0dea350
This commit is contained in:
Cyril Roelandt 2016-04-26 14:37:05 +02:00
parent c5160516b8
commit 71561316c7
3 changed files with 9 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import abc
import datetime
from oslo_config import cfg
from oslo_utils import encodeutils
import six
from stevedore import named
@ -650,7 +651,8 @@ class CertificatePluginManager(named.NamedExtensionManager):
new_ca_infos = cert_plugin.get_ca_info()
except Exception as e:
# The plugin gave an invalid CA, log and return
LOG.error(u._LE("ERROR getting CA from plugin: %s"), e.message)
LOG.error(u._LE("ERROR getting CA from plugin: %s"),
encodeutils.exception_to_unicode(e))
return
old_cas, offset, limit, total = self.ca_repo.get_by_create_date(
@ -682,7 +684,8 @@ class CertificatePluginManager(named.NamedExtensionManager):
self._add_ca(plugin_name, add_id, new_ca_infos[add_id])
except Exception as e:
# The plugin gave an invalid CA, log and continue
LOG.error(u._LE("ERROR adding CA from plugin: %s"), e.message)
LOG.error(u._LE("ERROR adding CA from plugin: %s"),
encodeutils.exception_to_unicode(e))
def _add_ca(self, plugin_name, plugin_ca_id, ca_info):
parsed_ca = dict(ca_info)

View File

@ -41,7 +41,7 @@ class WhenInvokingLoadBodyFunction(utils.BaseTestCase):
exception = self.assertRaises(
ValueError, api.load_body, req)
self.assertEqual('Abort!', exception.message)
self.assertEqual('Abort!', str(exception))
@mock.patch('pecan.abort')
def test_should_abort_with_validation_unsupported_field(
@ -60,7 +60,7 @@ class WhenInvokingLoadBodyFunction(utils.BaseTestCase):
exception_result = self.assertRaises(
ValueError, api.load_body, req, validator=validator)
self.assertEqual('Abort!', exception_result.message)
self.assertEqual('Abort!', str(exception_result))
validator.validate.assert_called_once_with(json.loads(body))

View File

@ -32,6 +32,7 @@ commands =
barbican.tests.api.controllers.test_versions \
barbican.tests.api.middleware.test_context \
barbican.tests.api.middleware.test_simple \
barbican.tests.api.test_init \
barbican.tests.cmd.test_cmd \
barbican.tests.common.test_hrefs \
barbican.tests.common.test_quota \
@ -49,6 +50,7 @@ commands =
barbican.tests.model.repositories.test_repositories_transport_keys \
barbican.tests.model.test_models \
barbican.tests.plugin.crypto.test_manager \
barbican.tests.plugin.interface.test_certificate_manager \
barbican.tests.plugin.interface.test_secret_store \
barbican.tests.plugin.test_simple_certificate_manager \
barbican.tests.plugin.util.test_mime_types \