示例#1
0
    def test_object_atomic_default_false(self):
        with pytest.warns(DeprecationWarning):
            builder = CommandBuilder(atomic_default=False)
        builder.create("Sample:Untyped", {"arg": 1})
        builder.exercise(SOME_CONTRACT_ID, "SomeChoice",
                         {"choiceArg": "value"})

        expected = [
            CommandPayload(
                party=SOME_PARTY,
                ledger_id=DEFAULTS.default_ledger_id,
                workflow_id=DEFAULTS.default_workflow_id,
                application_id=DEFAULTS.default_application_id,
                command_id=DEFAULTS.default_command_id,
                commands=[CreateCommand(SOME_TEMPLATE_NAME, dict(arg=1))],
            ),
            CommandPayload(
                party=SOME_PARTY,
                ledger_id=DEFAULTS.default_ledger_id,
                workflow_id=DEFAULTS.default_workflow_id,
                application_id=DEFAULTS.default_application_id,
                command_id=DEFAULTS.default_command_id,
                commands=[
                    ExerciseCommand(SOME_CONTRACT_ID, "SomeChoice",
                                    {"choiceArg": "value"})
                ],
            ),
        ]

        actual = builder.build(DEFAULTS)

        assert expected == actual
示例#2
0
    def test_single_create_untyped(self):
        expr = create("Sample:Untyped", {"arg": 1})

        expected = [
            CommandPayload(
                party=SOME_PARTY,
                ledger_id=DEFAULTS.default_ledger_id,
                workflow_id=DEFAULTS.default_workflow_id,
                application_id=DEFAULTS.default_application_id,
                command_id=DEFAULTS.default_command_id,
                commands=[CreateCommand(SOME_TEMPLATE_NAME, dict(arg=1))],
            )
        ]
        actual = CommandBuilder.coerce(expr).build(DEFAULTS)

        assert expected == actual
示例#3
0
    def test_object_create_untyped(self):
        with pytest.warns(DeprecationWarning):
            builder = CommandBuilder()
        builder.create("Sample:Untyped", {"arg": 1})

        expected = [
            CommandPayload(
                party=SOME_PARTY,
                ledger_id=DEFAULTS.default_ledger_id,
                workflow_id=DEFAULTS.default_workflow_id,
                application_id=DEFAULTS.default_application_id,
                command_id=DEFAULTS.default_command_id,
                commands=[CreateCommand(SOME_TEMPLATE_NAME, dict(arg=1))],
            )
        ]
        actual = builder.build(DEFAULTS)

        assert expected == actual