예제 #1
0
def test_validation_exclude_success(dyn_method, exclude, params):
    validator = pydantic.PydanticValidator()
    validator.validate_method(dyn_method, params, exclude=exclude)
예제 #2
0
def test_validation_success(dyn_method, params):
    validator = pydantic.PydanticValidator()
    validator.validate_method(dyn_method, params)
    validator.validate_method(dyn_method, params)
예제 #3
0
def test_validation_error(dyn_method, params):
    validator = pydantic.PydanticValidator()

    with pytest.raises(ValidationError):
        validator.validate_method(dyn_method, params)
예제 #4
0
파일: posts.py 프로젝트: dapper91/pjrpc
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