From 4f45db00600c778523fb922cda180f0f3463b362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Douglas=20Mendiz=C3=A1bal?= Date: Thu, 26 Mar 2015 14:18:18 -0500 Subject: [PATCH] Consolidate Payload Exceptions The current exceptions are too fine grained. This CR consolidates the two exceptions into a single PayloadException. Change-Id: I22cf7b51adf0866b76e4dcf494df74d449f3b9fe --- barbicanclient/exceptions.py | 6 +----- barbicanclient/secrets.py | 7 +++---- functionaltests/client/v1/functional/test_secrets.py | 10 +++++----- test-requirements.txt | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/barbicanclient/exceptions.py b/barbicanclient/exceptions.py index e032de4f..e6cdbdc0 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 0bf44afa..0341947b 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 55c54c51..6be3c201 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 8cad4fb6..684cef9e 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