Merge "Port API test_resources to Python 3"

This commit is contained in:
Jenkins 2016-06-10 05:17:56 +00:00 committed by Gerrit Code Review
commit 29e7356c9d
3 changed files with 10 additions and 8 deletions

View File

@ -132,11 +132,14 @@ def _do_enforce_content_types(pecan_req, valid_content_types):
types passed in by our caller.
"""
if pecan_req.content_type not in valid_content_types:
content_type = pecan_req.content_type
if isinstance(content_type, bytes):
content_type = content_type.decode('utf-8')
m = u._(
"Unexpected content type: {type}. Expected content types "
"are: {expected}"
).format(
type=pecan_req.content_type.decode('utf-8'),
type=content_type,
expected=valid_content_types
)
pecan.abort(415, m)

View File

@ -401,7 +401,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
suppress_exception=True)
self.assertEqual(200, resp.status_int)
self.assertEqual(data, resp.body)
self.assertEqual(data, resp.body.decode())
mock_get_secret.assert_called_once_with(
'text/plain',
self.secret,
@ -428,7 +428,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
suppress_exception=True)
self.assertEqual(200, resp.status_int)
self.assertEqual(data, resp.body)
self.assertEqual(data, resp.body.decode())
mock_get_secret.assert_called_once_with(
'text/plain',
self.secret,
@ -457,7 +457,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
suppress_exception=True)
self.assertEqual(200, resp.status_int)
self.assertEqual(data, resp.body)
self.assertEqual(data, resp.body.decode())
mock_get_secret.assert_called_once_with(
'text/plain',
self.secret,
@ -580,7 +580,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
}
)
self.assertEqual(data, resp.body)
self.assertEqual(data, resp.body.decode())
mock_get_secret.assert_called_once_with(
'application/octet-stream',
@ -605,7 +605,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
self.assertEqual(204, resp.status_int)
mock_store_secret.assert_called_once_with(
unencrypted_raw='plain text',
unencrypted_raw=b'plain text',
content_type_raw='text/plain',
content_encoding=None,
secret_model=self.secret,
@ -631,7 +631,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
self.assertEqual(204, resp.status_int)
mock_store_secret.assert_called_once_with(
unencrypted_raw='plain text',
unencrypted_raw=b'plain text',
content_type_raw='application/octet-stream',
content_encoding=None,
secret_model=self.secret,

View File

@ -2,7 +2,6 @@ barbican.tests.api.controllers.test_containers
barbican.tests.api.controllers.test_orders
barbican.tests.api.controllers.test_quotas
barbican.tests.api.controllers.test_secrets
barbican.tests.api.test_resources
barbican.tests.api.test_transport_keys_resource
barbican.tests.cmd.test_barbican_manage
barbican.tests.cmd.test_db_cleanup