forked from openapi-generators/openapi-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_data_type.py
More file actions
35 lines (28 loc) · 840 Bytes
/
test_data_type.py
File metadata and controls
35 lines (28 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
import openapi_python_client.schema as oai
class TestDataType:
def test_schema_bad_types(self):
import pydantic
with pytest.raises(pydantic.ValidationError):
oai.Schema(type="bad_type")
with pytest.raises(pydantic.ValidationError):
oai.Schema(anyOf=[{"type": "garbage"}])
with pytest.raises(pydantic.ValidationError):
oai.Schema(
properties={
"bad": oai.Schema(type="not_real"),
},
)
@pytest.mark.parametrize(
"type_",
(
"string",
"number",
"integer",
"boolean",
"array",
"object",
),
)
def test_schema_happy(self, type_):
assert oai.Schema(type=type_).type == type_