Beispiel #1
0
    def _dict_to_obj(cls, data):
        """
        @summary: Converting Dictionary Representation of a Project object
            to a Project object
        @return: Project object
        @param data: Dictionary Representation of a Project object
        """
        if 'domain' in data:
            data['domain'] = Domain._dict_to_obj(data.get("domain"))

        return cls(
            id_=data.get("id"),
            name=data.get("name"),
            domain_id=data.get("domain_id"))
    def test_dict_to_obj(self):
        """
        test to verify Domain.dict_to_obj() can convert a dictionary
        representation of a Domain to a Domain object
        """
        # ARRANGE
        domain_dict = {
            'id': 'test_domain_id',
            'name': 'test_domain_name'
        }

        expected_domain_resp_obj = Domain(
            id_='test_domain_id', name='test_domain_name')

        # ACT
        domain_resp_obj = Domain._dict_to_obj(domain_dict)

        # ASSERT
        self.assertEqual(expected_domain_resp_obj, domain_resp_obj)
Beispiel #3
0
    def _dict_to_obj(cls, data):
        """
        @summary: Converting Dictionary Representation of a User object
            to a User object
        @return: User object
        @param data: Dictionary Representation of a User object
        """
        if data is None:
            return None
        data = cls._remove_extension_prefix(
            prefix=cls.NS_PREFIX, data_dict=data)
        if 'domain' in data:
            data['domain'] = Domain._dict_to_obj(data.get("domain"))

        return cls(
            id_=data.get("id"),
            name=data.get("name"),
            default_project_id=data.get("default_project_id"),
            default_region=data.get("default_region"),
            domain=data.get("domain"))