Pydantic requests¶
-
Back to Testing Overview
Return to the Testing overview page with all topics.
ValidationError is raised by the constructor, before send, so that attempt leaves requests empty. A valid send returns the response. Mark the test pydantic.
See Pydantic.
class CreateOrder(cqrs.PydanticRequest[CreatedOrder]):
sku: str = pydantic.Field(min_length=1)
with pytest.raises(pydantic.ValidationError):
CreateOrder(sku="")
result = await harness.mediator.send(CreateOrder(sku="book"))
assert result.order_id == "1"
Library example: examples/testing/pydantic_request.py.