Merge "add tempest test to activate library policies"
This commit is contained in:
commit
4fa7ef60ea
|
@ -45,15 +45,23 @@ class PolicyClient(rest_client.RestClient):
|
|||
driver = '/v1/system/drivers'
|
||||
driver_path = '/v1/system/drivers/%s'
|
||||
|
||||
def _add_params_to_url(self, url, params):
|
||||
for key in params:
|
||||
url = url + '?{param_name}={param_value}'.format(
|
||||
param_name=key, param_value=params[key])
|
||||
return url
|
||||
|
||||
def _resp_helper(self, resp, body=None):
|
||||
if body:
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def create_policy(self, body):
|
||||
def create_policy(self, body, params=None):
|
||||
if params is None:
|
||||
params = {}
|
||||
body = json.dumps(body)
|
||||
resp, body = self.post(
|
||||
self.policy, body=body)
|
||||
self._add_params_to_url(self.policy, params), body=body)
|
||||
return self._resp_helper(resp, body)
|
||||
|
||||
def delete_policy(self, policy):
|
||||
|
|
|
@ -241,6 +241,26 @@ class TestPolicyLibraryBasicOps(manager_congress.ScenarioPolicyBase):
|
|||
self.assertNotIn(test_policy, new_state,
|
||||
'library policy delete not reflected in list results')
|
||||
|
||||
@decorators.attr(type='smoke')
|
||||
def test_create_library_policies(self):
|
||||
'''test the library policies by loading into policy engine'''
|
||||
|
||||
# list library policies (by name) to skip in this test, perhaps
|
||||
# because it depends on datasources not available in gate
|
||||
skip_names_list = []
|
||||
|
||||
response = self.admin_manager.congress_client.list_library_policy()
|
||||
library_policies = response['results']
|
||||
|
||||
for library_policy in library_policies:
|
||||
if library_policy['name'] not in skip_names_list:
|
||||
resp = self.admin_manager.congress_client.create_policy(
|
||||
body=None, params={'library_policy': library_policy['id']})
|
||||
self.assertEqual(resp.response['status'], '201',
|
||||
'Policy activation failed')
|
||||
self.addCleanup(self.os_admin.congress_client.delete_policy,
|
||||
resp['id'])
|
||||
|
||||
|
||||
class TestCongressDataSources(manager_congress.ScenarioPolicyBase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue