FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi-python-client/tests/test_config.py at main · e2b-dev/openapi-python-client · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
e2b-dev
/
openapi-python-client
Public
forked from
openapi-generators/openapi-python-client
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
openapi-python-client
/
tests
/
test_config.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (50 loc) · 2 KB
Breadcrumbs
openapi-python-client
/
tests
/
test_config.py
Copy path
File metadata and controls
61 lines (50 loc) · 2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
59
60
61
import
json
import
os
from
io
import
StringIO
from
pathlib
import
Path
from
typing
import
Any
import
pytest
from
ruamel
.
yaml
import
YAML
as
_YAML
from
openapi_python_client
.
config
import
ConfigFile
class
YAML
(
_YAML
):
def
dump_to_string
(
self
,
data
:
Any
,
**
kwargs
:
Any
)
->
str
:
stream
=
StringIO
()
self
.
dump
(
data
=
data
,
stream
=
stream
,
**
kwargs
)
return
stream
.
getvalue
()
yaml
=
YAML
(
typ
=
[
"safe"
,
"string"
])
def
json_with_tabs
(
d
:
dict
)
->
str
:
return
json
.
dumps
(
d
,
indent
=
4
).
replace
(
" "
,
"
\t
"
)
@
pytest
.
mark
.
parametrize
(
"filename,dump"
,
[
(
"example.yml"
,
yaml
.
dump_to_string
),
(
"example.json"
,
json
.
dumps
),
(
"example.yaml"
,
yaml
.
dump_to_string
),
(
"example.json"
,
json_with_tabs
),
],
)
@
pytest
.
mark
.
parametrize
(
"relative"
, (
True
,
False
),
ids
=
(
"relative"
,
"absolute"
))
def
test_load_from_path
(
tmp_path
:
Path
,
filename
,
dump
,
relative
)
->
None
:
yml_file
=
tmp_path
.
joinpath
(
filename
)
if
relative
:
if
not
os
.
getenv
(
"TEST_RELATIVE"
):
pytest
.
skip
(
"Skipping relative path checks"
)
return
yml_file
=
yml_file
.
relative_to
(
Path
.
cwd
())
override1
=
{
"class_name"
:
"ExampleClass"
,
"module_name"
:
"example_module"
}
override2
=
{
"class_name"
:
"DifferentClass"
,
"module_name"
:
"different_module"
}
data
=
{
"field_prefix"
:
"blah"
,
"class_overrides"
: {
"Class1"
:
override1
,
"Class2"
:
override2
},
"project_name_override"
:
"project-name"
,
"package_name_override"
:
"package_name"
,
"package_version_override"
:
"package_version"
,
}
yml_file
.
write_text
(
dump
(
data
))
config
=
ConfigFile
.
load_from_path
(
yml_file
)
assert
config
.
field_prefix
==
"blah"
assert
config
.
class_overrides
[
"Class1"
].
model_dump
()
==
override1
assert
config
.
class_overrides
[
"Class2"
].
model_dump
()
==
override2
assert
config
.
project_name_override
==
"project-name"
assert
config
.
package_name_override
==
"package_name"
assert
config
.
package_version_override
==
"package_version"
Back
|
FazBrowse Home
|
New Git URL