Skip to content

dishka

  • Back to Testing Overview

    Return to the Testing overview page with all topics.

    Back to Overview

The harness does not import dishka. The mediator is already built, and around wraps it. Read invocations. The harness builder stays unused.

See DI containers.

from cqrs.container.dishka import DishkaCQRSContainer

mediator = bootstrap.bootstrap(
    di_container=DishkaCQRSContainer(container),
    commands_mapper=commands_mapper,
    scope_strategy=cqrs.ScopeStrategy.HANDLER,
)
async with test_harness.around(mediator) as harness:
    await mediator.send(CreateOrder(sku="book"))
    harness.invocations.assert_entered(CreateOrderHandler)

Library example: examples/testing/dishka_container.py.