From 1ebec2827b0f97086bef5002e3bdb2c74e3c7625 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Tue, 14 Jun 2016 11:20:00 -0700 Subject: [PATCH] Define v1 image_members_client as library Image v1 API's image_members_client has good interfaces now, then this patch makes the client as a library. Partially implements blueprint consistent-service-method-names Change-Id: I51af23c1249a10c8d4ddea99b28e61dccb5f38c2 --- ...e-clients-as-library-86d17caa26ce3961.yaml | 1 + tempest/clients.py | 4 +- tempest/lib/services/image/v1/__init__.py | 0 .../image/v1}/image_members_client.py | 0 .../tests/lib/services/image/v1/__init__.py | 0 .../image/v1/test_image_members_client.py | 84 +++++++++++++++++++ 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 tempest/lib/services/image/v1/__init__.py rename tempest/{services/image/v1/json => lib/services/image/v1}/image_members_client.py (100%) create mode 100644 tempest/tests/lib/services/image/v1/__init__.py create mode 100644 tempest/tests/lib/services/image/v1/test_image_members_client.py diff --git a/releasenotes/notes/image-clients-as-library-86d17caa26ce3961.yaml b/releasenotes/notes/image-clients-as-library-86d17caa26ce3961.yaml index faae7d09e..90a50560d 100644 --- a/releasenotes/notes/image-clients-as-library-86d17caa26ce3961.yaml +++ b/releasenotes/notes/image-clients-as-library-86d17caa26ce3961.yaml @@ -6,6 +6,7 @@ features: so the other projects can use these modules as stable libraries without any maintenance changes. + * image_members_client(v1) * image_members_client(v2) * images_client(v2) * namespaces_client(v2) diff --git a/tempest/clients.py b/tempest/clients.py index 93ab74ba4..5e75f27d2 100644 --- a/tempest/clients.py +++ b/tempest/clients.py @@ -76,6 +76,8 @@ from tempest.lib.services.compute.volumes_client import \ from tempest.lib.services.identity.v2.endpoints_client import EndpointsClient from tempest.lib.services.identity.v2.token_client import TokenClient from tempest.lib.services.identity.v3.token_client import V3TokenClient +from tempest.lib.services.image.v1.image_members_client import \ + ImageMembersClient from tempest.lib.services.image.v2.image_members_client import \ ImageMembersClient as ImageMembersClientV2 from tempest.lib.services.image.v2.images_client import \ @@ -139,8 +141,6 @@ from tempest.services.identity.v3.json.services_client import \ from tempest.services.identity.v3.json.trusts_client import TrustsClient from tempest.services.identity.v3.json.users_clients import \ UsersClient as UsersV3Client -from tempest.services.image.v1.json.image_members_client import \ - ImageMembersClient from tempest.services.image.v1.json.images_client import ImagesClient from tempest.services.object_storage.account_client import AccountClient from tempest.services.object_storage.container_client import ContainerClient diff --git a/tempest/lib/services/image/v1/__init__.py b/tempest/lib/services/image/v1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tempest/services/image/v1/json/image_members_client.py b/tempest/lib/services/image/v1/image_members_client.py similarity index 100% rename from tempest/services/image/v1/json/image_members_client.py rename to tempest/lib/services/image/v1/image_members_client.py diff --git a/tempest/tests/lib/services/image/v1/__init__.py b/tempest/tests/lib/services/image/v1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tempest/tests/lib/services/image/v1/test_image_members_client.py b/tempest/tests/lib/services/image/v1/test_image_members_client.py new file mode 100644 index 000000000..a5a6128c0 --- /dev/null +++ b/tempest/tests/lib/services/image/v1/test_image_members_client.py @@ -0,0 +1,84 @@ +# Copyright 2016 NEC Corporation. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tempest.lib.services.image.v1 import image_members_client +from tempest.tests.lib import fake_auth_provider +from tempest.tests.lib.services import base + + +class TestImageMembersClient(base.BaseServiceTest): + FAKE_LIST_IMAGE_MEMBERS = { + "members": [ + { + "created_at": "2013-10-07T17:58:03Z", + "image_id": "dbc999e3-c52f-4200-bedd-3b18fe7f87fe", + "member_id": "123456789", + "status": "pending", + "updated_at": "2013-10-07T17:58:03Z" + }, + { + "created_at": "2013-10-07T17:58:55Z", + "image_id": "dbc999e3-c52f-4200-bedd-3b18fe7f87fe", + "member_id": "987654321", + "status": "accepted", + "updated_at": "2013-10-08T12:08:55Z" + } + ] + } + + def setUp(self): + super(TestImageMembersClient, self).setUp() + fake_auth = fake_auth_provider.FakeAuthProvider() + self.client = image_members_client.ImageMembersClient(fake_auth, + 'image', + 'regionOne') + + def _test_list_image_members(self, bytes_body=False): + self.check_service_client_function( + self.client.list_image_members, + 'tempest.lib.common.rest_client.RestClient.get', + self.FAKE_LIST_IMAGE_MEMBERS, + bytes_body, + image_id="0ae74cc5-5147-4239-9ce2-b0c580f7067e") + + def _test_create_image_member(self, bytes_body=False): + self.check_service_client_function( + self.client.create_image_member, + 'tempest.lib.common.rest_client.RestClient.put', + {}, + bytes_body, + image_id="0ae74cc5-5147-4239-9ce2-b0c580f7067e", + member_id="8989447062e04a818baf9e073fd04fa7", + status=204) + + def test_list_image_members_with_str_body(self): + self._test_list_image_members() + + def test_list_image_members_with_bytes_body(self): + self._test_list_image_members(bytes_body=True) + + def test_create_image_member_with_str_body(self): + self._test_create_image_member() + + def test_create_image_member_with_bytes_body(self): + self._test_create_image_member(bytes_body=True) + + def test_delete_image_member(self): + self.check_service_client_function( + self.client.delete_image_member, + 'tempest.lib.common.rest_client.RestClient.delete', + {}, + image_id="0ae74cc5-5147-4239-9ce2-b0c580f7067e", + member_id="8989447062e04a818baf9e073fd04fa7", + status=204)