Tenants API Client - User Tests Parity.
1. Refactored tenant responses model - obj_to_json method. 2. Refactored tenant client - create user for a tenant method. 3. Refactored tenant and client tests. Change-Id: Ied4929f5387e56a33c7fbfd9e4a493c0e2442b78
This commit is contained in:
@@ -177,7 +177,7 @@ class TenantsAPI_Client(AutoMarshallingRestClient):
|
|||||||
@summary: Creates a user for a given tenant
|
@summary: Creates a user for a given tenant
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = '{0}/tenants/{1}/users'.format(self.base_url, tenant_id)
|
url = '{0}/users'.format(self.base_url)
|
||||||
user_request_object = User(id_=id_, tenant_id=tenant_id, name=name,
|
user_request_object = User(id_=id_, tenant_id=tenant_id, name=name,
|
||||||
enabled=enabled, email=email)
|
enabled=enabled, email=email)
|
||||||
response = self.request('POST', url,
|
response = self.request('POST', url,
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ class Tenant(BaseIdentityModel):
|
|||||||
self.enabled = enabled
|
self.enabled = enabled
|
||||||
|
|
||||||
def _obj_to_json(self):
|
def _obj_to_json(self):
|
||||||
json_dict = {"tenant": {"id": self.id_,
|
json_dict = {"tenant": {"name": self.name,
|
||||||
"name": self.name,
|
|
||||||
"description": self.description,
|
"description": self.description,
|
||||||
"enabled": self.enabled}}
|
"enabled": self.enabled}}
|
||||||
return json.dumps(json_dict)
|
return json.dumps(json_dict)
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ class TenantTest(TestCase):
|
|||||||
"description": self.tenant_description,
|
"description": self.tenant_description,
|
||||||
"enabled": self.tenant_enabled}
|
"enabled": self.tenant_enabled}
|
||||||
|
|
||||||
|
self.tenant_json_dict = {
|
||||||
|
"name": self.tenant_name,
|
||||||
|
"description": self.tenant_description,
|
||||||
|
"enabled": self.tenant_enabled}
|
||||||
|
|
||||||
self.href = "HREF"
|
self.href = "HREF"
|
||||||
self.type = "TYPE"
|
self.type = "TYPE"
|
||||||
self.rel = "REL"
|
self.rel = "REL"
|
||||||
@@ -46,7 +51,8 @@ class TenantTest(TestCase):
|
|||||||
'"enabled": false, ' \
|
'"enabled": false, ' \
|
||||||
'"name": "TENANT_NAME", ' \
|
'"name": "TENANT_NAME", ' \
|
||||||
'"description": "TENANT_DESCRIPTION"}]}'
|
'"description": "TENANT_DESCRIPTION"}]}'
|
||||||
self.expected_tenant_json = json.dumps({"tenant": self.tenant_dict})
|
self.expected_tenant_json = json.dumps(
|
||||||
|
{"tenant": self.tenant_json_dict})
|
||||||
self.expected_tenants_link_json = \
|
self.expected_tenants_link_json = \
|
||||||
json.dumps({"tenantsLink": self.tenants_link_dict})
|
json.dumps({"tenantsLink": self.tenants_link_dict})
|
||||||
|
|
||||||
|
|||||||
@@ -104,11 +104,11 @@ class TenantsClientTest(TestCase):
|
|||||||
self._build_assertions(actual_response, self.user_url)
|
self._build_assertions(actual_response, self.user_url)
|
||||||
|
|
||||||
def test_create_user_for_tenant(self):
|
def test_create_user_for_tenant(self):
|
||||||
HTTPretty.register_uri(HTTPretty.POST, self.tenant_users_url)
|
HTTPretty.register_uri(HTTPretty.POST, self.users_url)
|
||||||
|
|
||||||
actual_response = self.tenant_api_client.create_user_for_a_tenant(
|
actual_response = self.tenant_api_client.create_user_for_a_tenant(
|
||||||
name="Admin", tenant_id=self.tenant_id)
|
name="Admin", tenant_id=self.tenant_id)
|
||||||
self._build_assertions(actual_response, self.tenant_users_url)
|
self._build_assertions(actual_response, self.users_url)
|
||||||
|
|
||||||
def test_update_user(self):
|
def test_update_user(self):
|
||||||
HTTPretty.register_uri(HTTPretty.PUT, self.user_url)
|
HTTPretty.register_uri(HTTPretty.PUT, self.user_url)
|
||||||
|
|||||||
Reference in New Issue
Block a user