FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
netutils/tests/unit/test_conversion.py at develop · networktocode/netutils · GitHub
networktocode
/
netutils
Public
Notifications
You must be signed in to change notification settings
Fork
69
Star
256
Code
Issues
32
Pull requests
21
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
netutils
/
tests
/
unit
/
test_conversion.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (22 loc) · 1.01 KB
Breadcrumbs
netutils
/
tests
/
unit
/
test_conversion.py
Copy path
File metadata and controls
32 lines (22 loc) · 1.01 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
"""Test that configurations properly convert from undesired format to desired"""
import
glob
import
os
import
pytest
from
netutils
.
config
.
conversion
import
(
conversion_map
,
paloalto_panos_brace_to_set
,
)
MOCK_DIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"mock"
,
"config"
,
"conversion"
)
TXT_FILE
=
"_sent.txt"
CONVERTED_FILE
=
"_converted.txt"
conversion_files
=
[]
for
network_os
in
list
(
conversion_map
.
keys
()):
for
_file
in
glob
.
glob
(
f"
{
MOCK_DIR
}
/
{
network_os
}
/*
{
TXT_FILE
}
"
):
conversion_files
.
append
([
_file
,
network_os
])
@
pytest
.
mark
.
parametrize
(
"_file"
,
conversion_files
)
def
test_config_conversion
(
_file
,
get_text_data
):
# pylint: disable=redefined-outer-name
truncate_file
=
os
.
path
.
join
(
MOCK_DIR
,
_file
[
0
][:
-
len
(
TXT_FILE
)])
sent_cfg
=
get_text_data
(
os
.
path
.
join
(
MOCK_DIR
,
_file
[
0
]))
converted_cfg
=
paloalto_panos_brace_to_set
(
cfg
=
sent_cfg
,
cfg_type
=
"string"
)
received_data
=
get_text_data
(
truncate_file
+
"_converted.txt"
)
assert
converted_cfg
==
received_data
Back
|
FazBrowse Home
|
New Git URL