Merge "Return complete response from flavors_client part-2"
This commit is contained in:
@@ -62,7 +62,8 @@ class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
id=new_flavor_id,
|
id=new_flavor_id,
|
||||||
is_public='False')['flavor']
|
is_public='False')['flavor']
|
||||||
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
|
self.addCleanup(self.client.delete_flavor, new_flavor['id'])
|
||||||
flavor_access = self.client.list_flavor_access(new_flavor_id)
|
flavor_access = (self.client.list_flavor_access(new_flavor_id)
|
||||||
|
['flavor_access'])
|
||||||
self.assertEqual(len(flavor_access), 0, str(flavor_access))
|
self.assertEqual(len(flavor_access), 0, str(flavor_access))
|
||||||
|
|
||||||
@test.idempotent_id('59e622f6-bdf6-45e3-8ba8-fedad905a6b4')
|
@test.idempotent_id('59e622f6-bdf6-45e3-8ba8-fedad905a6b4')
|
||||||
@@ -81,8 +82,9 @@ class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
"tenant_id": str(self.tenant_id),
|
"tenant_id": str(self.tenant_id),
|
||||||
"flavor_id": str(new_flavor['id']),
|
"flavor_id": str(new_flavor['id']),
|
||||||
}
|
}
|
||||||
add_body = \
|
add_body = (self.client.add_flavor_access(new_flavor['id'],
|
||||||
self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
|
self.tenant_id)
|
||||||
|
['flavor_access'])
|
||||||
self.assertIn(resp_body, add_body)
|
self.assertIn(resp_body, add_body)
|
||||||
|
|
||||||
# The flavor is present in list.
|
# The flavor is present in list.
|
||||||
@@ -90,8 +92,9 @@ class FlavorsAccessTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))
|
self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))
|
||||||
|
|
||||||
# Remove flavor access from a tenant.
|
# Remove flavor access from a tenant.
|
||||||
remove_body = \
|
remove_body = (self.client.remove_flavor_access(new_flavor['id'],
|
||||||
self.client.remove_flavor_access(new_flavor['id'], self.tenant_id)
|
self.tenant_id)
|
||||||
|
['flavor_access'])
|
||||||
self.assertNotIn(resp_body, remove_body)
|
self.assertNotIn(resp_body, remove_body)
|
||||||
|
|
||||||
# The flavor is not present in list.
|
# The flavor is not present in list.
|
||||||
|
|||||||
@@ -71,11 +71,12 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
# Assigning extra specs values that are to be set
|
# Assigning extra specs values that are to be set
|
||||||
specs = {"key1": "value1", "key2": "value2"}
|
specs = {"key1": "value1", "key2": "value2"}
|
||||||
# SET extra specs to the flavor created in setUp
|
# SET extra specs to the flavor created in setUp
|
||||||
set_body = \
|
set_body = self.client.set_flavor_extra_spec(self.flavor['id'],
|
||||||
self.client.set_flavor_extra_spec(self.flavor['id'], **specs)
|
**specs)['extra_specs']
|
||||||
self.assertEqual(set_body, specs)
|
self.assertEqual(set_body, specs)
|
||||||
# GET extra specs and verify
|
# GET extra specs and verify
|
||||||
get_body = self.client.list_flavor_extra_specs(self.flavor['id'])
|
get_body = (self.client.list_flavor_extra_specs(self.flavor['id'])
|
||||||
|
['extra_specs'])
|
||||||
self.assertEqual(get_body, specs)
|
self.assertEqual(get_body, specs)
|
||||||
|
|
||||||
# UPDATE the value of the extra specs key1
|
# UPDATE the value of the extra specs key1
|
||||||
@@ -87,7 +88,8 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
|
|
||||||
# GET extra specs and verify the value of the key2
|
# GET extra specs and verify the value of the key2
|
||||||
# is the same as before
|
# is the same as before
|
||||||
get_body = self.client.list_flavor_extra_specs(self.flavor['id'])
|
get_body = (self.client.list_flavor_extra_specs(self.flavor['id'])
|
||||||
|
['extra_specs'])
|
||||||
self.assertEqual(get_body, {"key1": "value", "key2": "value2"})
|
self.assertEqual(get_body, {"key1": "value", "key2": "value2"})
|
||||||
|
|
||||||
# UNSET extra specs that were set in this test
|
# UNSET extra specs that were set in this test
|
||||||
@@ -98,7 +100,8 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
def test_flavor_non_admin_get_all_keys(self):
|
def test_flavor_non_admin_get_all_keys(self):
|
||||||
specs = {"key1": "value1", "key2": "value2"}
|
specs = {"key1": "value1", "key2": "value2"}
|
||||||
self.client.set_flavor_extra_spec(self.flavor['id'], **specs)
|
self.client.set_flavor_extra_spec(self.flavor['id'], **specs)
|
||||||
body = self.flavors_client.list_flavor_extra_specs(self.flavor['id'])
|
body = (self.flavors_client.list_flavor_extra_specs(self.flavor['id'])
|
||||||
|
['extra_specs'])
|
||||||
|
|
||||||
for key in specs:
|
for key in specs:
|
||||||
self.assertEqual(body[key], specs[key])
|
self.assertEqual(body[key], specs[key])
|
||||||
@@ -106,7 +109,8 @@ class FlavorsExtraSpecsTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
@test.idempotent_id('12805a7f-39a3-4042-b989-701d5cad9c90')
|
@test.idempotent_id('12805a7f-39a3-4042-b989-701d5cad9c90')
|
||||||
def test_flavor_non_admin_get_specific_key(self):
|
def test_flavor_non_admin_get_specific_key(self):
|
||||||
body = self.client.set_flavor_extra_spec(self.flavor['id'],
|
body = self.client.set_flavor_extra_spec(self.flavor['id'],
|
||||||
key1="value1", key2="value2")
|
key1="value1",
|
||||||
|
key2="value2")['extra_specs']
|
||||||
self.assertEqual(body['key1'], 'value1')
|
self.assertEqual(body['key1'], 'value1')
|
||||||
self.assertIn('key2', body)
|
self.assertIn('key2', body)
|
||||||
body = self.flavors_client.show_flavor_extra_spec(
|
body = self.flavors_client.show_flavor_extra_spec(
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class FlavorsExtraSpecsNegativeTestJSON(base.BaseV2ComputeAdminTest):
|
|||||||
def test_flavor_non_admin_update_specific_key(self):
|
def test_flavor_non_admin_update_specific_key(self):
|
||||||
# non admin user is not allowed to update flavor extra spec
|
# non admin user is not allowed to update flavor extra spec
|
||||||
body = self.client.set_flavor_extra_spec(
|
body = self.client.set_flavor_extra_spec(
|
||||||
self.flavor['id'], key1="value1", key2="value2")
|
self.flavor['id'], key1="value1", key2="value2")['extra_specs']
|
||||||
self.assertEqual(body['key1'], 'value1')
|
self.assertEqual(body['key1'], 'value1')
|
||||||
self.assertRaises(lib_exc.Forbidden,
|
self.assertRaises(lib_exc.Forbidden,
|
||||||
self.flavors_client.
|
self.flavors_client.
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class FlavorsClient(service_client.ServiceClient):
|
|||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
|
self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
|
||||||
resp, body)
|
resp, body)
|
||||||
return service_client.ResponseBody(resp, body['extra_specs'])
|
return service_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
def list_flavor_extra_specs(self, flavor_id):
|
def list_flavor_extra_specs(self, flavor_id):
|
||||||
"""Gets extra Specs details of the mentioned flavor."""
|
"""Gets extra Specs details of the mentioned flavor."""
|
||||||
@@ -103,7 +103,7 @@ class FlavorsClient(service_client.ServiceClient):
|
|||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
|
self.validate_response(schema_extra_specs.set_get_flavor_extra_specs,
|
||||||
resp, body)
|
resp, body)
|
||||||
return service_client.ResponseBody(resp, body['extra_specs'])
|
return service_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
def show_flavor_extra_spec(self, flavor_id, key):
|
def show_flavor_extra_spec(self, flavor_id, key):
|
||||||
"""Gets extra Specs key-value of the mentioned flavor and key."""
|
"""Gets extra Specs key-value of the mentioned flavor and key."""
|
||||||
@@ -138,7 +138,7 @@ class FlavorsClient(service_client.ServiceClient):
|
|||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.validate_response(schema_access.add_remove_list_flavor_access,
|
self.validate_response(schema_access.add_remove_list_flavor_access,
|
||||||
resp, body)
|
resp, body)
|
||||||
return service_client.ResponseBodyList(resp, body['flavor_access'])
|
return service_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
def add_flavor_access(self, flavor_id, tenant_id):
|
def add_flavor_access(self, flavor_id, tenant_id):
|
||||||
"""Add flavor access for the specified tenant."""
|
"""Add flavor access for the specified tenant."""
|
||||||
@@ -152,7 +152,7 @@ class FlavorsClient(service_client.ServiceClient):
|
|||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.validate_response(schema_access.add_remove_list_flavor_access,
|
self.validate_response(schema_access.add_remove_list_flavor_access,
|
||||||
resp, body)
|
resp, body)
|
||||||
return service_client.ResponseBodyList(resp, body['flavor_access'])
|
return service_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
def remove_flavor_access(self, flavor_id, tenant_id):
|
def remove_flavor_access(self, flavor_id, tenant_id):
|
||||||
"""Remove flavor access from the specified tenant."""
|
"""Remove flavor access from the specified tenant."""
|
||||||
@@ -166,4 +166,4 @@ class FlavorsClient(service_client.ServiceClient):
|
|||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
self.validate_response(schema_access.add_remove_list_flavor_access,
|
self.validate_response(schema_access.add_remove_list_flavor_access,
|
||||||
resp, body)
|
resp, body)
|
||||||
return service_client.ResponseBody(resp, body['flavor_access'])
|
return service_client.ResponseBody(resp, body)
|
||||||
|
|||||||
Reference in New Issue
Block a user