[V3] Make policy_client use **kwargs
As we discussed on
http://lists.openstack.org/pipermail/openstack-dev/2015-July/068864.html
All http POST/PUT methods need to contain **kwargs as their arguments.
This patch makes policy_client use **kwargs.
Partially implements blueprint consistent-service-method-names
Change-Id: Ic78a5e0b8fb78d88a8f7f974731be5368645af8b
diff --git a/tempest/api/identity/admin/v3/test_policies.py b/tempest/api/identity/admin/v3/test_policies.py
index d079fec..44e5c7b 100644
--- a/tempest/api/identity/admin/v3/test_policies.py
+++ b/tempest/api/identity/admin/v3/test_policies.py
@@ -31,8 +31,8 @@
for _ in range(3):
blob = data_utils.rand_name('BlobName')
policy_type = data_utils.rand_name('PolicyType')
- policy = self.policy_client.create_policy(blob,
- policy_type)['policy']
+ policy = self.policy_client.create_policy(
+ blob=blob, type=policy_type)['policy']
# Delete the Policy at the end of this method
self.addCleanup(self._delete_policy, policy['id'])
policy_ids.append(policy['id'])
@@ -49,7 +49,8 @@
# Test to update policy
blob = data_utils.rand_name('BlobName')
policy_type = data_utils.rand_name('PolicyType')
- policy = self.policy_client.create_policy(blob, policy_type)['policy']
+ policy = self.policy_client.create_policy(blob=blob,
+ type=policy_type)['policy']
self.addCleanup(self._delete_policy, policy['id'])
self.assertIn('id', policy)
self.assertIn('type', policy)
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index 3231bb0..ecc9df7 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+"""
+http://developer.openstack.org/api-ref-identity-v3.html#policies-v3
+"""
+
from oslo_serialization import jsonutils as json
from tempest.common import service_client
@@ -21,13 +25,13 @@
class PolicyClient(service_client.ServiceClient):
api_version = "v3"
- def create_policy(self, blob, type):
- """Creates a Policy."""
- post_body = {
- "blob": blob,
- "type": type
- }
- post_body = json.dumps({'policy': post_body})
+ def create_policy(self, **kwargs):
+ """Creates a Policy.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#createPolicy
+ """
+ post_body = json.dumps({'policy': kwargs})
resp, body = self.post('policies', post_body)
self.expected_success(201, resp.status)
body = json.loads(body)
@@ -49,12 +53,12 @@
return service_client.ResponseBody(resp, body)
def update_policy(self, policy_id, **kwargs):
- """Updates a policy."""
- type = kwargs.get('type')
- post_body = {
- 'type': type
- }
- post_body = json.dumps({'policy': post_body})
+ """Updates a policy.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-identity-v3.html#updatePolicy
+ """
+ post_body = json.dumps({'policy': kwargs})
url = 'policies/%s' % policy_id
resp, body = self.patch(url, post_body)
self.expected_success(200, resp.status)