def test_validations(self):
        type_ref = TypeReference(ModuleRef('pkg0', 'Some'), ('Template',))
        data_type = RecordType(name=type_ref, named_args=NamedArgumentList((('a', SCALAR_TYPE_INTEGER),)), type_args=())

        psb = PackageStoreBuilder()
        psb.add_type(type_ref, data_type)
        serializer = ValidateSerializer(psb.build())
        result1 = serializer.serialize_value(type_ref, {'a': {}})
        result2 = serializer.serialize_value(type_ref, {'b': 2})
        print(result1)
        print(result2)
Example #2
0
    def test_render_update_of_contract_type_con_old(self):
        from dazl.model.types import ContractIdType, UpdateType, ModuleRef, TypeReference

        module_ref = ModuleRef(package_id='00000000000000000000000000000000',
                               module_name=('ABC', ))
        type_ref = TypeReference(module=module_ref, name=('DefGhi', ))
        type_ = UpdateType(ContractIdType(type_ref))

        expected = 'Update (ContractId ABC:DefGhi)'
        actual = str(type_)

        self.assertEqual(expected, actual)
Example #3
0
def test_render_list_of_contract_type_con_old():
    from dazl.model.types import ContractIdType, ListType, ModuleRef, TypeReference

    module_ref = ModuleRef(package_id='00000000000000000000000000000000',
                           module_name=('ABC', ))
    type_ref = TypeReference(module=module_ref, name=('DefGhi', ))
    type_ = ListType(ContractIdType(type_ref))

    expected = '[ContractId ABC:DefGhi]'
    actual = str(type_)

    assert expected == actual
def test_render_update_of_contract_type_con_old():
    from dazl.model.types import ContractIdType, UpdateType, ModuleRef, TypeReference

    module_ref = ModuleRef(
        package_id=PackageRef('00000000000000000000000000000000'),
        module_name=DottedName(('ABC', )))
    type_ref = TypeReference(
        con=TypeConName(module=module_ref, name=('DefGhi', )))
    type_ = UpdateType(ContractIdType(type_ref))

    expected = 'Update (ContractId ABC:DefGhi)'
    actual = str(type_)

    assert expected == actual
Example #5
0
def test_render_update_of_contract_type_con_new():
    from dazl.damlast.daml_lf_1 import PrimType, Type
    from dazl.model.types import ModuleRef, TypeReference

    module_ref = ModuleRef(package_id='00000000000000000000000000000000',
                           module_name=('ABC', ))
    con_type = Type(con=Type.Con(
        tycon=TypeReference(module=module_ref, name=('DefGhi', )), args=()))
    cid_type = Type(
        prim=Type.Prim(prim=PrimType.CONTRACT_ID, args=(con_type, )))
    type_ = Type(prim=Type.Prim(prim=PrimType.UPDATE, args=(cid_type, )))

    expected = 'Update (ContractId ABC:DefGhi)'
    actual = str(type_)

    assert expected == actual
Example #6
0
    def test_render_list_of_contract_type_con_new(self):
        from dazl.damlast.daml_lf_1 import PrimType, Type
        from dazl.model.types import ModuleRef, TypeReference

        module_ref = ModuleRef(package_id='00000000000000000000000000000000',
                               module_name=('ABC', ))
        con_type = Type(con=Type.Con(
            tycon=TypeReference(module=module_ref, name=(
                'DefGhi', )), args=()))
        cid_type = Type(
            prim=Type.Prim(prim=PrimType.CONTRACT_ID, args=(con_type, )))
        type_ = Type(prim=Type.Prim(prim=PrimType.LIST, args=(cid_type, )))

        expected = '[ContractId ABC:DefGhi]'
        actual = str(type_)

        self.assertEqual(expected, actual)
Example #7
0
def simple_type_ref(name) -> TypeReference:
    return TypeReference(module=ModuleRef('pkg0', ()), name=dotted_name(name))