[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
This commit is contained in:
Yaroslav Lobankov 2015-11-11 16:03:12 +03:00
parent 2b459ec052
commit 5918c45dbc
2 changed files with 21 additions and 16 deletions

View File

@ -31,8 +31,8 @@ class PoliciesTestJSON(base.BaseIdentityV3AdminTest):
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 @@ class PoliciesTestJSON(base.BaseIdentityV3AdminTest):
# 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)

View File

@ -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 @@ from tempest.common import service_client
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 @@ class PolicyClient(service_client.ServiceClient):
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)