コード例 #1
0
 def test_dict_to_obj(self):
     """
     test to verify Project.dict_to_obj() can convert a dictionary
     representation of a Project to a Project object
     """
     # ARRANGE
     project_dict = {
         'id': 'test_project_id',
         'name': 'test_project_name',
         'domain': 'test_domain'
     }
     expected_project_obj = Project(id_='test_project_id',
                                    name='test_project_name',
                                    domain='mocked stuff')
     # ACT
     project_resp_obj = Project._dict_to_obj(project_dict)
     # ARRANGE
     self.assertEqual(expected_project_obj, project_resp_obj)
コード例 #2
0
ファイル: responses.py プロジェクト: Prokop/cloud_roast
 def _dict_to_obj(cls, data):
     """
     @summary: Converting Dictionary Representation of AuthResponse object
         to AuthResponse object
     @return: AuthResponse object
     @param data: Dictionary Representation of AuthResponse object
     """
     if data is None:
         return None
     return cls(
         token=AuthResponseToken._dict_to_obj(data.get("token")),
         roles=Roles._dict_to_obj(data.get("roles") or []),
         user=User._dict_to_obj(data.get("user")),
         catalog=Catalog._dict_to_obj(data.get("catalog")) or [],
         issued_at=data.get("issued_at"),
         extras=data.get("extras"),
         methods=data.get("methods"),
         project=Project._dict_to_obj(data.get("project")),
         expires_at=data.get("expires_at"))