-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_parser.py
More file actions
46 lines (31 loc) · 992 Bytes
/
test_parser.py
File metadata and controls
46 lines (31 loc) · 992 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
36
37
38
39
40
41
42
43
44
45
46
from pathlib import Path
from checkov.bicep.parser import Parser
EXAMPLES_DIR = Path(__file__).parent / "examples"
def test_parse():
# given
test_file = EXAMPLES_DIR / "playground.bicep"
# when
template, file_lines = Parser().parse(test_file)
# then
assert template is not None
assert file_lines is not None
assert len(template["parameters"]) == 5
assert len(template["variables"]) == 10
assert len(template["resources"]) == 8
assert len(file_lines) == 204
def test_parse_malformed_file():
# given
test_file = EXAMPLES_DIR / "malformed.bicep"
# when
template, file_lines = Parser().parse(test_file)
# then
assert template is None
assert file_lines is None
def test_parse_multiline_function():
# given
test_file = EXAMPLES_DIR / "multiline_function.bicep"
# when
template, file_lines = Parser().parse(test_file)
# then
assert template is not None
assert file_lines is not None