def test_contract_id_as_dict_key(self):
        cid_a = ContractId(template_id=DUMMY_TEMPLATE_ID, contract_id='1')
        cid_b = ContractId(template_id=DUMMY_TEMPLATE_ID, contract_id='1')
        test_dict = dict()
        test_dict[cid_a] = 'hello world'

        self.assertEqual(test_dict[cid_b], 'hello world')
def test_contract_id_as_dict_key():
    cid_a = ContractId(template_id=DUMMY_TEMPLATE_ID, contract_id='1')
    cid_b = ContractId(template_id=DUMMY_TEMPLATE_ID, contract_id='1')
    test_dict = dict()
    test_dict[cid_a] = 'hello world'

    assert test_dict[cid_b] == 'hello world'
Ejemplo n.º 3
0
    def test_capture_handles_unknown_templates(self):
        parties = list('ABC')
        capture = LedgerCapture()
        capture.capture('A',
                        ContractId('0:0', template_id='some_unknown_template'),
                        dict(some_field='some_value'), datetime.utcnow())

        lines = fmt_pretty.format_entries(capture, parties)
        output = '\n'.join(lines) + '\n'
        self.assertTrue(output, 'some lines of output expected')
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0


from datetime import datetime, timedelta
from unittest import TestCase

from dazl.model.core import ContractId, Party
from dazl.model.types import UnresolvedTypeReference
from dazl.model.writing import create, CommandBuilder, CommandDefaults, CommandPayload, CreateCommand, \
    ExerciseCommand

SOME_PARTY = Party('SomeParty')
SOME_CONTRACT_ID = ContractId('#0:0', UnresolvedTypeReference('Sample.Untyped'))
DEFAULTS = CommandDefaults(
    default_party=SOME_PARTY,
    default_ledger_id='some_ledger',
    default_workflow_id='some_workflow',
    default_application_id='some_app',
    default_command_id='some_commands',
    default_ttl=timedelta(seconds=30))
DEFAULT_NOW = datetime(2019, 1, 1, 0, 0, 0)
DEFAULT_MRT = datetime(2019, 1, 1, 0, 0, 30)


class TestCommandBuilderTest(TestCase):
    """
    Tests for the various ways that helper objects are converted to :class:`CommandPayload`.
    """

    def test_single_create_untyped(self):
Ejemplo n.º 5
0
 def test_choice_meta_deconstructed(self):
     for test_name, Sample in codegen_backends().items():
         with self.subTest(test_name):
             cid = ContractId('1:0')
             command = exercise(cid, Sample.Archive, {})
             self.assertEqual(command.choice, 'Archive')