forked from openapi-generators/openapi-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
58 lines (46 loc) · 1.67 KB
/
conftest.py
File metadata and controls
58 lines (46 loc) · 1.67 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from typing import Callable
import pytest
from openapi_python_client.parser.properties import EnumProperty, ModelProperty
@pytest.fixture
def model_property_factory() -> Callable[..., ModelProperty]:
"""
This fixture surfaces in the test as a function which manufactures ModelProperties with defaults.
You can pass the same params into this as the ModelProperty constructor to override defaults.
"""
from openapi_python_client.parser.properties import Class
def _factory(**kwargs):
kwargs = {
"name": "",
"description": "",
"required": True,
"nullable": True,
"default": None,
"class_info": Class(name="", module_name=""),
"required_properties": [],
"optional_properties": [],
"relative_imports": set(),
"additional_properties": False,
**kwargs,
}
return ModelProperty(**kwargs)
return _factory
@pytest.fixture
def enum_property_factory() -> Callable[..., EnumProperty]:
"""
This fixture surfaces in the test as a function which manufactures EnumProperties with defaults.
You can pass the same params into this as the EnumProerty constructor to override defaults.
"""
from openapi_python_client.parser.properties import Class
def _factory(**kwargs):
kwargs = {
"name": "test",
"required": True,
"nullable": False,
"default": None,
"class_info": Class(name="", module_name=""),
"values": {},
"value_type": str,
**kwargs,
}
return EnumProperty(**kwargs)
return _factory