def test_list_to_obj(self): """ test to verify Role.dict_to_obj() can convert a dictionary representation of a Role to a Role object """ # ARRANGE roles_list = ['test_role_1', 'test_role_2'] expected_roles_response_obj = Roles() expected_roles_response_obj.append('mocked stuff') expected_roles_response_obj.append('mocked stuff') # ACT roles_resp_obj = Roles._list_to_obj(roles_list) # ASSERT self.assertEqual(expected_roles_response_obj, roles_resp_obj)
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"))