def test_api_consistency(self):
        impl = _PartyClientImpl(MetricEvents(), Invoker(), Party('party'))

        apc = AIOPartyClient(impl)
        tpc = SimplePartyClient(impl)

        callable_apcs = {
            key: getattr(apc, key)
            for key in dir(apc)
            if not key.startswith('_') and callable(getattr(apc, key))
        }
        callable_tpcs = {
            key: getattr(tpc, key)
            for key in dir(tpc)
            if not key.startswith('_') and callable(getattr(tpc, key))
        }

        self.assertEqual(sorted(set(callable_apcs.keys())),
                         sorted(set(callable_tpcs.keys())))
def test_api_consistency():
    from dazl.client._network_client_impl import _NetworkImpl
    from dazl.client._party_client_impl import _PartyClientImpl
    impl = _PartyClientImpl(_NetworkImpl(), Party('party'))

    apc = AIOPartyClient(impl)
    tpc = SimplePartyClient(impl)

    callable_apcs = {
        key: getattr(apc, key)
        for key in dir(apc)
        if not key.startswith('_') and callable(getattr(apc, key))
    }
    callable_tpcs = {
        key: getattr(tpc, key)
        for key in dir(tpc)
        if not key.startswith('_') and callable(getattr(tpc, key))
    }

    assert sorted(set(callable_apcs.keys())) == sorted(
        set(callable_tpcs.keys()))
Example #3
0
def test_party_config_allows_list():
    config = NetworkConfig.parse_kwargs(parties=['Bob'], participant_url='http://nowhere/')
    assert config.parties[0].party == Party('Bob')
    assert config.parties[0].url == 'http://nowhere/'
Example #4
0
def test_party_config_allows_single_string():
    config = NetworkConfig.parse_kwargs(parties='Bob', participant_url='http://nowhere/')
    assert config.parties[0].party == Party('Bob')
    assert config.parties[0].url == 'http://nowhere/'
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import logging
from pathlib import Path
from unittest import TestCase

from dazl import sandbox, exercise, setup_default_logger
from dazl.client.api import simple_client
from dazl.model.core import Party

DAML_FILE = Path(__file__).parent.parent / 'resources' / 'Simple.daml'
PARTY = Party('Operator')
OperatorRole = 'Simple.OperatorRole'
OperatorNotification = 'Simple.OperatorNotification'

setup_default_logger(logging.DEBUG)


class TestThreadsafeMethods(TestCase):
    def test_threadsafe_methods(self):
        with sandbox(DAML_FILE) as proc:
            with simple_client(proc.url, PARTY) as client:
                client.ready()
                client.submit_create(OperatorRole, {'operator': PARTY})

                operator_cid, _ = client.find_one(OperatorRole)

                client.submit_exercise(operator_cid, 'PublishMany',
                                       dict(count=5))
Example #6
0
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

import logging
from asyncio import sleep
from unittest import TestCase

from aiohttp import ClientSession

from dazl import Network, sandbox, create, exercise_by_key
from dazl.model.core import Party
from .dars import TestServer as TestServerDar

Alice = Party("Alice")
Bob = Party("Bob")
Carol = Party("Carol")

LOG = logging.getLogger('test_server')


class TestServer(TestCase):
    def test_server_endpoint(self):
        SERVER_PORT = 53390
        with sandbox(TestServerDar) as proc:
            bot_main(sandbox_url=proc.url, server_port=SERVER_PORT)


def ensure_person_contract(network: Network, party: Party):
    network.aio_party(party).add_ledger_ready(
        lambda _: create('TestServer:Person', dict(party=party)))
 def test_party_config_allows_list(self):
     config = NetworkConfig.parse_kwargs(parties=['Bob'],
                                         participant_url='http://nowhere/')
     self.assertEqual(config.parties[0].party, Party('Bob'))
     self.assertEqual(config.parties[0].url, 'http://nowhere/')
# 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):