Merge "Define image_members_client of image v2 as library"
diff --git a/releasenotes/notes/image-clients-as-library-86d17caa26ce3961.yaml b/releasenotes/notes/image-clients-as-library-86d17caa26ce3961.yaml
index 46c0915..630f8ed 100644
--- a/releasenotes/notes/image-clients-as-library-86d17caa26ce3961.yaml
+++ b/releasenotes/notes/image-clients-as-library-86d17caa26ce3961.yaml
@@ -4,6 +4,7 @@
The following image service clients are defined as library interface,
so the other projects can use these modules as stable libraries
without any maintenance changes.
+ **image_members_client**
**namespaces_client**
**resource_types_client**
**schemas_client**
diff --git a/tempest/clients.py b/tempest/clients.py
index f97992d..5395e0e 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -75,6 +75,8 @@
VolumesClient as ComputeVolumesClient
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.v2.image_members_client import \
+ ImageMembersClient as ImageMembersClientV2
from tempest.lib.services.image.v2.namespaces_client import NamespacesClient
from tempest.lib.services.image.v2.resource_types_client import \
ResourceTypesClient
@@ -138,8 +140,6 @@
from tempest.services.image.v1.json.image_members_client import \
ImageMembersClient
from tempest.services.image.v1.json.images_client import ImagesClient
-from tempest.services.image.v2.json.image_members_client import \
- ImageMembersClient as ImageMembersClientV2
from tempest.services.image.v2.json.images_client import \
ImagesClient as ImagesV2Client
from tempest.services.object_storage.account_client import AccountClient
diff --git a/tempest/services/image/v2/json/image_members_client.py b/tempest/lib/services/image/v2/image_members_client.py
similarity index 100%
rename from tempest/services/image/v2/json/image_members_client.py
rename to tempest/lib/services/image/v2/image_members_client.py
diff --git a/tempest/tests/lib/services/image/v2/test_image_members_client.py b/tempest/tests/lib/services/image/v2/test_image_members_client.py
new file mode 100644
index 0000000..703b6e1
--- /dev/null
+++ b/tempest/tests/lib/services/image/v2/test_image_members_client.py
@@ -0,0 +1,90 @@
+# 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.v2 import image_members_client
+from tempest.tests.lib import fake_auth_provider
+from tempest.tests.lib.services import base
+
+
+class TestImageMembersClient(base.BaseServiceTest):
+ FAKE_CREATE_SHOW_UPDATE_IMAGE_MEMBER = {
+ "status": "pending",
+ "created_at": "2013-11-26T07:21:21Z",
+ "updated_at": "2013-11-26T07:21:21Z",
+ "image_id": "0ae74cc5-5147-4239-9ce2-b0c580f7067e",
+ "member_id": "8989447062e04a818baf9e073fd04fa7",
+ "schema": "/v2/schemas/member"
+ }
+
+ 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_show_image_member(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.show_image_member,
+ 'tempest.lib.common.rest_client.RestClient.get',
+ self.FAKE_CREATE_SHOW_UPDATE_IMAGE_MEMBER,
+ bytes_body,
+ image_id="0ae74cc5-5147-4239-9ce2-b0c580f7067e",
+ member_id="8989447062e04a818baf9e073fd04fa7")
+
+ 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.post',
+ self.FAKE_CREATE_SHOW_UPDATE_IMAGE_MEMBER,
+ bytes_body,
+ image_id="0ae74cc5-5147-4239-9ce2-b0c580f7067e",
+ member_id="8989447062e04a818baf9e073fd04fa7")
+
+ def _test_update_image_member(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.update_image_member,
+ 'tempest.lib.common.rest_client.RestClient.put',
+ self.FAKE_CREATE_SHOW_UPDATE_IMAGE_MEMBER,
+ bytes_body,
+ image_id="0ae74cc5-5147-4239-9ce2-b0c580f7067e",
+ member_id="8989447062e04a818baf9e073fd04fa7",
+ schema="/v2/schemas/member2")
+
+ def test_show_image_member_with_str_body(self):
+ self._test_show_image_member()
+
+ def test_show_image_member_with_bytes_body(self):
+ self._test_show_image_member(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)
+
+ def test_update_image_member_with_str_body(self):
+ self._test_update_image_member()
+
+ def test_update_image_member_with_bytes_body(self):
+ self._test_update_image_member(bytes_body=True)