Skip to content
This repository was archived by the owner on Mar 2, 2025. It is now read-only.

Commit be298e4

Browse files
committed
Add varios syntax tests (including test for new 'syntax='iosxr')
1 parent b54d925 commit be298e4

File tree

1 file changed

+82
-5
lines changed

1 file changed

+82
-5
lines changed

tests/test_CiscoConfParse.py

+82-5
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,113 @@ def testParse_valid_filepath_01():
6262
parse = CiscoConfParse(f"{THIS_TEST_PATH}/fixtures/configs/sample_01.ios")
6363
assert len(parse.ioscfg) == 450
6464

65-
6665
def testParse_valid_filepath_02():
6766
"""Test reading a cisco ios config-file on disk (from filename in the config parameter); ref github issue #262."""
6867
parse = CiscoConfParse(config=f"{THIS_TEST_PATH}/fixtures/configs/sample_01.ios")
6968
assert len(parse.ioscfg) == 450
7069

71-
7270
def testParse_valid_filepath_03():
7371
"""Test reading an f5 config-file on disk (without the config keyword); ref github issue #262."""
7472
parse = CiscoConfParse(f"{THIS_TEST_PATH}/fixtures/configs/sample_01.f5", comment="#", syntax="junos")
7573
assert len(parse.ioscfg) == 16
7674

77-
7875
def testParse_valid_filepath_04():
7976
"""Test reading an f5 config-file on disk (from filename in the config parameter); ref github issue #262."""
8077
parse = CiscoConfParse(config=f"{THIS_TEST_PATH}/fixtures/configs/sample_01.f5", comment="#", syntax="junos")
8178
assert len(parse.ioscfg) == 16
8279

83-
8480
def testParse_valid_filepath_05():
8581
"""Test reading a junos config-file on disk (without the config keyword); ref github issue #262."""
8682
parse = CiscoConfParse(f"{THIS_TEST_PATH}/fixtures/configs/sample_01.junos", comment="#", syntax="junos")
8783
assert len(parse.ioscfg) == 79
8884

89-
9085
def testParse_valid_filepath_06():
9186
"""Test reading a junos config-file on disk (from filename in the config parameter); ref github issue #262."""
9287
parse = CiscoConfParse(config=f"{THIS_TEST_PATH}/fixtures/configs/sample_01.junos", comment="#", syntax="junos")
9388
assert len(parse.ioscfg) == 79
9489

90+
def testParse_syntax_ios_nofactory_01():
91+
"""Ensure successful parse of IOS with no factory"""
92+
parse = CiscoConfParse(
93+
"fixtures/configs/sample_01.ios",
94+
syntax="ios",
95+
comment="!",
96+
factory=False,
97+
)
98+
# No Factory ignores blank lines
99+
assert len(parse.objs) == 450
100+
101+
def testParse_syntax_ios_factory_01():
102+
"""Ensure successful parse of IOS with factory"""
103+
parse = CiscoConfParse(
104+
"fixtures/configs/sample_01.ios",
105+
syntax="ios",
106+
comment="!",
107+
factory=True,
108+
)
109+
# Factory allows blank lines to exist... the banner has a blank line
110+
assert len(parse.objs) == 451
111+
112+
def testParse_syntax_nxos_nofactory_01():
113+
"""Ensure successful parse of NXOS with no factory"""
114+
parse = CiscoConfParse(
115+
"fixtures/configs/sample_01.nxos",
116+
syntax="nxos",
117+
comment="!",
118+
factory=False,
119+
)
120+
assert len(parse.objs) == 998
121+
122+
def testParse_syntax_nxos_factory_01():
123+
"""Ensure successful parse of NXOS with factory"""
124+
parse = CiscoConfParse(
125+
"fixtures/configs/sample_01.nxos",
126+
syntax="nxos",
127+
comment="!",
128+
factory=True,
129+
)
130+
assert len(parse.objs) == 998
131+
132+
def testParse_syntax_iosxr_nofactory_01():
133+
"""Ensure successful parse of IOS XR with no factory"""
134+
parse = CiscoConfParse(
135+
"fixtures/configs/sample_01.iosxr",
136+
syntax="iosxr",
137+
comment="!",
138+
factory=False,
139+
)
140+
assert len(parse.objs) == 468
141+
142+
def testParse_syntax_iosxr_factory_01():
143+
"""Ensure successful parse of IOS XR with factory"""
144+
parse = CiscoConfParse(
145+
"fixtures/configs/sample_01.iosxr",
146+
syntax="iosxr",
147+
comment="!",
148+
factory=True,
149+
)
150+
assert len(parse.objs) == 476
151+
152+
def testParse_syntax_asa_nofactory_01():
153+
"""Ensure successful parse of ASA with no factory"""
154+
parse = CiscoConfParse(
155+
"fixtures/configs/sample_01.asa",
156+
syntax="asa",
157+
comment="!",
158+
factory=False,
159+
)
160+
assert len(parse.objs) == 422
161+
162+
def testParse_syntax_asa_factory_01():
163+
"""Ensure successful parse of ASA with factory"""
164+
parse = CiscoConfParse(
165+
"fixtures/configs/sample_01.asa",
166+
syntax="asa",
167+
comment="!",
168+
factory=True,
169+
)
170+
assert len(parse.objs) == 422
171+
95172
def testParse_parse_line_braces_01():
96173
uut = parse_line_braces("ltm pool FOO {", comment_delimiter="#")
97174
assert uut == (0, 1, "ltm pool FOO ")

0 commit comments

Comments
 (0)