Ejemplo n.º 1
0
    async def deserialize(data: dict):
        """
        Create the object from a previously serialized object.

        :param data: The output of the "serialize" call
        Example:
        source_id = 'foobar123'
        name = 'Address Schema'
        version = '1.0'
        attrs = ['address', 'city', 'state']
        payment_handle = 0
        schema1 = await Schema.create(source_id, name, version, attrs, payment_handle)
        data1 = await schema1.serialize()
        :return: A re-instantiated object
        """
        try:
            # Todo: Find better way to access attr_names. Potential for issues.
            schema = await Schema._deserialize("vcx_schema_deserialize",
                                               json.dumps(data),
                                               data['data']['source_id'],
                                               data['data']['name'],
                                               data['data']['version'],
                                               data['data']['data'])

            schema.schema_id = await schema.get_schema_id()
            return schema
        except KeyError:
            raise VcxError(ErrorCode.InvalidSchema, error_message(ErrorCode.InvalidSchema))
Ejemplo n.º 2
0
 async def deserialize(data: dict):
     try:
         credential_def = await CredentialDef._deserialize(
             "vcx_credentialdef_deserialize", json.dumps(data),
             data['source_id'], data['name'], data['id'])
         return credential_def
     except KeyError:
         raise VcxError(ErrorCode.InvalidCredentialDef,
                        error_message(ErrorCode.InvalidCredentialDef))
Ejemplo n.º 3
0
    async def deserialize(data: dict):
        try:
            # Todo: Find better way to access attr_names. Potential for issues.
            schema = await Schema._deserialize("vcx_schema_deserialize",
                                               json.dumps(data),
                                               data['source_id'], data['name'],
                                               data['version'], data['data'])

            schema.schema_id = await schema.get_schema_id()
            return schema
        except KeyError:
            raise VcxError(ErrorCode.InvalidSchema,
                           error_message(ErrorCode.InvalidSchema))
Ejemplo n.º 4
0
    async def deserialize(data: dict):
        """
        Create the object from a previously serialized object.

        :param data: The output of the "serialize" call
        :return: A re-instantiated object
        """
        try:
            credential_def = await CredentialDef._deserialize(
                "vcx_credentialdef_deserialize", json.dumps(data),
                data['data']['source_id'], data['data']['name'],
                data['data']['id'])
            return credential_def
        except KeyError:
            raise VcxError(ErrorCode.InvalidCredentialDef,
                           error_message(ErrorCode.InvalidCredentialDef))
Ejemplo n.º 5
0
    async def deserialize(data: dict):
        """
        Create the object from a previously serialized object.

        :param data: The output of the "serialize" call
        :return: A re-instantiated object
        """
        try:
            # Todo: Find better way to access attr_names. Potential for issues.
            schema = await Schema._deserialize("vcx_schema_deserialize",
                                               json.dumps(data),
                                               data['data']['source_id'],
                                               data['data']['name'],
                                               data['data']['version'],
                                               data['data']['data'])

            schema.schema_id = await schema.get_schema_id()
            return schema
        except KeyError:
            raise VcxError(ErrorCode.InvalidSchema,
                           error_message(ErrorCode.InvalidSchema))
Ejemplo n.º 6
0
    async def deserialize(data: dict):
        """
        Create the object from a previously serialized object.

        :param data: The output of the "serialize" call
        Example:
        source_id = 'foobar123'
        schema_name = 'Schema Name'
        payment_handle = 0
        credential_def1 = await CredentialDef.create(source_id, name, schema_id, payment_handle)
        data1 = await credential_def1.serialize()
        credential_def2 = await CredentialDef.deserialize(data1)
        :return: A re-instantiated object
        """
        try:
            credential_def = await CredentialDef._deserialize("vcx_credentialdef_deserialize",
                                                              json.dumps(data),
                                                              data['data']['source_id'],
                                                              data['data']['name'],
                                                              data['data']['id'])
            return credential_def
        except KeyError:
            raise VcxError(ErrorCode.InvalidCredentialDef, error_message(ErrorCode.InvalidCredentialDef))
Ejemplo n.º 7
0
async def test_error_message():
    assert error_message(
        ErrorCode.NotReady) == 'Object not ready for specified action'
Ejemplo n.º 8
0
def test_c_error_msg():
    assert error_message(0) == 'Success'