diff options
author | Douglas Mendizábal <mail@doug.gt> | 2015-03-26 14:18:18 -0500 |
---|---|---|
committer | Douglas Mendizábal <mail@doug.gt> | 2015-03-26 17:01:43 -0500 |
commit | 4f45db00600c778523fb922cda180f0f3463b362 (patch) | |
tree | f63cae4a808394a4381e77457d06b50322e7e4df | |
parent | 91cf1cef2e81f343327ad0af9318ffa7232c4f5b (diff) | |
download | python-barbicanclient-4f45db00600c778523fb922cda180f0f3463b362.tar.gz |
Consolidate Payload Exceptions
The current exceptions are too fine grained. This CR consolidates the
two exceptions into a single PayloadException.
Change-Id: I22cf7b51adf0866b76e4dcf494df74d449f3b9fe
-rw-r--r-- | barbicanclient/exceptions.py | 6 | ||||
-rw-r--r-- | barbicanclient/secrets.py | 7 | ||||
-rw-r--r-- | functionaltests/client/v1/functional/test_secrets.py | 10 | ||||
-rw-r--r-- | test-requirements.txt | 2 |
4 files changed, 10 insertions, 15 deletions
diff --git a/barbicanclient/exceptions.py b/barbicanclient/exceptions.py index e032de4..e6cdbdc 100644 --- a/barbicanclient/exceptions.py +++ b/barbicanclient/exceptions.py @@ -18,9 +18,5 @@ class BarbicanException(Exception): pass -class NoPayloadException(BarbicanException): - pass - - -class InvalidPayloadException(BarbicanException): +class PayloadException(BarbicanException): pass diff --git a/barbicanclient/secrets.py b/barbicanclient/secrets.py index 0bf44af..0341947 100644 --- a/barbicanclient/secrets.py +++ b/barbicanclient/secrets.py @@ -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 diff --git a/functionaltests/client/v1/functional/test_secrets.py b/functionaltests/client/v1/functional/test_secrets.py index 55c54c5..6be3c20 100644 --- a/functionaltests/client/v1/functional/test_secrets.py +++ b/functionaltests/client/v1/functional/test_secrets.py @@ -152,7 +152,7 @@ class SecretsTestCase(base.TestCase): test_model.payload = None self.assertRaises( - exceptions.NoPayloadException, + exceptions.PayloadException, self.behaviors.store_secret, test_model ) @@ -167,7 +167,7 @@ class SecretsTestCase(base.TestCase): test_model.payload_content_type = None self.assertRaises( - exceptions.NoPayloadException, + exceptions.PayloadException, self.behaviors.store_secret, test_model ) @@ -210,7 +210,7 @@ class SecretsTestCase(base.TestCase): secret_create_emptystrings_data) self.assertRaises( - exceptions.NoPayloadException, + exceptions.PayloadException, self.behaviors.store_secret, test_model ) @@ -377,7 +377,7 @@ class SecretsTestCase(base.TestCase): test_model.payload = payload self.assertRaises( - exceptions.InvalidPayloadException, + exceptions.PayloadException, self.behaviors.store_secret, test_model ) @@ -398,7 +398,7 @@ class SecretsTestCase(base.TestCase): test_model.payload = payload self.assertRaises( - exceptions.NoPayloadException, + exceptions.PayloadException, self.behaviors.store_secret, test_model ) diff --git a/test-requirements.txt b/test-requirements.txt index 8cad4fb..684cef9 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 |