Ejemplo n.º 1
0
    def setUp(self):
        self.tenant_id = "TENANT_ID"
        self.tenant_name = "TENANT_NAME"
        self.tenant_description = "TENANT_DESCRIPTION"
        self.tenant_enabled = False

        self.tenant_dict = {
            "id": self.tenant_id,
            "name": self.tenant_name,
            "description": self.tenant_description,
            "enabled": self.tenant_enabled
        }

        self.tenant_json_dict = {
            "name": self.tenant_name,
            "description": self.tenant_description,
            "enabled": self.tenant_enabled
        }

        self.href = "HREF"
        self.type = "TYPE"
        self.rel = "REL"
        self.tenants_link_dict = {
            "href": self.href,
            "type": self.type,
            "rel": self.rel
        }

        self.expected_tenant = Tenant(id_=self.tenant_id,
                                      name=self.tenant_name,
                                      description=self.tenant_description,
                                      enabled=self.tenant_enabled)

        self.tenant_serialized_str = '{"tenant": ' \
                                     '{"id": "TENANT_ID", ' \
                                     '"enabled": false, ' \
                                     '"name": "TENANT_NAME", ' \
                                     '"description": "TENANT_DESCRIPTION"}}'

        self.expected_tenant_link = TenantsLink(href=self.href,
                                                type_=self.type,
                                                rel=self.rel)
        self.tenant_list_dict = [self.tenant_dict]
        self.expected_tenants = Tenants(tenants=[self.expected_tenant])

        self.tenants_serialized_str = '{"tenants": ' \
                                      '[{"id": "TENANT_ID", ' \
                                      '"enabled": false, ' \
                                      '"name": "TENANT_NAME", ' \
                                      '"description": "TENANT_DESCRIPTION"}]}'
        self.expected_tenant_json = json.dumps(
            {"tenant": self.tenant_json_dict})
        self.expected_tenants_link_json = \
            json.dumps({"tenantsLink": self.tenants_link_dict})
Ejemplo n.º 2
0
    def create_tenant(self,
                      name=None,
                      description=None,
                      enabled=None,
                      requestslib_kwargs=None):
        """
        @summary: Creates a tenant given the provided parameters
         Maps to /tenants
        @param name: The name for the tenant
        @type name: String
        @param description: The description of the tenant
        @type description: String
        @param enabled: The status of the tenant
        @type name: Boolean
        @return: server_response
        @rtype: Response
        """

        url = '{0}/tenants'.format(self.base_url)
        tenant_request_object = Tenant(name=name,
                                       description=description,
                                       enabled=enabled)
        response = self.request('POST',
                                url,
                                response_entity_type=Tenant,
                                request_entity=tenant_request_object,
                                requestslib_kwargs=requestslib_kwargs)
        return response
Ejemplo n.º 3
0
    def setUp(self):
        self.tenant_id = "TENANT_ID"
        self.tenant_name = "TENANT_NAME"
        self.tenant_description = "TENANT_DESCRIPTION"
        self.tenant_enabled = False

        self.tenant_dict = {
            "id": self.tenant_id,
            "name": self.tenant_name,
            "description": self.tenant_description,
            "enabled": self.tenant_enabled}

        self.tenant_json_dict = {
            "name": self.tenant_name,
            "description": self.tenant_description,
            "enabled": self.tenant_enabled}

        self.href = "HREF"
        self.type = "TYPE"
        self.rel = "REL"
        self.tenants_link_dict = {"href": self.href,
                                  "type": self.type,
                                  "rel": self.rel}

        self.expected_tenant = Tenant(id_=self.tenant_id,
                                      name=self.tenant_name,
                                      description=self.tenant_description,
                                      enabled=self.tenant_enabled)

        self.tenant_serialized_str = '{"tenant": ' \
                                     '{"id": "TENANT_ID", ' \
                                     '"enabled": false, ' \
                                     '"name": "TENANT_NAME", ' \
                                     '"description": "TENANT_DESCRIPTION"}}'

        self.expected_tenant_link = TenantsLink(href=self.href,
                                                type_=self.type,
                                                rel=self.rel)
        self.tenant_list_dict = [self.tenant_dict]
        self.expected_tenants = Tenants(tenants=[self.expected_tenant])

        self.tenants_serialized_str = '{"tenants": ' \
                                      '[{"id": "TENANT_ID", ' \
                                      '"enabled": false, ' \
                                      '"name": "TENANT_NAME", ' \
                                      '"description": "TENANT_DESCRIPTION"}]}'
        self.expected_tenant_json = json.dumps(
            {"tenant": self.tenant_json_dict})
        self.expected_tenants_link_json = \
            json.dumps({"tenantsLink": self.tenants_link_dict})
Ejemplo n.º 4
0
 def test_json_to_obj(self):
     assert self.expected_tenant == Tenant._json_to_obj(
         self.tenant_serialized_str)
     assert self.expected_tenants == Tenants._json_to_obj(
         self.tenants_serialized_str)
Ejemplo n.º 5
0
 def test_dict_to_obj(self):
     assert self.expected_tenant == Tenant._dict_to_obj(self.tenant_dict)
     assert self.expected_tenant_link == TenantsLink._dict_to_obj(
         self.tenants_link_dict)
Ejemplo n.º 6
0
 def test_json_to_obj(self):
     assert self.expected_tenant == Tenant._json_to_obj(
         self.tenant_serialized_str)
     assert self.expected_tenants == Tenants._json_to_obj(
         self.tenants_serialized_str)
Ejemplo n.º 7
0
 def test_dict_to_obj(self):
     assert self.expected_tenant == Tenant._dict_to_obj(self.tenant_dict)
     assert self.expected_tenant_link == TenantsLink._dict_to_obj(
         self.tenants_link_dict)