From 93d8f41713ec2128210bf0a8479a5f3872ce0382 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 5 May 2023 11:00:35 +0100 Subject: [PATCH] Blackify openstack.key_manager Black used with the '-l 79 -S' flags. A future change will ignore this commit in git-blame history by adding a 'git-blame-ignore-revs' file. Change-Id: Ief5e4e9fa2675c7e74b77feb54776c692deaf33f Signed-off-by: Stephen Finucane --- openstack/key_manager/v1/_format.py | 1 - openstack/key_manager/v1/_proxy.py | 20 +++--- openstack/key_manager/v1/container.py | 4 +- openstack/key_manager/v1/order.py | 3 +- openstack/key_manager/v1/secret.py | 37 +++++++---- .../unit/key_manager/v1/test_container.py | 3 +- .../tests/unit/key_manager/v1/test_order.py | 3 +- .../tests/unit/key_manager/v1/test_proxy.py | 14 ++-- .../tests/unit/key_manager/v1/test_secret.py | 65 +++++++++++-------- 9 files changed, 91 insertions(+), 59 deletions(-) diff --git a/openstack/key_manager/v1/_format.py b/openstack/key_manager/v1/_format.py index 56dbca774..8da3515ac 100644 --- a/openstack/key_manager/v1/_format.py +++ b/openstack/key_manager/v1/_format.py @@ -16,7 +16,6 @@ from openstack import format class HREFToUUID(format.Formatter): - @classmethod def deserialize(cls, value): """Convert a HREF to the UUID portion""" diff --git a/openstack/key_manager/v1/_proxy.py b/openstack/key_manager/v1/_proxy.py index c02b537e9..e3f5ee9cd 100644 --- a/openstack/key_manager/v1/_proxy.py +++ b/openstack/key_manager/v1/_proxy.py @@ -49,8 +49,9 @@ class Proxy(proxy.Proxy): :returns: ``None`` """ - self._delete(_container.Container, container, - ignore_missing=ignore_missing) + self._delete( + _container.Container, container, ignore_missing=ignore_missing + ) def find_container(self, name_or_id, ignore_missing=True): """Find a single container @@ -64,8 +65,9 @@ class Proxy(proxy.Proxy): :returns: One :class:`~openstack.key_manager.v1.container.Container` or None """ - return self._find(_container.Container, name_or_id, - ignore_missing=ignore_missing) + return self._find( + _container.Container, name_or_id, ignore_missing=ignore_missing + ) def get_container(self, container): """Get a single container @@ -143,8 +145,9 @@ class Proxy(proxy.Proxy): attempting to find a nonexistent resource. :returns: One :class:`~openstack.key_manager.v1.order.Order` or None """ - return self._find(_order.Order, name_or_id, - ignore_missing=ignore_missing) + return self._find( + _order.Order, name_or_id, ignore_missing=ignore_missing + ) def get_order(self, order): """Get a single order @@ -223,8 +226,9 @@ class Proxy(proxy.Proxy): :returns: One :class:`~openstack.key_manager.v1.secret.Secret` or None """ - return self._find(_secret.Secret, name_or_id, - ignore_missing=ignore_missing) + return self._find( + _secret.Secret, name_or_id, ignore_missing=ignore_missing + ) def get_secret(self, secret): """Get a single secret diff --git a/openstack/key_manager/v1/container.py b/openstack/key_manager/v1/container.py index 4b14020ab..eebe5d038 100644 --- a/openstack/key_manager/v1/container.py +++ b/openstack/key_manager/v1/container.py @@ -30,8 +30,8 @@ class Container(resource.Resource): container_ref = resource.Body('container_ref') #: The ID for this container container_id = resource.Body( - 'container_ref', alternate_id=True, - type=_format.HREFToUUID) + 'container_ref', alternate_id=True, type=_format.HREFToUUID + ) #: The timestamp when this container was created. created_at = resource.Body('created') #: The name of this container diff --git a/openstack/key_manager/v1/order.py b/openstack/key_manager/v1/order.py index 1f7198c4e..350677f7f 100644 --- a/openstack/key_manager/v1/order.py +++ b/openstack/key_manager/v1/order.py @@ -36,7 +36,8 @@ class Order(resource.Resource): order_ref = resource.Body('order_ref') #: The ID of this order order_id = resource.Body( - 'order_ref', alternate_id=True, type=_format.HREFToUUID) + 'order_ref', alternate_id=True, type=_format.HREFToUUID + ) #: Secret href associated with the order secret_ref = resource.Body('secret_ref') #: Secret ID associated with the order diff --git a/openstack/key_manager/v1/secret.py b/openstack/key_manager/v1/secret.py index 7be69f997..aba4bca9f 100644 --- a/openstack/key_manager/v1/secret.py +++ b/openstack/key_manager/v1/secret.py @@ -27,11 +27,17 @@ class Secret(resource.Resource): allow_list = True _query_mapping = resource.QueryParameters( - "name", "mode", "bits", - "secret_type", "acl_only", - "created", "updated", - "expiration", "sort", - algorithm="alg") + "name", + "mode", + "bits", + "secret_type", + "acl_only", + "created", + "updated", + "expiration", + "sort", + algorithm="alg", + ) # Properties #: Metadata provided by a user or system for informational purposes @@ -59,7 +65,8 @@ class Secret(resource.Resource): # in all of OpenStack because of the departure from using actual IDs # that even this service can't even use itself. secret_id = resource.Body( - 'secret_ref', alternate_id=True, type=_format.HREFToUUID) + 'secret_ref', alternate_id=True, type=_format.HREFToUUID + ) #: Used to indicate the type of secret being stored. secret_type = resource.Body('secret_type') #: The status of this secret @@ -77,10 +84,17 @@ class Secret(resource.Resource): #: (required if payload is encoded) payload_content_encoding = resource.Body('payload_content_encoding') - def fetch(self, session, requires_id=True, - base_path=None, error_message=None, skip_cache=False): - request = self._prepare_request(requires_id=requires_id, - base_path=base_path) + def fetch( + self, + session, + requires_id=True, + base_path=None, + error_message=None, + skip_cache=False, + ): + request = self._prepare_request( + requires_id=requires_id, base_path=base_path + ) response = session.get(request.url).json() @@ -96,7 +110,8 @@ class Secret(resource.Resource): payload = session.get( utils.urljoin(request.url, "payload"), headers={"Accept": content_type}, - skip_cache=skip_cache) + skip_cache=skip_cache, + ) response["payload"] = payload.text # We already have the JSON here so don't call into _translate_response diff --git a/openstack/tests/unit/key_manager/v1/test_container.py b/openstack/tests/unit/key_manager/v1/test_container.py index 789d61c7c..bb43d6f5b 100644 --- a/openstack/tests/unit/key_manager/v1/test_container.py +++ b/openstack/tests/unit/key_manager/v1/test_container.py @@ -24,12 +24,11 @@ EXAMPLE = { 'status': '5', 'type': '6', 'updated': '2015-03-09T12:15:57.233772', - 'consumers': ['7'] + 'consumers': ['7'], } class TestContainer(base.TestCase): - def test_basic(self): sot = container.Container() self.assertIsNone(sot.resource_key) diff --git a/openstack/tests/unit/key_manager/v1/test_order.py b/openstack/tests/unit/key_manager/v1/test_order.py index d9aee65f1..bdb1198f0 100644 --- a/openstack/tests/unit/key_manager/v1/test_order.py +++ b/openstack/tests/unit/key_manager/v1/test_order.py @@ -27,12 +27,11 @@ EXAMPLE = { 'sub_status': '7', 'sub_status_message': '8', 'type': '9', - 'updated': '10' + 'updated': '10', } class TestOrder(base.TestCase): - def test_basic(self): sot = order.Order() self.assertIsNone(sot.resource_key) diff --git a/openstack/tests/unit/key_manager/v1/test_proxy.py b/openstack/tests/unit/key_manager/v1/test_proxy.py index f6d104939..e5ec2bb9b 100644 --- a/openstack/tests/unit/key_manager/v1/test_proxy.py +++ b/openstack/tests/unit/key_manager/v1/test_proxy.py @@ -28,12 +28,14 @@ class TestKeyManagerContainer(TestKeyManagerProxy): self.verify_create(self.proxy.create_container, container.Container) def test_container_delete(self): - self.verify_delete(self.proxy.delete_container, - container.Container, False) + self.verify_delete( + self.proxy.delete_container, container.Container, False + ) def test_container_delete_ignore(self): - self.verify_delete(self.proxy.delete_container, - container.Container, True) + self.verify_delete( + self.proxy.delete_container, container.Container, True + ) def test_container_find(self): self.verify_find(self.proxy.find_container, container.Container) @@ -87,8 +89,8 @@ class TestKeyManagerSecret(TestKeyManagerProxy): def test_secret_get(self): self.verify_get(self.proxy.get_secret, secret.Secret) self.verify_get_overrided( - self.proxy, secret.Secret, - 'openstack.key_manager.v1.secret.Secret') + self.proxy, secret.Secret, 'openstack.key_manager.v1.secret.Secret' + ) def test_secrets(self): self.verify_list(self.proxy.secrets, secret.Secret) diff --git a/openstack/tests/unit/key_manager/v1/test_secret.py b/openstack/tests/unit/key_manager/v1/test_secret.py index 7202c54ae..819e2a930 100644 --- a/openstack/tests/unit/key_manager/v1/test_secret.py +++ b/openstack/tests/unit/key_manager/v1/test_secret.py @@ -31,12 +31,11 @@ EXAMPLE = { 'secret_type': '9', 'payload': '10', 'payload_content_type': '11', - 'payload_content_encoding': '12' + 'payload_content_encoding': '12', } class TestSecret(base.TestCase): - def test_basic(self): sot = secret.Secret() self.assertIsNone(sot.resource_key) @@ -48,19 +47,23 @@ class TestSecret(base.TestCase): self.assertTrue(sot.allow_delete) self.assertTrue(sot.allow_list) - self.assertDictEqual({"name": "name", - "mode": "mode", - "bits": "bits", - "secret_type": "secret_type", - "acl_only": "acl_only", - "created": "created", - "updated": "updated", - "expiration": "expiration", - "sort": "sort", - "algorithm": "alg", - "limit": "limit", - "marker": "marker"}, - sot._query_mapping._mapping) + self.assertDictEqual( + { + "name": "name", + "mode": "mode", + "bits": "bits", + "secret_type": "secret_type", + "acl_only": "acl_only", + "created": "created", + "updated": "updated", + "expiration": "expiration", + "sort": "sort", + "algorithm": "alg", + "limit": "limit", + "marker": "marker", + }, + sot._query_mapping._mapping, + ) def test_make_it(self): sot = secret.Secret(**EXAMPLE) @@ -77,10 +80,12 @@ class TestSecret(base.TestCase): self.assertEqual(EXAMPLE['updated'], sot.updated_at) self.assertEqual(EXAMPLE['secret_type'], sot.secret_type) self.assertEqual(EXAMPLE['payload'], sot.payload) - self.assertEqual(EXAMPLE['payload_content_type'], - sot.payload_content_type) - self.assertEqual(EXAMPLE['payload_content_encoding'], - sot.payload_content_encoding) + self.assertEqual( + EXAMPLE['payload_content_type'], sot.payload_content_type + ) + self.assertEqual( + EXAMPLE['payload_content_encoding'], sot.payload_content_encoding + ) def test_get_no_payload(self): sot = secret.Secret(id="id") @@ -112,11 +117,17 @@ class TestSecret(base.TestCase): rv = sot.fetch(sess) sess.get.assert_has_calls( - [mock.call("secrets/id",), - mock.call( - "secrets/id/payload", - headers={"Accept": content_type}, - skip_cache=False)]) + [ + mock.call( + "secrets/id", + ), + mock.call( + "secrets/id/payload", + headers={"Accept": content_type}, + skip_cache=False, + ), + ] + ) self.assertEqual(rv.payload, payload) self.assertEqual(rv.status, metadata["status"]) @@ -129,7 +140,9 @@ class TestSecret(base.TestCase): def test_get_with_payload_from_content_types(self): content_type = "some/type" - metadata = {"status": "fine", - "content_types": {"default": content_type}} + metadata = { + "status": "fine", + "content_types": {"default": content_type}, + } sot = secret.Secret(id="id") self._test_payload(sot, metadata, content_type)