Merge "Make image_client use **kwargs"
diff --git a/tempest/api/image/v2/test_images_member.py b/tempest/api/image/v2/test_images_member.py
index d68ceff..98ff64b 100644
--- a/tempest/api/image/v2/test_images_member.py
+++ b/tempest/api/image/v2/test_images_member.py
@@ -20,14 +20,14 @@
def test_image_share_accept(self):
image_id = self._create_image()
member = self.os_img_client.add_image_member(image_id,
- self.alt_tenant_id)
+ member=self.alt_tenant_id)
self.assertEqual(member['member_id'], self.alt_tenant_id)
self.assertEqual(member['image_id'], image_id)
self.assertEqual(member['status'], 'pending')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
self.alt_img_client.update_image_member(image_id,
self.alt_tenant_id,
- {'status': 'accepted'})
+ status='accepted')
self.assertIn(image_id, self._list_image_ids_as_alt())
body = self.os_img_client.list_image_members(image_id)
members = body['members']
@@ -41,24 +41,24 @@
def test_image_share_reject(self):
image_id = self._create_image()
member = self.os_img_client.add_image_member(image_id,
- self.alt_tenant_id)
+ member=self.alt_tenant_id)
self.assertEqual(member['member_id'], self.alt_tenant_id)
self.assertEqual(member['image_id'], image_id)
self.assertEqual(member['status'], 'pending')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
self.alt_img_client.update_image_member(image_id,
self.alt_tenant_id,
- {'status': 'rejected'})
+ status='rejected')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
@test.idempotent_id('a6ee18b9-4378-465e-9ad9-9a6de58a3287')
def test_get_image_member(self):
image_id = self._create_image()
self.os_img_client.add_image_member(image_id,
- self.alt_tenant_id)
+ member=self.alt_tenant_id)
self.alt_img_client.update_image_member(image_id,
self.alt_tenant_id,
- {'status': 'accepted'})
+ status='accepted')
self.assertIn(image_id, self._list_image_ids_as_alt())
member = self.os_img_client.show_image_member(image_id,
@@ -71,10 +71,10 @@
def test_remove_image_member(self):
image_id = self._create_image()
self.os_img_client.add_image_member(image_id,
- self.alt_tenant_id)
+ member=self.alt_tenant_id)
self.alt_img_client.update_image_member(image_id,
self.alt_tenant_id,
- {'status': 'accepted'})
+ status='accepted')
self.assertIn(image_id, self._list_image_ids_as_alt())
self.os_img_client.delete_image_member(image_id, self.alt_tenant_id)
@@ -94,14 +94,14 @@
def test_get_private_image(self):
image_id = self._create_image()
member = self.os_img_client.add_image_member(image_id,
- self.alt_tenant_id)
+ member=self.alt_tenant_id)
self.assertEqual(member['member_id'], self.alt_tenant_id)
self.assertEqual(member['image_id'], image_id)
self.assertEqual(member['status'], 'pending')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
self.alt_img_client.update_image_member(image_id,
self.alt_tenant_id,
- {'status': 'accepted'})
+ status='accepted')
self.assertIn(image_id, self._list_image_ids_as_alt())
self.os_img_client.delete_image_member(image_id, self.alt_tenant_id)
self.assertNotIn(image_id, self._list_image_ids_as_alt())
diff --git a/tempest/api/image/v2/test_images_member_negative.py b/tempest/api/image/v2/test_images_member_negative.py
index ae8913c..d5ea291 100644
--- a/tempest/api/image/v2/test_images_member_negative.py
+++ b/tempest/api/image/v2/test_images_member_negative.py
@@ -23,22 +23,22 @@
def test_image_share_invalid_status(self):
image_id = self._create_image()
member = self.os_img_client.add_image_member(image_id,
- self.alt_tenant_id)
+ member=self.alt_tenant_id)
self.assertEqual(member['status'], 'pending')
self.assertRaises(lib_exc.BadRequest,
self.alt_img_client.update_image_member,
image_id, self.alt_tenant_id,
- {'status': 'notavalidstatus'})
+ status='notavalidstatus')
@test.attr(type=['negative'])
@test.idempotent_id('27002f74-109e-4a37-acd0-f91cd4597967')
def test_image_share_owner_cannot_accept(self):
image_id = self._create_image()
member = self.os_img_client.add_image_member(image_id,
- self.alt_tenant_id)
+ member=self.alt_tenant_id)
self.assertEqual(member['status'], 'pending')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
self.assertRaises(lib_exc.Forbidden,
self.os_img_client.update_image_member,
- image_id, self.alt_tenant_id, {'status': 'accepted'})
+ image_id, self.alt_tenant_id, status='accepted')
self.assertNotIn(image_id, self._list_image_ids_as_alt())
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 6b9ec32..a7e0f04 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -178,17 +178,17 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def add_image_member(self, image_id, member_id):
+ def add_image_member(self, image_id, **kwargs):
url = 'v2/images/%s/members' % image_id
- data = json.dumps({'member': member_id})
+ data = json.dumps(kwargs)
resp, body = self.post(url, data)
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def update_image_member(self, image_id, member_id, body):
+ def update_image_member(self, image_id, member_id, **kwargs):
url = 'v2/images/%s/members/%s' % (image_id, member_id)
- data = json.dumps(body)
+ data = json.dumps(kwargs)
resp, body = self.put(url, data)
self.expected_success(200, resp.status)
body = json.loads(body)
@@ -220,19 +220,13 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def create_namespace(self, namespace, **kwargs):
- params = {
- "namespace": namespace,
- }
+ def create_namespace(self, **kwargs):
+ """Create a namespace.
- for option in kwargs:
- value = kwargs.get(option)
- if isinstance(value, dict) or isinstance(value, tuple):
- params.update(value)
- else:
- params[option] = value
-
- data = json.dumps(params)
+ Available params: see http://developer.openstack.org/
+ api-ref-image-v2.html#createNamespace-v2
+ """
+ data = json.dumps(kwargs)
self._validate_schema(data)
resp, body = self.post('/v2/metadefs/namespaces', data)
@@ -247,18 +241,16 @@
body = json.loads(body)
return service_client.ResponseBody(resp, body)
- def update_namespace(self, namespace, visibility, **kwargs):
- params = {
- "namespace": namespace,
- "visibility": visibility
- }
- for option in kwargs:
- value = kwargs.get(option)
- if isinstance(value, dict) or isinstance(value, tuple):
- params.update(value)
- else:
- params[option] = value
+ def update_namespace(self, namespace, **kwargs):
+ """Update a namespace.
+ Available params: see http://developer.openstack.org/
+ api-ref-image-v2.html#updateNamespace-v2
+ """
+ # NOTE: On Glance API, we need to pass namespace on both URI
+ # and a request body.
+ params = {'namespace': namespace}
+ params.update(kwargs)
data = json.dumps(params)
self._validate_schema(data)
url = '/v2/metadefs/namespaces/%s' % namespace