1
0
Fork 0

Adding upstream version 0.5.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-04 22:22:32 +02:00
parent 303fa6e9d8
commit 97e6d74bac
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
110 changed files with 12006 additions and 0 deletions

6
tests/v3_1/__init__.py Normal file
View file

@ -0,0 +1,6 @@
from openapi_pydantic.v3.v3_1.schema import Schema, schema_validate
def test_empty_schema() -> None:
schema = schema_validate({})
assert schema == Schema()

View file

@ -0,0 +1,35 @@
import pytest
from pydantic import ValidationError
from openapi_pydantic.v3.v3_1 import Schema
@pytest.mark.parametrize(
"datatype",
(
"string",
"number",
"integer",
"boolean",
"array",
"object",
"null",
),
)
def test_good_types_parse_and_equate(datatype: str) -> None:
assert Schema(type=datatype).type == datatype
def test_bad_types_raise_validation_errors() -> None:
with pytest.raises(ValidationError):
Schema(type="invalid")
with pytest.raises(ValidationError):
Schema(anyOf=[{"type": "invalid"}])
with pytest.raises(ValidationError):
Schema(
properties={
"a": Schema(type="invalid"),
},
)