Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Request Fallback

  • Back to Testing Overview

    Return to the Testing overview page with all topics.

    Back to Overview

Both classes are on invocations. The response on requests is the fallback's.

See Request Handler Fallback.

def commands_mapper(mapper: cqrs.RequestMap) -> None:
    mapper.bind(
        CreateOrder,
        cqrs.RequestHandlerFallback(CreateOrderHandler, CreateOrderFallback),
    )

async def test_request_fallback_answers_after_the_primary_fails() -> None:
    container = di.Container()
    async with test_harness(container, commands_mapper=commands_mapper) as harness:
        result = await harness.mediator.send(CreateOrder(sku="book"))

        assert result.source == "fallback"
        harness.invocations.assert_entered(CreateOrderHandler)
        harness.invocations.assert_entered(CreateOrderFallback)

Library example: examples/testing/test_fallback.py.