def test_validation_exclude_success(dyn_method, exclude, params): validator = pydantic.PydanticValidator() validator.validate_method(dyn_method, params, exclude=exclude)
def test_validation_success(dyn_method, params): validator = pydantic.PydanticValidator() validator.validate_method(dyn_method, params) validator.validate_method(dyn_method, params)
def test_validation_error(dyn_method, params): validator = pydantic.PydanticValidator() with pytest.raises(ValidationError): validator.validate_method(dyn_method, params)
import uuid from collections import defaultdict import pydantic from django.http.request import HttpRequest import pjrpc.server.specs.extractors.pydantic from pjrpc.server.validators import pydantic as validators from pjrpc.server.specs import openapi as specs methods = pjrpc.server.MethodRegistry() validator = validators.PydanticValidator() db = defaultdict(dict) class PostIn(pydantic.BaseModel): """ Post data. """ title: str content: str class PostOut(PostIn): """ Created post data. """ id: uuid.UUID