nac-test 0.3.0a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nac_test/__init__.py +7 -0
- nac_test/__main__.py +8 -0
- nac_test/cli/__init__.py +0 -0
- nac_test/cli/main.py +224 -0
- nac_test/pabot.py +38 -0
- nac_test/robot_writer.py +191 -0
- nac_test-0.3.0a0.dist-info/LICENSE +385 -0
- nac_test-0.3.0a0.dist-info/METADATA +250 -0
- nac_test-0.3.0a0.dist-info/RECORD +11 -0
- nac_test-0.3.0a0.dist-info/WHEEL +4 -0
- nac_test-0.3.0a0.dist-info/entry_points.txt +4 -0
nac_test/__init__.py
ADDED
nac_test/__main__.py
ADDED
nac_test/cli/__init__.py
ADDED
|
File without changes
|
nac_test/cli/main.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
# Copyright: (c) 2022, Daniel Schmidt <danischm@cisco.com>
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
import errorhandler
|
|
9
|
+
|
|
10
|
+
import typer
|
|
11
|
+
from typing_extensions import Annotated
|
|
12
|
+
from enum import Enum
|
|
13
|
+
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
import nac_test.pabot
|
|
17
|
+
import nac_test.robot_writer
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
app = typer.Typer(add_completion=False)
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
error_handler = errorhandler.ErrorHandler()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def configure_logging(level: str) -> None:
|
|
28
|
+
if level == "DEBUG":
|
|
29
|
+
lev = logging.DEBUG
|
|
30
|
+
elif level == "INFO":
|
|
31
|
+
lev = logging.INFO
|
|
32
|
+
elif level == "WARNING":
|
|
33
|
+
lev = logging.WARNING
|
|
34
|
+
elif level == "ERROR":
|
|
35
|
+
lev = logging.ERROR
|
|
36
|
+
else:
|
|
37
|
+
lev = logging.CRITICAL
|
|
38
|
+
logger = logging.getLogger()
|
|
39
|
+
handler = logging.StreamHandler(sys.stdout)
|
|
40
|
+
handler.setFormatter(logging.Formatter("%(levelname)s - %(message)s"))
|
|
41
|
+
logger.addHandler(handler)
|
|
42
|
+
logger.setLevel(lev)
|
|
43
|
+
error_handler.reset()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class VerbosityLevel(str, Enum):
|
|
47
|
+
debug = "DEBUG"
|
|
48
|
+
info = "INFO"
|
|
49
|
+
warning = "WARNING"
|
|
50
|
+
error = "ERROR"
|
|
51
|
+
critical = "CRITICAL"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def version_callback(value: bool) -> None:
|
|
55
|
+
if value:
|
|
56
|
+
print(f"nac-test, version {nac_test.__version__}")
|
|
57
|
+
raise typer.Exit()
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
Verbosity = Annotated[
|
|
61
|
+
VerbosityLevel,
|
|
62
|
+
typer.Option(
|
|
63
|
+
"-v",
|
|
64
|
+
"--verbosity",
|
|
65
|
+
help="Verbosity level.",
|
|
66
|
+
envvar="NAC_VALIDATE_VERBOSITY",
|
|
67
|
+
is_eager=True,
|
|
68
|
+
),
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Data = Annotated[
|
|
73
|
+
list[Path],
|
|
74
|
+
typer.Option(
|
|
75
|
+
"-d",
|
|
76
|
+
"--data",
|
|
77
|
+
exists=True,
|
|
78
|
+
dir_okay=True,
|
|
79
|
+
file_okay=True,
|
|
80
|
+
help="Path to data YAML files.",
|
|
81
|
+
envvar="NAC_TEST_DATA",
|
|
82
|
+
),
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
Templates = Annotated[
|
|
87
|
+
Path,
|
|
88
|
+
typer.Option(
|
|
89
|
+
"-t",
|
|
90
|
+
"--templates",
|
|
91
|
+
exists=True,
|
|
92
|
+
dir_okay=True,
|
|
93
|
+
file_okay=False,
|
|
94
|
+
help="Path to test templates.",
|
|
95
|
+
envvar="NAC_TEST_TEMPLATES",
|
|
96
|
+
),
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
Filters = Annotated[
|
|
101
|
+
Path | None,
|
|
102
|
+
typer.Option(
|
|
103
|
+
"-f",
|
|
104
|
+
"--filters",
|
|
105
|
+
exists=True,
|
|
106
|
+
dir_okay=True,
|
|
107
|
+
file_okay=False,
|
|
108
|
+
help="Path to Jinja filters.",
|
|
109
|
+
envvar="NAC_TEST_FILTERS",
|
|
110
|
+
),
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
Tests = Annotated[
|
|
115
|
+
Path | None,
|
|
116
|
+
typer.Option(
|
|
117
|
+
"--tests",
|
|
118
|
+
exists=True,
|
|
119
|
+
dir_okay=True,
|
|
120
|
+
file_okay=False,
|
|
121
|
+
help="Path to Jinja tests.",
|
|
122
|
+
envvar="NAC_TEST_TESTS",
|
|
123
|
+
),
|
|
124
|
+
]
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
Output = Annotated[
|
|
128
|
+
Path,
|
|
129
|
+
typer.Option(
|
|
130
|
+
"-o",
|
|
131
|
+
"--output",
|
|
132
|
+
exists=False,
|
|
133
|
+
dir_okay=True,
|
|
134
|
+
file_okay=False,
|
|
135
|
+
help="Path to output directory.",
|
|
136
|
+
envvar="NAC_TEST_OUTPUT",
|
|
137
|
+
),
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
Include = Annotated[
|
|
142
|
+
list[str],
|
|
143
|
+
typer.Option(
|
|
144
|
+
"-i",
|
|
145
|
+
"--include",
|
|
146
|
+
help="Selects the test cases by tag (include).",
|
|
147
|
+
envvar="NAC_TEST_INCLUDE",
|
|
148
|
+
),
|
|
149
|
+
]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
Exclude = Annotated[
|
|
153
|
+
list[str],
|
|
154
|
+
typer.Option(
|
|
155
|
+
"-e",
|
|
156
|
+
"--exclude",
|
|
157
|
+
help="Selects the test cases by tag (exclude).",
|
|
158
|
+
envvar="NAC_TEST_EXCLUDE",
|
|
159
|
+
),
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
RenderOnly = Annotated[
|
|
164
|
+
bool,
|
|
165
|
+
typer.Option(
|
|
166
|
+
"--render-only",
|
|
167
|
+
help="Only render tests without executing them.",
|
|
168
|
+
envvar="NAC_TEST_RENDER_ONLY",
|
|
169
|
+
),
|
|
170
|
+
]
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
DryRun = Annotated[
|
|
174
|
+
bool,
|
|
175
|
+
typer.Option(
|
|
176
|
+
"--dry-run",
|
|
177
|
+
help="Dry run flag. See robot dry run mode.",
|
|
178
|
+
envvar="NAC_TEST_DRY_RUN",
|
|
179
|
+
),
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
Version = Annotated[
|
|
184
|
+
bool,
|
|
185
|
+
typer.Option(
|
|
186
|
+
"--version",
|
|
187
|
+
callback=version_callback,
|
|
188
|
+
help="Display version number.",
|
|
189
|
+
is_eager=True,
|
|
190
|
+
),
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
@app.command()
|
|
195
|
+
def main(
|
|
196
|
+
data: Data,
|
|
197
|
+
templates: Templates,
|
|
198
|
+
output: Output,
|
|
199
|
+
filters: Filters = None,
|
|
200
|
+
tests: Tests = None,
|
|
201
|
+
include: Include = [],
|
|
202
|
+
exclude: Exclude = [],
|
|
203
|
+
render_only: RenderOnly = False,
|
|
204
|
+
dry_run: DryRun = False,
|
|
205
|
+
verbosity: Verbosity = VerbosityLevel.warning,
|
|
206
|
+
version: Version = False,
|
|
207
|
+
) -> None:
|
|
208
|
+
"""A CLI tool to render and execute Robot Framework tests using Jinja templating."""
|
|
209
|
+
configure_logging(verbosity)
|
|
210
|
+
|
|
211
|
+
writer = nac_test.robot_writer.RobotWriter(data, filters, tests, include, exclude)
|
|
212
|
+
writer.write(templates, output)
|
|
213
|
+
if not render_only:
|
|
214
|
+
nac_test.pabot.run_pabot(
|
|
215
|
+
output, include, exclude, dry_run, verbosity == VerbosityLevel.debug
|
|
216
|
+
)
|
|
217
|
+
exit()
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def exit() -> None:
|
|
221
|
+
if error_handler.fired:
|
|
222
|
+
raise typer.Exit(1)
|
|
223
|
+
else:
|
|
224
|
+
raise typer.Exit(0)
|
nac_test/pabot.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
# Copyright: (c) 2022, Daniel Schmidt <danischm@cisco.com>
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import pabot.pabot
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def run_pabot(
|
|
11
|
+
path: Path,
|
|
12
|
+
include: list[str] = [],
|
|
13
|
+
exclude: list[str] = [],
|
|
14
|
+
dry_run: bool = False,
|
|
15
|
+
verbose: bool = False,
|
|
16
|
+
) -> None:
|
|
17
|
+
"""Run pabot"""
|
|
18
|
+
args = ["--pabotlib", "--pabotlibport", "0"]
|
|
19
|
+
if verbose:
|
|
20
|
+
args.append("--verbose")
|
|
21
|
+
if dry_run:
|
|
22
|
+
args.append("--dryrun")
|
|
23
|
+
for i in include:
|
|
24
|
+
args.extend(["--include", i])
|
|
25
|
+
for e in exclude:
|
|
26
|
+
args.extend(["--exclude", e])
|
|
27
|
+
args.extend(
|
|
28
|
+
[
|
|
29
|
+
"-d",
|
|
30
|
+
str(path),
|
|
31
|
+
"--skiponfailure",
|
|
32
|
+
"non-critical",
|
|
33
|
+
"-x",
|
|
34
|
+
"xunit.xml",
|
|
35
|
+
str(path),
|
|
36
|
+
]
|
|
37
|
+
)
|
|
38
|
+
pabot.pabot.main(args)
|
nac_test/robot_writer.py
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
# Copyright: (c) 2022, Daniel Schmidt <danischm@cisco.com>
|
|
4
|
+
|
|
5
|
+
import importlib.util
|
|
6
|
+
import json
|
|
7
|
+
import logging
|
|
8
|
+
import os
|
|
9
|
+
import pathlib
|
|
10
|
+
import re
|
|
11
|
+
import shutil
|
|
12
|
+
import sys
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from jinja2 import ChainableUndefined, Environment, FileSystemLoader # type: ignore
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
from nac_yaml import yaml
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class RobotWriter:
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
data_paths: list[Path],
|
|
27
|
+
filters_path: Path | None,
|
|
28
|
+
tests_path: Path | None,
|
|
29
|
+
include_tags: list[str] = [],
|
|
30
|
+
exclude_tags: list[str] = [],
|
|
31
|
+
) -> None:
|
|
32
|
+
logger.info("Loading yaml files from %s", data_paths)
|
|
33
|
+
self.data = yaml.load_yaml_files(data_paths)
|
|
34
|
+
self.filters: dict[str, Any] = {}
|
|
35
|
+
self.include_tags = include_tags
|
|
36
|
+
self.exclude_tags = exclude_tags
|
|
37
|
+
if filters_path:
|
|
38
|
+
logger.info("Loading filters")
|
|
39
|
+
for filename in os.listdir(filters_path):
|
|
40
|
+
if Path(filename).suffix == ".py":
|
|
41
|
+
file_path = Path(filters_path, filename)
|
|
42
|
+
spec = importlib.util.spec_from_file_location(
|
|
43
|
+
"nac_test.filters", file_path
|
|
44
|
+
)
|
|
45
|
+
if spec is not None:
|
|
46
|
+
mod = importlib.util.module_from_spec(spec)
|
|
47
|
+
sys.modules["nac_test.filters"] = mod
|
|
48
|
+
if spec.loader is not None:
|
|
49
|
+
spec.loader.exec_module(mod)
|
|
50
|
+
self.filters[mod.Filter.name] = mod.Filter
|
|
51
|
+
self.tests: dict[str, Any] = {}
|
|
52
|
+
if tests_path:
|
|
53
|
+
logger.info("Loading tests")
|
|
54
|
+
for filename in os.listdir(tests_path):
|
|
55
|
+
if Path(filename).suffix == ".py":
|
|
56
|
+
file_path = Path(tests_path, filename)
|
|
57
|
+
spec = importlib.util.spec_from_file_location(
|
|
58
|
+
"nac_test.tests", file_path
|
|
59
|
+
)
|
|
60
|
+
if spec is not None:
|
|
61
|
+
mod = importlib.util.module_from_spec(spec)
|
|
62
|
+
sys.modules["nac_test.tests"] = mod
|
|
63
|
+
if spec.loader is not None:
|
|
64
|
+
spec.loader.exec_module(mod)
|
|
65
|
+
self.tests[mod.Test.name] = mod.Test
|
|
66
|
+
|
|
67
|
+
def render_template(
|
|
68
|
+
self, template_path: Path, output_path: Path, env: Environment, **kwargs: Any
|
|
69
|
+
) -> None:
|
|
70
|
+
"""Render single robot jinja template"""
|
|
71
|
+
logger.info("Render robot template: %s", template_path)
|
|
72
|
+
# add robot tags to kwargs
|
|
73
|
+
kwargs["robot_include_tags"] = self.include_tags
|
|
74
|
+
kwargs["robot_exclude_tags"] = self.exclude_tags
|
|
75
|
+
# create output directory if it does not exist yet
|
|
76
|
+
pathlib.Path(os.path.dirname(output_path)).mkdir(parents=True, exist_ok=True)
|
|
77
|
+
|
|
78
|
+
template = env.get_template(str(template_path))
|
|
79
|
+
# hack to convert nested ordereddict to dict, to avoid duplicate dict keys, e.g. 'tag'
|
|
80
|
+
# json roundtrip should be safe as everything should be serializable
|
|
81
|
+
data = json.loads(json.dumps(self.data))
|
|
82
|
+
result = template.render(data, **kwargs)
|
|
83
|
+
|
|
84
|
+
# remove extra empty lines
|
|
85
|
+
lines = result.splitlines()
|
|
86
|
+
cleaned_lines = []
|
|
87
|
+
for index, line in enumerate(lines):
|
|
88
|
+
if len(line.strip()):
|
|
89
|
+
cleaned_lines.append(line)
|
|
90
|
+
else:
|
|
91
|
+
if index + 1 < len(lines):
|
|
92
|
+
next_line = lines[index + 1]
|
|
93
|
+
if len(next_line) and not next_line[0].isspace():
|
|
94
|
+
cleaned_lines.append(line)
|
|
95
|
+
result = os.linesep.join(cleaned_lines)
|
|
96
|
+
|
|
97
|
+
with open(output_path, "w") as file:
|
|
98
|
+
file.write(result)
|
|
99
|
+
|
|
100
|
+
def _fix_duplicate_path(self, *paths: str) -> Path:
|
|
101
|
+
"""Helper function to detect existing paths with non-matching case. Returns a unique path to work with case-insensitve filesystems."""
|
|
102
|
+
directory = os.path.join(*paths[:-1])
|
|
103
|
+
if os.path.exists(directory):
|
|
104
|
+
entries = os.listdir(directory)
|
|
105
|
+
lower_case_entries = [path.lower() for path in entries]
|
|
106
|
+
if paths[-1].lower() in lower_case_entries and paths[-1] not in entries:
|
|
107
|
+
return Path(*paths[:-1], "_" + paths[-1])
|
|
108
|
+
return Path(os.path.join(*paths))
|
|
109
|
+
|
|
110
|
+
def write(self, templates_path: Path, output_path: Path) -> None:
|
|
111
|
+
"""Render Robot test suites."""
|
|
112
|
+
env = Environment(
|
|
113
|
+
loader=FileSystemLoader(templates_path),
|
|
114
|
+
undefined=ChainableUndefined,
|
|
115
|
+
lstrip_blocks=True,
|
|
116
|
+
trim_blocks=True,
|
|
117
|
+
)
|
|
118
|
+
for name, filter in self.filters.items():
|
|
119
|
+
env.filters[name] = filter.filter
|
|
120
|
+
for name, test in self.tests.items():
|
|
121
|
+
env.tests[name] = test.test
|
|
122
|
+
|
|
123
|
+
for dir, _, files in os.walk(templates_path):
|
|
124
|
+
for filename in files:
|
|
125
|
+
if Path(filename).suffix not in [".robot", ".resource", ".j2"]:
|
|
126
|
+
logger.info(
|
|
127
|
+
"Skip file with unknown file extension (not one of .robot, .resource or .j2): %s",
|
|
128
|
+
Path(dir, filename),
|
|
129
|
+
)
|
|
130
|
+
out = Path(output_path, os.path.relpath(dir, templates_path))
|
|
131
|
+
pathlib.Path(out).mkdir(parents=True, exist_ok=True)
|
|
132
|
+
shutil.copy(Path(dir, filename), out)
|
|
133
|
+
continue
|
|
134
|
+
rel = os.path.relpath(dir, templates_path)
|
|
135
|
+
t_path = Path(rel, filename)
|
|
136
|
+
|
|
137
|
+
# search for directives
|
|
138
|
+
pattern = re.compile("{#(.+?)#}")
|
|
139
|
+
content = ""
|
|
140
|
+
next_template = False
|
|
141
|
+
try:
|
|
142
|
+
with open(Path(dir, filename), "r") as file:
|
|
143
|
+
content = file.read()
|
|
144
|
+
except: # noqa: E722
|
|
145
|
+
logger.warning("Could not open/read file: %s", Path(dir, filename))
|
|
146
|
+
continue
|
|
147
|
+
for match in re.finditer(pattern, content):
|
|
148
|
+
params = match.group().split(" ")
|
|
149
|
+
if len(params) == 6 and params[1] in [
|
|
150
|
+
"iterate_list",
|
|
151
|
+
"iterate_list_folder",
|
|
152
|
+
]:
|
|
153
|
+
next_template = True
|
|
154
|
+
path = params[2].split(".")
|
|
155
|
+
attr = params[3]
|
|
156
|
+
elem = self.data
|
|
157
|
+
for p in path:
|
|
158
|
+
elem = elem.get(p, {})
|
|
159
|
+
if not isinstance(elem, list):
|
|
160
|
+
continue
|
|
161
|
+
for item in elem:
|
|
162
|
+
value = str(item.get(attr))
|
|
163
|
+
if value is None:
|
|
164
|
+
continue
|
|
165
|
+
extra: dict[str, Any] = {}
|
|
166
|
+
if "[" in params[4]:
|
|
167
|
+
index = params[4].split("[")[1].split("]")[0]
|
|
168
|
+
extra_list: list[Any] = [None] * (int(index) + 1)
|
|
169
|
+
extra_list[int(index)] = value
|
|
170
|
+
extra = {params[4].split("[")[0]: extra_list}
|
|
171
|
+
else:
|
|
172
|
+
extra = {params[4]: value}
|
|
173
|
+
if params[1] == "iterate_list":
|
|
174
|
+
o_dir = self._fix_duplicate_path(
|
|
175
|
+
str(output_path), rel, value
|
|
176
|
+
)
|
|
177
|
+
o_path = Path(o_dir, filename)
|
|
178
|
+
else:
|
|
179
|
+
foldername = os.path.splitext(filename)[0]
|
|
180
|
+
new_filename = (
|
|
181
|
+
value + "." + os.path.splitext(filename)[1][1:]
|
|
182
|
+
)
|
|
183
|
+
o_path = self._fix_duplicate_path(
|
|
184
|
+
str(output_path), rel, foldername, new_filename
|
|
185
|
+
)
|
|
186
|
+
self.render_template(t_path, Path(o_path), env, **extra)
|
|
187
|
+
if next_template:
|
|
188
|
+
continue
|
|
189
|
+
|
|
190
|
+
o_path = Path(output_path, rel, filename)
|
|
191
|
+
self.render_template(t_path, o_path, env)
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
Mozilla Public License Version 2.0
|
|
2
|
+
==================================
|
|
3
|
+
|
|
4
|
+
1. Definitions
|
|
5
|
+
|
|
6
|
+
--------------
|
|
7
|
+
|
|
8
|
+
1.1. "Contributor"
|
|
9
|
+
means each individual or legal entity that creates, contributes to
|
|
10
|
+
the creation of, or owns Covered Software.
|
|
11
|
+
|
|
12
|
+
1.2. "Contributor Version"
|
|
13
|
+
means the combination of the Contributions of others (if any) used
|
|
14
|
+
by a Contributor and that particular Contributor's Contribution.
|
|
15
|
+
|
|
16
|
+
1.3. "Contribution"
|
|
17
|
+
means Covered Software of a particular Contributor.
|
|
18
|
+
|
|
19
|
+
1.4. "Covered Software"
|
|
20
|
+
means Source Code Form to which the initial Contributor has attached
|
|
21
|
+
the notice in Exhibit A, the Executable Form of such Source Code
|
|
22
|
+
Form, and Modifications of such Source Code Form, in each case
|
|
23
|
+
including portions thereof.
|
|
24
|
+
|
|
25
|
+
1.5. "Incompatible With Secondary Licenses"
|
|
26
|
+
means
|
|
27
|
+
|
|
28
|
+
(a) that the initial Contributor has attached the notice described
|
|
29
|
+
in Exhibit B to the Covered Software; or
|
|
30
|
+
|
|
31
|
+
(b) that the Covered Software was made available under the terms of
|
|
32
|
+
version 1.1 or earlier of the License, but not also under the
|
|
33
|
+
terms of a Secondary License.
|
|
34
|
+
|
|
35
|
+
1.6. "Executable Form"
|
|
36
|
+
means any form of the work other than Source Code Form.
|
|
37
|
+
|
|
38
|
+
1.7. "Larger Work"
|
|
39
|
+
means a work that combines Covered Software with other material, in
|
|
40
|
+
a separate file or files, that is not Covered Software.
|
|
41
|
+
|
|
42
|
+
1.8. "License"
|
|
43
|
+
means this document.
|
|
44
|
+
|
|
45
|
+
1.9. "Licensable"
|
|
46
|
+
means having the right to grant, to the maximum extent possible,
|
|
47
|
+
whether at the time of the initial grant or subsequently, any and
|
|
48
|
+
all of the rights conveyed by this License.
|
|
49
|
+
|
|
50
|
+
1.10. "Modifications"
|
|
51
|
+
means any of the following:
|
|
52
|
+
|
|
53
|
+
(a) any file in Source Code Form that results from an addition to,
|
|
54
|
+
deletion from, or modification of the contents of Covered
|
|
55
|
+
Software; or
|
|
56
|
+
|
|
57
|
+
(b) any new file in Source Code Form that contains any Covered
|
|
58
|
+
Software.
|
|
59
|
+
|
|
60
|
+
1.11. "Patent Claims" of a Contributor
|
|
61
|
+
means any patent claim(s), including without limitation, method,
|
|
62
|
+
process, and apparatus claims, in any patent Licensable by such
|
|
63
|
+
Contributor that would be infringed, but for the grant of the
|
|
64
|
+
License, by the making, using, selling, offering for sale, having
|
|
65
|
+
made, import, or transfer of either its Contributions or its
|
|
66
|
+
Contributor Version.
|
|
67
|
+
|
|
68
|
+
1.12. "Secondary License"
|
|
69
|
+
means either the GNU General Public License, Version 2.0, the GNU
|
|
70
|
+
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
71
|
+
Public License, Version 3.0, or any later versions of those
|
|
72
|
+
licenses.
|
|
73
|
+
|
|
74
|
+
1.13. "Source Code Form"
|
|
75
|
+
means the form of the work preferred for making modifications.
|
|
76
|
+
|
|
77
|
+
1.14. "You" (or "Your")
|
|
78
|
+
means an individual or a legal entity exercising rights under this
|
|
79
|
+
License. For legal entities, "You" includes any entity that
|
|
80
|
+
controls, is controlled by, or is under common control with You. For
|
|
81
|
+
purposes of this definition, "control" means (a) the power, direct
|
|
82
|
+
or indirect, to cause the direction or management of such entity,
|
|
83
|
+
whether by contract or otherwise, or (b) ownership of more than
|
|
84
|
+
fifty percent (50%) of the outstanding shares or beneficial
|
|
85
|
+
ownership of such entity.
|
|
86
|
+
|
|
87
|
+
2. License Grants and Conditions
|
|
88
|
+
|
|
89
|
+
--------------------------------
|
|
90
|
+
|
|
91
|
+
2.1. Grants
|
|
92
|
+
|
|
93
|
+
Each Contributor hereby grants You a world-wide, royalty-free,
|
|
94
|
+
non-exclusive license:
|
|
95
|
+
|
|
96
|
+
(a) under intellectual property rights (other than patent or trademark)
|
|
97
|
+
Licensable by such Contributor to use, reproduce, make available,
|
|
98
|
+
modify, display, perform, distribute, and otherwise exploit its
|
|
99
|
+
Contributions, either on an unmodified basis, with Modifications, or
|
|
100
|
+
as part of a Larger Work; and
|
|
101
|
+
|
|
102
|
+
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
|
103
|
+
for sale, have made, import, and otherwise transfer either its
|
|
104
|
+
Contributions or its Contributor Version.
|
|
105
|
+
|
|
106
|
+
2.2. Effective Date
|
|
107
|
+
|
|
108
|
+
The licenses granted in Section 2.1 with respect to any Contribution
|
|
109
|
+
become effective for each Contribution on the date the Contributor first
|
|
110
|
+
distributes such Contribution.
|
|
111
|
+
|
|
112
|
+
2.3. Limitations on Grant Scope
|
|
113
|
+
|
|
114
|
+
The licenses granted in this Section 2 are the only rights granted under
|
|
115
|
+
this License. No additional rights or licenses will be implied from the
|
|
116
|
+
distribution or licensing of Covered Software under this License.
|
|
117
|
+
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
118
|
+
Contributor:
|
|
119
|
+
|
|
120
|
+
(a) for any code that a Contributor has removed from Covered Software;
|
|
121
|
+
or
|
|
122
|
+
|
|
123
|
+
(b) for infringements caused by: (i) Your and any other third party's
|
|
124
|
+
modifications of Covered Software, or (ii) the combination of its
|
|
125
|
+
Contributions with other software (except as part of its Contributor
|
|
126
|
+
Version); or
|
|
127
|
+
|
|
128
|
+
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
129
|
+
its Contributions.
|
|
130
|
+
|
|
131
|
+
This License does not grant any rights in the trademarks, service marks,
|
|
132
|
+
or logos of any Contributor (except as may be necessary to comply with
|
|
133
|
+
the notice requirements in Section 3.4).
|
|
134
|
+
|
|
135
|
+
2.4. Subsequent Licenses
|
|
136
|
+
|
|
137
|
+
No Contributor makes additional grants as a result of Your choice to
|
|
138
|
+
distribute the Covered Software under a subsequent version of this
|
|
139
|
+
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
140
|
+
permitted under the terms of Section 3.3).
|
|
141
|
+
|
|
142
|
+
2.5. Representation
|
|
143
|
+
|
|
144
|
+
Each Contributor represents that the Contributor believes its
|
|
145
|
+
Contributions are its original creation(s) or it has sufficient rights
|
|
146
|
+
to grant the rights to its Contributions conveyed by this License.
|
|
147
|
+
|
|
148
|
+
2.6. Fair Use
|
|
149
|
+
|
|
150
|
+
This License is not intended to limit any rights You have under
|
|
151
|
+
applicable copyright doctrines of fair use, fair dealing, or other
|
|
152
|
+
equivalents.
|
|
153
|
+
|
|
154
|
+
2.7. Conditions
|
|
155
|
+
|
|
156
|
+
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
157
|
+
in Section 2.1.
|
|
158
|
+
|
|
159
|
+
3. Responsibilities
|
|
160
|
+
|
|
161
|
+
-------------------
|
|
162
|
+
|
|
163
|
+
3.1. Distribution of Source Form
|
|
164
|
+
|
|
165
|
+
All distribution of Covered Software in Source Code Form, including any
|
|
166
|
+
Modifications that You create or to which You contribute, must be under
|
|
167
|
+
the terms of this License. You must inform recipients that the Source
|
|
168
|
+
Code Form of the Covered Software is governed by the terms of this
|
|
169
|
+
License, and how they can obtain a copy of this License. You may not
|
|
170
|
+
attempt to alter or restrict the recipients' rights in the Source Code
|
|
171
|
+
Form.
|
|
172
|
+
|
|
173
|
+
3.2. Distribution of Executable Form
|
|
174
|
+
|
|
175
|
+
If You distribute Covered Software in Executable Form then:
|
|
176
|
+
|
|
177
|
+
(a) such Covered Software must also be made available in Source Code
|
|
178
|
+
Form, as described in Section 3.1, and You must inform recipients of
|
|
179
|
+
the Executable Form how they can obtain a copy of such Source Code
|
|
180
|
+
Form by reasonable means in a timely manner, at a charge no more
|
|
181
|
+
than the cost of distribution to the recipient; and
|
|
182
|
+
|
|
183
|
+
(b) You may distribute such Executable Form under the terms of this
|
|
184
|
+
License, or sublicense it under different terms, provided that the
|
|
185
|
+
license for the Executable Form does not attempt to limit or alter
|
|
186
|
+
the recipients' rights in the Source Code Form under this License.
|
|
187
|
+
|
|
188
|
+
3.3. Distribution of a Larger Work
|
|
189
|
+
|
|
190
|
+
You may create and distribute a Larger Work under terms of Your choice,
|
|
191
|
+
provided that You also comply with the requirements of this License for
|
|
192
|
+
the Covered Software. If the Larger Work is a combination of Covered
|
|
193
|
+
Software with a work governed by one or more Secondary Licenses, and the
|
|
194
|
+
Covered Software is not Incompatible With Secondary Licenses, this
|
|
195
|
+
License permits You to additionally distribute such Covered Software
|
|
196
|
+
under the terms of such Secondary License(s), so that the recipient of
|
|
197
|
+
the Larger Work may, at their option, further distribute the Covered
|
|
198
|
+
Software under the terms of either this License or such Secondary
|
|
199
|
+
License(s).
|
|
200
|
+
|
|
201
|
+
3.4. Notices
|
|
202
|
+
|
|
203
|
+
You may not remove or alter the substance of any license notices
|
|
204
|
+
(including copyright notices, patent notices, disclaimers of warranty,
|
|
205
|
+
or limitations of liability) contained within the Source Code Form of
|
|
206
|
+
the Covered Software, except that You may alter any license notices to
|
|
207
|
+
the extent required to remedy known factual inaccuracies.
|
|
208
|
+
|
|
209
|
+
3.5. Application of Additional Terms
|
|
210
|
+
|
|
211
|
+
You may choose to offer, and to charge a fee for, warranty, support,
|
|
212
|
+
indemnity or liability obligations to one or more recipients of Covered
|
|
213
|
+
Software. However, You may do so only on Your own behalf, and not on
|
|
214
|
+
behalf of any Contributor. You must make it absolutely clear that any
|
|
215
|
+
such warranty, support, indemnity, or liability obligation is offered by
|
|
216
|
+
You alone, and You hereby agree to indemnify every Contributor for any
|
|
217
|
+
liability incurred by such Contributor as a result of warranty, support,
|
|
218
|
+
indemnity or liability terms You offer. You may include additional
|
|
219
|
+
disclaimers of warranty and limitations of liability specific to any
|
|
220
|
+
jurisdiction.
|
|
221
|
+
|
|
222
|
+
4. Inability to Comply Due to Statute or Regulation
|
|
223
|
+
|
|
224
|
+
---------------------------------------------------
|
|
225
|
+
|
|
226
|
+
If it is impossible for You to comply with any of the terms of this
|
|
227
|
+
License with respect to some or all of the Covered Software due to
|
|
228
|
+
statute, judicial order, or regulation then You must: (a) comply with
|
|
229
|
+
the terms of this License to the maximum extent possible; and (b)
|
|
230
|
+
describe the limitations and the code they affect. Such description must
|
|
231
|
+
be placed in a text file included with all distributions of the Covered
|
|
232
|
+
Software under this License. Except to the extent prohibited by statute
|
|
233
|
+
or regulation, such description must be sufficiently detailed for a
|
|
234
|
+
recipient of ordinary skill to be able to understand it.
|
|
235
|
+
|
|
236
|
+
5. Termination
|
|
237
|
+
|
|
238
|
+
--------------
|
|
239
|
+
|
|
240
|
+
5.1. The rights granted under this License will terminate automatically
|
|
241
|
+
if You fail to comply with any of its terms. However, if You become
|
|
242
|
+
compliant, then the rights granted under this License from a particular
|
|
243
|
+
Contributor are reinstated (a) provisionally, unless and until such
|
|
244
|
+
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
245
|
+
ongoing basis, if such Contributor fails to notify You of the
|
|
246
|
+
non-compliance by some reasonable means prior to 60 days after You have
|
|
247
|
+
come back into compliance. Moreover, Your grants from a particular
|
|
248
|
+
Contributor are reinstated on an ongoing basis if such Contributor
|
|
249
|
+
notifies You of the non-compliance by some reasonable means, this is the
|
|
250
|
+
first time You have received notice of non-compliance with this License
|
|
251
|
+
from such Contributor, and You become compliant prior to 30 days after
|
|
252
|
+
Your receipt of the notice.
|
|
253
|
+
|
|
254
|
+
5.2. If You initiate litigation against any entity by asserting a patent
|
|
255
|
+
infringement claim (excluding declaratory judgment actions,
|
|
256
|
+
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
257
|
+
directly or indirectly infringes any patent, then the rights granted to
|
|
258
|
+
You by any and all Contributors for the Covered Software under Section
|
|
259
|
+
2.1 of this License shall terminate.
|
|
260
|
+
|
|
261
|
+
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
262
|
+
end user license agreements (excluding distributors and resellers) which
|
|
263
|
+
have been validly granted by You or Your distributors under this License
|
|
264
|
+
prior to termination shall survive termination.
|
|
265
|
+
|
|
266
|
+
************************************************************************
|
|
267
|
+
|
|
268
|
+
* *
|
|
269
|
+
* 6. Disclaimer of Warranty *
|
|
270
|
+
* ------------------------- *
|
|
271
|
+
* *
|
|
272
|
+
* Covered Software is provided under this License on an "as is" *
|
|
273
|
+
* basis, without warranty of any kind, either expressed, implied, or *
|
|
274
|
+
* statutory, including, without limitation, warranties that the *
|
|
275
|
+
* Covered Software is free of defects, merchantable, fit for a *
|
|
276
|
+
* particular purpose or non-infringing. The entire risk as to the *
|
|
277
|
+
* quality and performance of the Covered Software is with You. *
|
|
278
|
+
* Should any Covered Software prove defective in any respect, You *
|
|
279
|
+
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
280
|
+
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
281
|
+
* essential part of this License. No use of any Covered Software is *
|
|
282
|
+
* authorized under this License except under this disclaimer. *
|
|
283
|
+
* *
|
|
284
|
+
|
|
285
|
+
************************************************************************
|
|
286
|
+
|
|
287
|
+
************************************************************************
|
|
288
|
+
|
|
289
|
+
* *
|
|
290
|
+
* 7. Limitation of Liability *
|
|
291
|
+
* -------------------------- *
|
|
292
|
+
* *
|
|
293
|
+
* Under no circumstances and under no legal theory, whether tort *
|
|
294
|
+
* (including negligence), contract, or otherwise, shall any *
|
|
295
|
+
* Contributor, or anyone who distributes Covered Software as *
|
|
296
|
+
* permitted above, be liable to You for any direct, indirect, *
|
|
297
|
+
* special, incidental, or consequential damages of any character *
|
|
298
|
+
* including, without limitation, damages for lost profits, loss of *
|
|
299
|
+
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
300
|
+
* and all other commercial damages or losses, even if such party *
|
|
301
|
+
* shall have been informed of the possibility of such damages. This *
|
|
302
|
+
* limitation of liability shall not apply to liability for death or *
|
|
303
|
+
* personal injury resulting from such party's negligence to the *
|
|
304
|
+
* extent applicable law prohibits such limitation. Some *
|
|
305
|
+
* jurisdictions do not allow the exclusion or limitation of *
|
|
306
|
+
* incidental or consequential damages, so this exclusion and *
|
|
307
|
+
* limitation may not apply to You. *
|
|
308
|
+
* *
|
|
309
|
+
|
|
310
|
+
************************************************************************
|
|
311
|
+
|
|
312
|
+
8. Litigation
|
|
313
|
+
|
|
314
|
+
-------------
|
|
315
|
+
|
|
316
|
+
Any litigation relating to this License may be brought only in the
|
|
317
|
+
courts of a jurisdiction where the defendant maintains its principal
|
|
318
|
+
place of business and such litigation shall be governed by laws of that
|
|
319
|
+
jurisdiction, without reference to its conflict-of-law provisions.
|
|
320
|
+
Nothing in this Section shall prevent a party's ability to bring
|
|
321
|
+
cross-claims or counter-claims.
|
|
322
|
+
|
|
323
|
+
9. Miscellaneous
|
|
324
|
+
|
|
325
|
+
----------------
|
|
326
|
+
|
|
327
|
+
This License represents the complete agreement concerning the subject
|
|
328
|
+
matter hereof. If any provision of this License is held to be
|
|
329
|
+
unenforceable, such provision shall be reformed only to the extent
|
|
330
|
+
necessary to make it enforceable. Any law or regulation which provides
|
|
331
|
+
that the language of a contract shall be construed against the drafter
|
|
332
|
+
shall not be used to construe this License against a Contributor.
|
|
333
|
+
|
|
334
|
+
10. Versions of the License
|
|
335
|
+
|
|
336
|
+
---------------------------
|
|
337
|
+
|
|
338
|
+
10.1. New Versions
|
|
339
|
+
|
|
340
|
+
Mozilla Foundation is the license steward. Except as provided in Section
|
|
341
|
+
10.3, no one other than the license steward has the right to modify or
|
|
342
|
+
publish new versions of this License. Each version will be given a
|
|
343
|
+
distinguishing version number.
|
|
344
|
+
|
|
345
|
+
10.2. Effect of New Versions
|
|
346
|
+
|
|
347
|
+
You may distribute the Covered Software under the terms of the version
|
|
348
|
+
of the License under which You originally received the Covered Software,
|
|
349
|
+
or under the terms of any subsequent version published by the license
|
|
350
|
+
steward.
|
|
351
|
+
|
|
352
|
+
10.3. Modified Versions
|
|
353
|
+
|
|
354
|
+
If you create software not governed by this License, and you want to
|
|
355
|
+
create a new license for such software, you may create and use a
|
|
356
|
+
modified version of this License if you rename the license and remove
|
|
357
|
+
any references to the name of the license steward (except to note that
|
|
358
|
+
such modified license differs from this License).
|
|
359
|
+
|
|
360
|
+
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
361
|
+
Licenses
|
|
362
|
+
|
|
363
|
+
If You choose to distribute Source Code Form that is Incompatible With
|
|
364
|
+
Secondary Licenses under the terms of this version of the License, the
|
|
365
|
+
notice described in Exhibit B of this License must be attached.
|
|
366
|
+
|
|
367
|
+
Exhibit A - Source Code Form License Notice
|
|
368
|
+
-------------------------------------------
|
|
369
|
+
|
|
370
|
+
This Source Code Form is subject to the terms of the Mozilla Public
|
|
371
|
+
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
372
|
+
file, You can obtain one at <http://mozilla.org/MPL/2.0/>.
|
|
373
|
+
|
|
374
|
+
If it is not possible or desirable to put the notice in a particular
|
|
375
|
+
file, then You may include the notice in a location (such as a LICENSE
|
|
376
|
+
file in a relevant directory) where a recipient would be likely to look
|
|
377
|
+
for such a notice.
|
|
378
|
+
|
|
379
|
+
You may add additional accurate notices of copyright ownership.
|
|
380
|
+
|
|
381
|
+
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
382
|
+
---------------------------------------------------------
|
|
383
|
+
|
|
384
|
+
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
385
|
+
defined by the Mozilla Public License, v. 2.0.
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: nac-test
|
|
3
|
+
Version: 0.3.0a0
|
|
4
|
+
Summary: A CLI tool to render and execute Robot Framework tests using Jinja templating.
|
|
5
|
+
License: LICENSE
|
|
6
|
+
Author: Daniel Schmidt
|
|
7
|
+
Author-email: danischm@cisco.com
|
|
8
|
+
Maintainer: Daniel Schmidt
|
|
9
|
+
Maintainer-email: danischm@cisco.com
|
|
10
|
+
Requires-Python: >=3.10,<4.0
|
|
11
|
+
Classifier: License :: Other/Proprietary License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Dist: Jinja2 (>=3.1,<4.0)
|
|
18
|
+
Requires-Dist: RESTinstance (>=1.5,<2.0)
|
|
19
|
+
Requires-Dist: errorhandler (>=2.0,<3.0)
|
|
20
|
+
Requires-Dist: jmespath (>=1.0,<2.0)
|
|
21
|
+
Requires-Dist: nac-yaml (>=0.1.2)
|
|
22
|
+
Requires-Dist: robotframework (>=7.2,<8.0)
|
|
23
|
+
Requires-Dist: robotframework-jsonlibrary (>=0.5,<1.0)
|
|
24
|
+
Requires-Dist: robotframework-pabot (>=4.1,<5.0)
|
|
25
|
+
Requires-Dist: robotframework-requests (>=0.9,<1.0)
|
|
26
|
+
Requires-Dist: ruamel-yaml (>=0.16,<1.0)
|
|
27
|
+
Requires-Dist: typer (>=0.15,<1.0)
|
|
28
|
+
Project-URL: Documentation, https://github.com/netascode/nac-test
|
|
29
|
+
Project-URL: Homepage, https://github.com/netascode/nac-test
|
|
30
|
+
Project-URL: Repository, https://github.com/netascode/nac-test
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
[](https://github.com/netascode/nac-test/actions/workflows/test.yml)
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
# nac-test
|
|
37
|
+
|
|
38
|
+
A CLI tool to render and execute [Robot Framework](https://robotframework.org/) tests using [Jinja](https://jinja.palletsprojects.com/) templating. Combining Robot's language agnostic syntax with the flexibility of Jinja templating allows dynamically rendering a set of test suites from the desired infrastructure state expressed in YAML syntax.
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
$ nac-test -h
|
|
42
|
+
|
|
43
|
+
Usage: nac-test [OPTIONS]
|
|
44
|
+
|
|
45
|
+
A CLI tool to render and execute Robot Framework tests using Jinja templating.
|
|
46
|
+
|
|
47
|
+
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
|
48
|
+
│ * --data -d PATH Path to data YAML files. [env var: NAC_TEST_DATA] [default: None] [required] │
|
|
49
|
+
│ * --templates -t DIRECTORY Path to test templates. [env var: NAC_TEST_TEMPLATES] [default: None] [required] │
|
|
50
|
+
│ * --output -o DIRECTORY Path to output directory. [env var: NAC_TEST_OUTPUT] [default: None] [required] │
|
|
51
|
+
│ --filters -f DIRECTORY Path to Jinja filters. [env var: NAC_TEST_FILTERS] [default: None] │
|
|
52
|
+
│ --tests DIRECTORY Path to Jinja tests. [env var: NAC_TEST_TESTS] [default: None] │
|
|
53
|
+
│ --include -i TEXT Selects the test cases by tag (include). [env var: NAC_TEST_INCLUDE] │
|
|
54
|
+
│ --exclude -e TEXT Selects the test cases by tag (exclude). [env var: NAC_TEST_EXCLUDE] │
|
|
55
|
+
│ --render-only Only render tests without executing them. [env var: NAC_TEST_RENDER_ONLY] │
|
|
56
|
+
│ --dry-run Dry run flag. See robot dry run mode. [env var: NAC_TEST_DRY_RUN] │
|
|
57
|
+
│ --verbosity -v [DEBUG|INFO|WARNING|ERROR|CRITICAL] Verbosity level. [env var: NAC_VALIDATE_VERBOSITY] [default: WARNING] │
|
|
58
|
+
│ --version Display version number. │
|
|
59
|
+
│ --help Show this message and exit. │
|
|
60
|
+
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
All data from the YAML files (`--data` option) will first be combined into a single data structure which is then provided as input to the templating process. Each template in the `--templates` path will then be rendered and written to the `--output` path. If the `--templates` path has subfolders, the folder structure will be retained when rendering the templates.
|
|
64
|
+
|
|
65
|
+
After all templates have been rendered [Pabot](https://pabot.org/) will execute all test suites in parallel and create a test report in the `--output` path. The `--skiponfailure non-critical` argument will be used by default, meaning all failed tests with a `non-critical` tag will show up as "skipped" instead of "failed" in the final test report.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
|
|
69
|
+
Python 3.10+ is required to install `nac-test`. Don't have Python 3.10 or later? See [Python 3 Installation & Setup Guide](https://realpython.com/installing-python/).
|
|
70
|
+
|
|
71
|
+
`nac-test` can be installed in a virtual environment using `pip`:
|
|
72
|
+
|
|
73
|
+
```shell
|
|
74
|
+
pip install nac-test
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The following Robot libraries are installed with `nac-test`:
|
|
78
|
+
|
|
79
|
+
- [RESTinstance](https://github.com/asyrjasalo/RESTinstance)
|
|
80
|
+
- [Requests](https://github.com/MarketSquare/robotframework-requests)
|
|
81
|
+
- [JSONLibrary](https://github.com/robotframework-thailand/robotframework-jsonlibrary)
|
|
82
|
+
|
|
83
|
+
Any other libraries can of course be added via `pip`.
|
|
84
|
+
|
|
85
|
+
## Ansible Vault Support
|
|
86
|
+
|
|
87
|
+
Values in YAML files can be encrypted using [Ansible Vault](https://docs.ansible.com/ansible/latest/user_guide/vault.html). This requires Ansible (`ansible-vault` command) to be installed and the following two environment variables to be defined:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
export ANSIBLE_VAULT_ID=dev
|
|
91
|
+
export ANSIBLE_VAULT_PASSWORD=Password123
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`ANSIBLE_VAULT_ID` is optional, and if not defined will be omitted.
|
|
95
|
+
|
|
96
|
+
## Additional Tags
|
|
97
|
+
|
|
98
|
+
### Reading Environment Variables
|
|
99
|
+
|
|
100
|
+
The `!env` YAML tag can be used to read values from environment variables.
|
|
101
|
+
|
|
102
|
+
```yaml
|
|
103
|
+
root:
|
|
104
|
+
name: !env VAR_NAME
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Example
|
|
108
|
+
|
|
109
|
+
`data.yaml` located in `./data` folder:
|
|
110
|
+
|
|
111
|
+
```yaml
|
|
112
|
+
---
|
|
113
|
+
root:
|
|
114
|
+
children:
|
|
115
|
+
- name: ABC
|
|
116
|
+
param: value
|
|
117
|
+
- name: DEF
|
|
118
|
+
param: value
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`test1.robot` located in `./templates` folder:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
*** Settings ***
|
|
125
|
+
Documentation Test1
|
|
126
|
+
|
|
127
|
+
*** Test Cases ***
|
|
128
|
+
{% for child in root.children | default([]) %}
|
|
129
|
+
|
|
130
|
+
Test {{ child.name }}
|
|
131
|
+
Should Be Equal {{ child.param }} value
|
|
132
|
+
{% endfor %}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
After running `nac-test` with the following parameters:
|
|
136
|
+
|
|
137
|
+
```shell
|
|
138
|
+
nac-test --data ./data --templates ./templates --output ./tests
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The following rendered Robot test suite can be found in the `./tests` folder:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
*** Settings ***
|
|
145
|
+
Documentation Test1
|
|
146
|
+
|
|
147
|
+
*** Test Cases ***
|
|
148
|
+
|
|
149
|
+
Test ABC
|
|
150
|
+
Should Be Equal value value
|
|
151
|
+
|
|
152
|
+
Test DEF
|
|
153
|
+
Should Be Equal value value
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
As well as the test results and reports:
|
|
157
|
+
|
|
158
|
+
```shell
|
|
159
|
+
$ tree -L 1 tests
|
|
160
|
+
tests
|
|
161
|
+
├── log.html
|
|
162
|
+
├── output.xml
|
|
163
|
+
├── pabot_results
|
|
164
|
+
├── report.html
|
|
165
|
+
├── test1.robot
|
|
166
|
+
└── xunit.xml
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Custom Jinja Filters
|
|
170
|
+
|
|
171
|
+
Custom Jinja filters can be used by providing a set of Python classes where each filter is implemented as a separate `Filter` class in a `.py` file located in the `--filters` path. The class must have a single attribute named `name`, the filter name, and a `classmethod()` named `filter` which has one or more arguments. A sample filter can be found below.
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
class Filter:
|
|
175
|
+
name = "filter1"
|
|
176
|
+
|
|
177
|
+
@classmethod
|
|
178
|
+
def filter(cls, data):
|
|
179
|
+
return str(data) + "_filtered"
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Custom Jinja Tests
|
|
183
|
+
|
|
184
|
+
Custom Jinja tests can be used by providing a set of Python classes where each test is implemented as a separate `Test` class in a `.py` file located in the `--tests` path. The class must have a single attribute named `name`, the test name, and a `classmethod()` named `test` which has one or more arguments. A sample test can be found below.
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
class Test:
|
|
188
|
+
name = "test1"
|
|
189
|
+
|
|
190
|
+
@classmethod
|
|
191
|
+
def test(cls, data1, data2):
|
|
192
|
+
return data1 == data2
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Rendering Directives
|
|
196
|
+
|
|
197
|
+
Special rendering directives exist to render a single test suite per (YAML) list item. The directive can be added to the Robot template as a Jinja comment following this syntax:
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
{# iterate_list <YAML_PATH_TO_LIST> <LIST_ITEM_ID> <JINJA_VARIABLE_NAME> #}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
After running `nac-test` with the data from the previous [example](#example) and the following template:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
{# iterate_list root.children name child_name #}
|
|
207
|
+
*** Settings ***
|
|
208
|
+
Documentation Test1
|
|
209
|
+
|
|
210
|
+
*** Test Cases ***
|
|
211
|
+
{% for child in root.children | default([]) %}
|
|
212
|
+
{% if child.name == child_name %}
|
|
213
|
+
|
|
214
|
+
Test {{ child.name }}
|
|
215
|
+
Should Be Equal {{ child.param }} value
|
|
216
|
+
{% endif %}
|
|
217
|
+
{% endfor %}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The following test suites will be rendered:
|
|
221
|
+
|
|
222
|
+
```shell
|
|
223
|
+
$ tree -L 2 tests
|
|
224
|
+
tests
|
|
225
|
+
├── ABC
|
|
226
|
+
│ └── test1.robot
|
|
227
|
+
└── DEF
|
|
228
|
+
└── test1.robot
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
A similar directive exists to put the test suites in a common folder though with a unique filename.
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
{# iterate_list_folder <YAML_PATH_TO_LIST> <LIST_ITEM_ID> <JINJA_VARIABLE_NAME> #}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
The following test suites will be rendered:
|
|
238
|
+
|
|
239
|
+
```shell
|
|
240
|
+
$ tree -L 2 tests
|
|
241
|
+
tests
|
|
242
|
+
└── test1
|
|
243
|
+
├── ABC.robot
|
|
244
|
+
└── DEF.robot
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Select Test Cases By Tag
|
|
248
|
+
|
|
249
|
+
It is possible to include and exclude test cases by tag names with the `--include` and `--exclude` CLI options. These options are directly passed to the Pabot/Robot executor and are documented [here](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#by-tag-names).
|
|
250
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
nac_test/__init__.py,sha256=cSkdnIbb8C7D00CmEW21Mb1bQaM_0KoMBXw86eAlN74,173
|
|
2
|
+
nac_test/__main__.py,sha256=eMQdtzk6p-z59sXDzlcQq7VEWGXwh4AsDgWR_oarIrM,166
|
|
3
|
+
nac_test/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
nac_test/cli/main.py,sha256=YioTFolBesJgfoOUbKcGoXEcGVxY-JdJIRP30icBWbk,4431
|
|
5
|
+
nac_test/pabot.py,sha256=p-V5ETUG6kOt_xWOXMyfG9hyXH6taqnGKyWvSsexZm0,808
|
|
6
|
+
nac_test/robot_writer.py,sha256=gpu4w8QzUxkYSugRfwW6yhEX3YJ6RNwlQRpZBUYLpm8,8369
|
|
7
|
+
nac_test-0.3.0a0.dist-info/LICENSE,sha256=zt2sx-c0iEk6-OO0iqRQ4l6fIGazRKW_qLMqfDpLm6M,16295
|
|
8
|
+
nac_test-0.3.0a0.dist-info/METADATA,sha256=ko74znxx0HIimxOpky_UxZciQiwUY-nWsgcGmU_Cmp4,10972
|
|
9
|
+
nac_test-0.3.0a0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
10
|
+
nac_test-0.3.0a0.dist-info/entry_points.txt,sha256=WFwenG8Bd4xTHOwQOyNCBtHuoxTMq0ZSbtvNFoXNRhM,81
|
|
11
|
+
nac_test-0.3.0a0.dist-info/RECORD,,
|