Merge "Consolidate Payload Exceptions"

This commit is contained in:
Jenkins 2015-03-27 09:28:24 +00:00 committed by Gerrit Code Review
commit 4bfc836aec
4 changed files with 10 additions and 15 deletions

View File

@ -18,9 +18,5 @@ class BarbicanException(Exception):
pass
class NoPayloadException(BarbicanException):
pass
class InvalidPayloadException(BarbicanException):
class PayloadException(BarbicanException):
pass

View File

@ -253,8 +253,7 @@ class Secret(SecretFormatter):
Stores the Secret in Barbican. New Secret objects are not persisted
in Barbican until this method is called.
:raises: NoPayloadException
:raises: InvalidPayloadException
:raises: PayloadException
"""
secret_dict = {
'name': self.name,
@ -265,9 +264,9 @@ class Secret(SecretFormatter):
}
if not self.payload:
raise exceptions.NoPayloadException
raise exceptions.PayloadException("Missing Payload")
if not isinstance(self.payload, (six.text_type, six.binary_type)):
raise exceptions.InvalidPayloadException
raise exceptions.PayloadException("Invalid Payload Type")
if self.payload_content_type:
"""
Setting the payload_content_type and payload_content_encoding

View File

@ -153,7 +153,7 @@ class SecretsTestCase(base.TestCase):
test_model.payload = None
self.assertRaises(
exceptions.NoPayloadException,
exceptions.PayloadException,
self.behaviors.store_secret,
test_model
)
@ -168,7 +168,7 @@ class SecretsTestCase(base.TestCase):
test_model.payload_content_type = None
self.assertRaises(
exceptions.NoPayloadException,
exceptions.PayloadException,
self.behaviors.store_secret,
test_model
)
@ -211,7 +211,7 @@ class SecretsTestCase(base.TestCase):
secret_create_emptystrings_data)
self.assertRaises(
exceptions.NoPayloadException,
exceptions.PayloadException,
self.behaviors.store_secret,
test_model
)
@ -536,7 +536,7 @@ class SecretsTestCase(base.TestCase):
test_model.payload = payload
self.assertRaises(
exceptions.InvalidPayloadException,
exceptions.PayloadException,
self.behaviors.store_secret,
test_model
)
@ -557,7 +557,7 @@ class SecretsTestCase(base.TestCase):
test_model.payload = payload
self.assertRaises(
exceptions.NoPayloadException,
exceptions.PayloadException,
self.behaviors.store_secret,
test_model
)

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
coverage>=3.6
discover
hacking>=0.7.0
hacking>=0.10.0,<0.11
fixtures>=0.3.14
requests-mock>=0.6.0 # Apache-2.0
mock>=1.0