ogc-cite-runner 0.3.0__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.
- ogc_cite_runner/__init__.py +0 -0
- ogc_cite_runner/__main__.py +3 -0
- ogc_cite_runner/config.py +94 -0
- ogc_cite_runner/exceptions.py +1 -0
- ogc_cite_runner/main.py +363 -0
- ogc_cite_runner/models.py +84 -0
- ogc_cite_runner/parsers/__init__.py +0 -0
- ogc_cite_runner/parsers/earl.py +208 -0
- ogc_cite_runner/serializers/__init__.py +0 -0
- ogc_cite_runner/serializers/console.py +147 -0
- ogc_cite_runner/serializers/simple.py +37 -0
- ogc_cite_runner/teamengine_runner.py +208 -0
- ogc_cite_runner/templates/test-suite-result.md +178 -0
- ogc_cite_runner-0.3.0.dist-info/METADATA +40 -0
- ogc_cite_runner-0.3.0.dist-info/RECORD +18 -0
- ogc_cite_runner-0.3.0.dist-info/WHEEL +4 -0
- ogc_cite_runner-0.3.0.dist-info/entry_points.txt +2 -0
- ogc_cite_runner-0.3.0.dist-info/licenses/LICENSE +21 -0
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import jinja2
|
|
4
|
+
import pydantic
|
|
5
|
+
from pydantic_settings import (
|
|
6
|
+
BaseSettings,
|
|
7
|
+
SettingsConfigDict,
|
|
8
|
+
)
|
|
9
|
+
from rich.console import Console
|
|
10
|
+
from rich.logging import RichHandler
|
|
11
|
+
|
|
12
|
+
from . import models
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class OgcCiteRunnerSettings(BaseSettings):
|
|
16
|
+
model_config = SettingsConfigDict(
|
|
17
|
+
env_prefix="OGC_CITE_RUNNER__", env_nested_delimiter="__"
|
|
18
|
+
)
|
|
19
|
+
default_json_serializer: str = "ogc_cite_runner.serializers.simple.to_json"
|
|
20
|
+
default_markdown_serializer: str = "ogc_cite_runner.serializers.simple.to_markdown"
|
|
21
|
+
default_console_serializer: str = "ogc_cite_runner.serializers.console.to_console"
|
|
22
|
+
default_parser: str = "ogc_cite_runner.parsers.earl.parse_test_suite_result"
|
|
23
|
+
extra_templates_path: str | None = None
|
|
24
|
+
|
|
25
|
+
# ogcapi_features_1_0_parser: str = (
|
|
26
|
+
# "ogc_cite_runner.teamengine_runner.parse_test_suite_result")
|
|
27
|
+
# ogcapi_features_1_0_markdown_serializer: str = (
|
|
28
|
+
# "ogc_cite_runner.teamengine_runner.serialize_test_suite_result")
|
|
29
|
+
simple_serializer_template: str = "test-suite-result.md"
|
|
30
|
+
docs_url: str = "https://osgeo.github.io/ogc-cite-runner/"
|
|
31
|
+
disclaimer: str = (
|
|
32
|
+
"ogc-cite-runner is not affiliated with the OGC. Having a CITE test suite be declared as passed by "
|
|
33
|
+
"ogc-cite-runner does not mean the implementation under test is OGC certified nor does it mean that it "
|
|
34
|
+
"is guaranteed to pass the official CITE certification program."
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class OgcCiteRunnerContext(pydantic.BaseModel):
|
|
39
|
+
model_config = pydantic.ConfigDict(arbitrary_types_allowed=True)
|
|
40
|
+
|
|
41
|
+
debug: bool = False
|
|
42
|
+
jinja_environment: jinja2.Environment = jinja2.Environment()
|
|
43
|
+
network_timeout_seconds: int = 20
|
|
44
|
+
result_console: Console
|
|
45
|
+
status_console: Console
|
|
46
|
+
settings: OgcCiteRunnerSettings
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def get_settings() -> OgcCiteRunnerSettings:
|
|
50
|
+
return OgcCiteRunnerSettings()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _get_jinja_environment(settings: OgcCiteRunnerSettings) -> jinja2.Environment:
|
|
54
|
+
loaders = [
|
|
55
|
+
jinja2.PackageLoader("ogc_cite_runner", "templates"),
|
|
56
|
+
]
|
|
57
|
+
if settings.extra_templates_path is not None:
|
|
58
|
+
loaders.append(jinja2.FileSystemLoader(settings.extra_templates_path))
|
|
59
|
+
env = jinja2.Environment(
|
|
60
|
+
loader=jinja2.ChoiceLoader(loaders),
|
|
61
|
+
extensions=[
|
|
62
|
+
"jinja2_humanize_extension.HumanizeExtension",
|
|
63
|
+
],
|
|
64
|
+
)
|
|
65
|
+
env.globals.update(
|
|
66
|
+
{
|
|
67
|
+
"TestStatus": models.TestStatus,
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
return env
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def configure_logging(rich_console: Console, debug: bool) -> None:
|
|
74
|
+
logging.basicConfig(
|
|
75
|
+
level=logging.DEBUG if debug else logging.WARNING,
|
|
76
|
+
handlers=[RichHandler(console=rich_console, rich_tracebacks=True)],
|
|
77
|
+
)
|
|
78
|
+
logging.getLogger("httpcore").setLevel(logging.INFO if debug else logging.WARNING)
|
|
79
|
+
logging.getLogger("httpx").setLevel(logging.INFO if debug else logging.WARNING)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def get_context(
|
|
83
|
+
debug: bool,
|
|
84
|
+
network_timeout_seconds: int,
|
|
85
|
+
) -> OgcCiteRunnerContext:
|
|
86
|
+
settings = get_settings()
|
|
87
|
+
return OgcCiteRunnerContext(
|
|
88
|
+
debug=debug,
|
|
89
|
+
network_timeout_seconds=network_timeout_seconds,
|
|
90
|
+
jinja_environment=_get_jinja_environment(settings),
|
|
91
|
+
settings=settings,
|
|
92
|
+
result_console=Console(),
|
|
93
|
+
status_console=Console(stderr=True),
|
|
94
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class OgcCiteRunnerException(BaseException): ...
|
ogc_cite_runner/main.py
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
"""CLI Utilities for running CITE tests and parsing their results."""
|
|
2
|
+
|
|
3
|
+
from builtins import print as stdlib_print
|
|
4
|
+
import logging
|
|
5
|
+
import typing
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
import click
|
|
9
|
+
import httpx
|
|
10
|
+
import pydantic
|
|
11
|
+
import typer
|
|
12
|
+
|
|
13
|
+
from . import (
|
|
14
|
+
config,
|
|
15
|
+
exceptions,
|
|
16
|
+
models,
|
|
17
|
+
teamengine_runner,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
app = typer.Typer()
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
_DEFAULT_OUTPUT_FORMAT = models.OutputFormat.CONSOLE
|
|
25
|
+
_DEFAULT_EXIT_WITH_ERROR = True
|
|
26
|
+
_DEFAULT_INCLUDE_SUMMARY = True
|
|
27
|
+
_DEFAULT_INCLUDE_FAILED = False
|
|
28
|
+
_DEFAULT_INCLUDE_SKIPPED = False
|
|
29
|
+
_DEFAULT_INCLUDE_PASSED = False
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _parse_pydantic_secret_str(value: str) -> pydantic.SecretStr:
|
|
33
|
+
return pydantic.SecretStr(value)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
_test_suite_identifier_argument = typing.Annotated[
|
|
37
|
+
str, typer.Argument(help="Identifier of the test suite. Ex: ogcapi-features-1.0")
|
|
38
|
+
]
|
|
39
|
+
_teamengine_base_url_argument = typing.Annotated[
|
|
40
|
+
str,
|
|
41
|
+
typer.Argument(
|
|
42
|
+
help="Base URL of teamengine service. Ex: http://localhost:8080/teamengine"
|
|
43
|
+
),
|
|
44
|
+
]
|
|
45
|
+
_teamengine_username_option = typing.Annotated[
|
|
46
|
+
pydantic.SecretStr,
|
|
47
|
+
typer.Option(
|
|
48
|
+
help="Username for authenticating with teamengine",
|
|
49
|
+
parser=_parse_pydantic_secret_str,
|
|
50
|
+
),
|
|
51
|
+
]
|
|
52
|
+
_teamengine_password_option = typing.Annotated[
|
|
53
|
+
pydantic.SecretStr,
|
|
54
|
+
typer.Option(
|
|
55
|
+
help="Password for authenticating with teamengine",
|
|
56
|
+
parser=_parse_pydantic_secret_str,
|
|
57
|
+
),
|
|
58
|
+
]
|
|
59
|
+
_output_format_option = typing.Annotated[
|
|
60
|
+
models.OutputFormat,
|
|
61
|
+
typer.Option(help="Output format for the suite execution result report"),
|
|
62
|
+
]
|
|
63
|
+
_exit_with_error_option = typing.Annotated[
|
|
64
|
+
bool,
|
|
65
|
+
typer.Option(
|
|
66
|
+
"--exit-with-error/--exit-without-error",
|
|
67
|
+
"-e/-E",
|
|
68
|
+
help="Exit with an error code of 1 if the test suite has failed.",
|
|
69
|
+
),
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
_include_summary_option = typing.Annotated[
|
|
73
|
+
bool,
|
|
74
|
+
typer.Option(
|
|
75
|
+
"--with-summary/--without-summary",
|
|
76
|
+
"-f/-F",
|
|
77
|
+
help=(
|
|
78
|
+
"Include report section with test execution summary. Note that this does "
|
|
79
|
+
"not apply to the RAW and JSON output formats, as these always "
|
|
80
|
+
"include the full test execution report."
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
_include_failed_option = typing.Annotated[
|
|
86
|
+
bool,
|
|
87
|
+
typer.Option(
|
|
88
|
+
"--with-failed/--without-failed",
|
|
89
|
+
"-f/-F",
|
|
90
|
+
help=(
|
|
91
|
+
"Include report section detailing failed tests. Note that this does not "
|
|
92
|
+
"apply to the RAW and JSON output formats, as these always include the "
|
|
93
|
+
"full test execution report."
|
|
94
|
+
),
|
|
95
|
+
),
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
_include_skipped_option = typing.Annotated[
|
|
99
|
+
bool,
|
|
100
|
+
typer.Option(
|
|
101
|
+
"--with-skipped/--without-skipped",
|
|
102
|
+
"-f/-F",
|
|
103
|
+
help=(
|
|
104
|
+
"Include report section detailing skipped tests. Note that this does not "
|
|
105
|
+
"apply to the RAW and JSON output formats, as these always include the "
|
|
106
|
+
"full test execution report."
|
|
107
|
+
),
|
|
108
|
+
),
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
_include_passed_option = typing.Annotated[
|
|
112
|
+
bool,
|
|
113
|
+
typer.Option(
|
|
114
|
+
"--with-passed/--without-passed",
|
|
115
|
+
"-f/-F",
|
|
116
|
+
help=(
|
|
117
|
+
"Include report section detailing passed tests. Note that this does not "
|
|
118
|
+
"apply to the RAW and JSON output formats, as these always include the "
|
|
119
|
+
"full test execution report."
|
|
120
|
+
),
|
|
121
|
+
),
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@app.callback()
|
|
126
|
+
def base_callback(
|
|
127
|
+
ctx: typer.Context, debug: bool = False, network_timeout: int = 120
|
|
128
|
+
) -> None:
|
|
129
|
+
context = config.get_context(
|
|
130
|
+
debug=debug,
|
|
131
|
+
network_timeout_seconds=network_timeout,
|
|
132
|
+
)
|
|
133
|
+
config.configure_logging(rich_console=context.status_console, debug=debug)
|
|
134
|
+
ctx.obj = context
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@app.command("parse-result")
|
|
138
|
+
def parse_test_result(
|
|
139
|
+
ctx: typer.Context,
|
|
140
|
+
test_suite_result: typing.Annotated[
|
|
141
|
+
Path,
|
|
142
|
+
typer.Argument(
|
|
143
|
+
# exists=True,
|
|
144
|
+
# file_okay=True,
|
|
145
|
+
# dir_okay=False,
|
|
146
|
+
allow_dash=True,
|
|
147
|
+
help="Suite execution result",
|
|
148
|
+
),
|
|
149
|
+
],
|
|
150
|
+
output_format: _output_format_option = _DEFAULT_OUTPUT_FORMAT,
|
|
151
|
+
include_summary: _include_summary_option = _DEFAULT_INCLUDE_SUMMARY,
|
|
152
|
+
include_failed: _include_failed_option = _DEFAULT_INCLUDE_FAILED,
|
|
153
|
+
include_skipped: _include_skipped_option = _DEFAULT_INCLUDE_SKIPPED,
|
|
154
|
+
include_passed: _include_passed_option = _DEFAULT_INCLUDE_PASSED,
|
|
155
|
+
exit_with_error: _exit_with_error_option = _DEFAULT_EXIT_WITH_ERROR,
|
|
156
|
+
):
|
|
157
|
+
context: config.OgcCiteRunnerContext = ctx.obj
|
|
158
|
+
context.status_console.print("Parsing test suite execution results...")
|
|
159
|
+
with click.open_file(test_suite_result) as fh:
|
|
160
|
+
raw_result = fh.read()
|
|
161
|
+
parsed = teamengine_runner.parse_test_suite_result(raw_result, context.settings)
|
|
162
|
+
context.status_console.print(f"Serializing parsed results to {output_format}...")
|
|
163
|
+
serialized = teamengine_runner.serialize_suite_result(
|
|
164
|
+
parsed,
|
|
165
|
+
output_format,
|
|
166
|
+
serialization_details=models.SerializationDetails(
|
|
167
|
+
include_summary=include_summary,
|
|
168
|
+
include_failed_detail=include_failed,
|
|
169
|
+
include_skipped_detail=include_skipped,
|
|
170
|
+
include_passed_detail=include_passed,
|
|
171
|
+
),
|
|
172
|
+
context=ctx.obj,
|
|
173
|
+
)
|
|
174
|
+
if output_format.print_pretty():
|
|
175
|
+
context.result_console.print(serialized)
|
|
176
|
+
else:
|
|
177
|
+
stdlib_print(serialized)
|
|
178
|
+
raise typer.Exit(_get_exit_code(parsed, exit_with_error))
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@app.command()
|
|
182
|
+
def execute_test_suite_from_github_actions(
|
|
183
|
+
ctx: typer.Context,
|
|
184
|
+
teamengine_base_url: _teamengine_base_url_argument,
|
|
185
|
+
test_suite_identifier: _test_suite_identifier_argument,
|
|
186
|
+
suite_input: typing.Annotated[
|
|
187
|
+
list[str],
|
|
188
|
+
typer.Argument(
|
|
189
|
+
help=(
|
|
190
|
+
"Space-separated list of inputs to be passed to teamengine. Each "
|
|
191
|
+
"input must be formatted as key=value. Ex: "
|
|
192
|
+
"iut=http://host.docker.internal:5000 noofcollections=-1"
|
|
193
|
+
)
|
|
194
|
+
),
|
|
195
|
+
],
|
|
196
|
+
teamengine_username: _teamengine_username_option = "ogctest",
|
|
197
|
+
teamengine_password: _teamengine_password_option = "ogctest",
|
|
198
|
+
output_format: _output_format_option = _DEFAULT_OUTPUT_FORMAT,
|
|
199
|
+
include_summary: _include_summary_option = _DEFAULT_INCLUDE_SUMMARY,
|
|
200
|
+
include_failed: _include_failed_option = _DEFAULT_INCLUDE_FAILED,
|
|
201
|
+
include_skipped: _include_skipped_option = _DEFAULT_INCLUDE_SKIPPED,
|
|
202
|
+
include_passed: _include_passed_option = _DEFAULT_INCLUDE_PASSED,
|
|
203
|
+
exit_with_error: _exit_with_error_option = _DEFAULT_EXIT_WITH_ERROR,
|
|
204
|
+
):
|
|
205
|
+
"""Execute a CITE test suite via github actions.
|
|
206
|
+
|
|
207
|
+
This command presents a simpler interface to run the
|
|
208
|
+
`execute-test-suite` command, making it easier to run as a github action.
|
|
209
|
+
"""
|
|
210
|
+
suite_inputs = {}
|
|
211
|
+
for raw_suite_input in suite_input:
|
|
212
|
+
param_name, param_value = raw_suite_input.partition("=")[::2]
|
|
213
|
+
param_values = suite_inputs.setdefault(param_name, [])
|
|
214
|
+
param_values.append(param_value)
|
|
215
|
+
parsed, serialized = _execute_test_suite(
|
|
216
|
+
ctx.obj,
|
|
217
|
+
teamengine_base_url=teamengine_base_url,
|
|
218
|
+
test_suite_identifier=test_suite_identifier,
|
|
219
|
+
teamengine_username=teamengine_username,
|
|
220
|
+
teamengine_password=teamengine_password,
|
|
221
|
+
test_suite_inputs=suite_inputs,
|
|
222
|
+
output_format=output_format,
|
|
223
|
+
serialization_details=models.SerializationDetails(
|
|
224
|
+
include_summary=include_summary,
|
|
225
|
+
include_failed_detail=include_failed,
|
|
226
|
+
include_skipped_detail=include_skipped,
|
|
227
|
+
include_passed_detail=include_passed,
|
|
228
|
+
),
|
|
229
|
+
)
|
|
230
|
+
context: config.OgcCiteRunnerContext = ctx.obj
|
|
231
|
+
if output_format.print_pretty():
|
|
232
|
+
context.result_console.print(serialized)
|
|
233
|
+
else:
|
|
234
|
+
stdlib_print(serialized)
|
|
235
|
+
raise typer.Exit(
|
|
236
|
+
0
|
|
237
|
+
if output_format == models.OutputFormat.RAW
|
|
238
|
+
else _get_exit_code(parsed, exit_with_error)
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
@app.command()
|
|
243
|
+
def execute_test_suite(
|
|
244
|
+
ctx: typer.Context,
|
|
245
|
+
teamengine_base_url: _teamengine_base_url_argument,
|
|
246
|
+
test_suite_identifier: _test_suite_identifier_argument,
|
|
247
|
+
teamengine_username: _teamengine_username_option = "ogctest",
|
|
248
|
+
teamengine_password: _teamengine_password_option = "ogctest",
|
|
249
|
+
suite_input: typing.Annotated[
|
|
250
|
+
typing.Optional[list[click.Tuple]],
|
|
251
|
+
typer.Option(
|
|
252
|
+
click_type=click.Tuple([str, str]),
|
|
253
|
+
help=(
|
|
254
|
+
"Input name and value separated by a space. "
|
|
255
|
+
"Ex: --suite-input iut http://host.docker.internal:5000"
|
|
256
|
+
),
|
|
257
|
+
),
|
|
258
|
+
] = None,
|
|
259
|
+
output_format: _output_format_option = _DEFAULT_OUTPUT_FORMAT,
|
|
260
|
+
include_summary: _include_summary_option = _DEFAULT_INCLUDE_SUMMARY,
|
|
261
|
+
include_failed: _include_failed_option = _DEFAULT_INCLUDE_FAILED,
|
|
262
|
+
include_skipped: _include_skipped_option = _DEFAULT_INCLUDE_SKIPPED,
|
|
263
|
+
include_passed: _include_passed_option = _DEFAULT_INCLUDE_PASSED,
|
|
264
|
+
exit_with_error: _exit_with_error_option = _DEFAULT_EXIT_WITH_ERROR,
|
|
265
|
+
):
|
|
266
|
+
"""Execute a CITE test suite."""
|
|
267
|
+
suite_inputs = {}
|
|
268
|
+
for param_name, param_value in suite_input:
|
|
269
|
+
param_values = suite_inputs.setdefault(param_name, [])
|
|
270
|
+
param_values.append(param_value)
|
|
271
|
+
context: config.OgcCiteRunnerContext = ctx.obj
|
|
272
|
+
parsed, serialized = _execute_test_suite(
|
|
273
|
+
context,
|
|
274
|
+
teamengine_base_url=teamengine_base_url,
|
|
275
|
+
test_suite_identifier=test_suite_identifier,
|
|
276
|
+
teamengine_username=teamengine_username,
|
|
277
|
+
teamengine_password=teamengine_password,
|
|
278
|
+
test_suite_inputs=suite_inputs,
|
|
279
|
+
output_format=output_format,
|
|
280
|
+
serialization_details=models.SerializationDetails(
|
|
281
|
+
include_summary=include_summary,
|
|
282
|
+
include_failed_detail=include_failed,
|
|
283
|
+
include_skipped_detail=include_skipped,
|
|
284
|
+
include_passed_detail=include_passed,
|
|
285
|
+
),
|
|
286
|
+
)
|
|
287
|
+
if output_format == models.OutputFormat.RAW:
|
|
288
|
+
logger.debug("Outputting raw response, as returned by teamengine...")
|
|
289
|
+
if output_format.print_pretty():
|
|
290
|
+
context.result_console.print(serialized)
|
|
291
|
+
else:
|
|
292
|
+
stdlib_print(serialized)
|
|
293
|
+
raise typer.Exit(
|
|
294
|
+
0
|
|
295
|
+
if output_format == models.OutputFormat.RAW
|
|
296
|
+
else _get_exit_code(parsed, exit_with_error)
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def _execute_test_suite(
|
|
301
|
+
context: config.OgcCiteRunnerContext,
|
|
302
|
+
teamengine_base_url: str,
|
|
303
|
+
test_suite_identifier: str,
|
|
304
|
+
teamengine_username: pydantic.SecretStr,
|
|
305
|
+
teamengine_password: pydantic.SecretStr,
|
|
306
|
+
test_suite_inputs: dict[str, list[str]],
|
|
307
|
+
output_format: models.OutputFormat,
|
|
308
|
+
serialization_details: models.SerializationDetails,
|
|
309
|
+
) -> tuple[models.TestSuiteResult | None, str]:
|
|
310
|
+
logger.debug(f"{locals()=}")
|
|
311
|
+
client = httpx.Client(timeout=context.network_timeout_seconds)
|
|
312
|
+
base_url = teamengine_base_url.strip("/")
|
|
313
|
+
context.status_console.print("Checking if teamengine is ready...")
|
|
314
|
+
if teamengine_runner.wait_for_teamengine_to_be_ready(client, base_url):
|
|
315
|
+
context.status_console.print(
|
|
316
|
+
f"Asking teamengine to execute test suite {test_suite_identifier!r}..."
|
|
317
|
+
)
|
|
318
|
+
try:
|
|
319
|
+
raw_result = teamengine_runner.execute_test_suite(
|
|
320
|
+
client,
|
|
321
|
+
base_url,
|
|
322
|
+
test_suite_identifier,
|
|
323
|
+
test_suite_arguments=test_suite_inputs,
|
|
324
|
+
teamengine_username=teamengine_username,
|
|
325
|
+
teamengine_password=teamengine_password,
|
|
326
|
+
)
|
|
327
|
+
except exceptions.OgcCiteRunnerException:
|
|
328
|
+
logger.exception("Unable to collect test suite execution results")
|
|
329
|
+
raise SystemExit(1)
|
|
330
|
+
else:
|
|
331
|
+
context.status_console.print(
|
|
332
|
+
"Received teamengine execution result in EARL format"
|
|
333
|
+
)
|
|
334
|
+
parsed = None
|
|
335
|
+
if output_format == models.OutputFormat.RAW:
|
|
336
|
+
context.status_console.print(
|
|
337
|
+
"Outputting raw response, as returned by teamengine..."
|
|
338
|
+
)
|
|
339
|
+
serialized = raw_result
|
|
340
|
+
else:
|
|
341
|
+
context.status_console.print("Parsing test suite execution results...")
|
|
342
|
+
parsed = teamengine_runner.parse_test_suite_result(
|
|
343
|
+
raw_result, context.settings
|
|
344
|
+
)
|
|
345
|
+
context.status_console.print(
|
|
346
|
+
f"Serializing parsed results to {output_format}..."
|
|
347
|
+
)
|
|
348
|
+
serialized = teamengine_runner.serialize_suite_result(
|
|
349
|
+
parsed,
|
|
350
|
+
output_format,
|
|
351
|
+
serialization_details,
|
|
352
|
+
context,
|
|
353
|
+
)
|
|
354
|
+
return parsed, serialized
|
|
355
|
+
else:
|
|
356
|
+
logger.critical("teamengine service is not available")
|
|
357
|
+
raise SystemExit(1)
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def _get_exit_code(
|
|
361
|
+
parsed: models.TestSuiteResult, exit_with_error_on_suite_failed_result: bool
|
|
362
|
+
) -> int:
|
|
363
|
+
return 0 if parsed.passed else (1 if exit_with_error_on_suite_failed_result else 0)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import datetime as dt
|
|
2
|
+
import enum
|
|
3
|
+
from typing import Generator
|
|
4
|
+
|
|
5
|
+
import pydantic
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class OutputFormat(str, enum.Enum):
|
|
9
|
+
JSON = "json"
|
|
10
|
+
MARKDOWN = "markdown"
|
|
11
|
+
RAW = "raw"
|
|
12
|
+
CONSOLE = "console"
|
|
13
|
+
|
|
14
|
+
def print_pretty(self) -> bool:
|
|
15
|
+
return {
|
|
16
|
+
self.JSON: False,
|
|
17
|
+
self.RAW: False,
|
|
18
|
+
}.get(self, True)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TestStatus(enum.Enum):
|
|
22
|
+
CANT_TELL = "CANT_TELL"
|
|
23
|
+
PASSED = "PASSED"
|
|
24
|
+
FAILED = "FAILED"
|
|
25
|
+
SKIPPED = "SKIPPED"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class SerializationDetails(pydantic.BaseModel):
|
|
29
|
+
include_summary: bool
|
|
30
|
+
include_failed_detail: bool
|
|
31
|
+
include_skipped_detail: bool
|
|
32
|
+
include_passed_detail: bool
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class TestSuiteInput(pydantic.BaseModel):
|
|
36
|
+
name: str
|
|
37
|
+
value: str
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class TestCaseResult(pydantic.BaseModel):
|
|
41
|
+
identifier: str
|
|
42
|
+
status: TestStatus
|
|
43
|
+
detail: str | None
|
|
44
|
+
name: str | None
|
|
45
|
+
description: str | None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ConformanceClassResult(pydantic.BaseModel):
|
|
49
|
+
title: str
|
|
50
|
+
description: str
|
|
51
|
+
num_failed_tests: int
|
|
52
|
+
num_passed_tests: int
|
|
53
|
+
num_skipped_tests: int
|
|
54
|
+
tests: list[TestCaseResult]
|
|
55
|
+
|
|
56
|
+
def gen_failed_tests(self) -> Generator[TestCaseResult, None, None]:
|
|
57
|
+
for test_case in self.tests:
|
|
58
|
+
if test_case.status in (TestStatus.FAILED, TestStatus.CANT_TELL):
|
|
59
|
+
yield test_case
|
|
60
|
+
|
|
61
|
+
def gen_skipped_tests(self) -> Generator[TestCaseResult, None, None]:
|
|
62
|
+
for test_case in self.tests:
|
|
63
|
+
if test_case.status == TestStatus.SKIPPED:
|
|
64
|
+
yield test_case
|
|
65
|
+
|
|
66
|
+
def gen_passed_tests(self) -> Generator[TestCaseResult, None, None]:
|
|
67
|
+
for test_case in self.tests:
|
|
68
|
+
if test_case.status == TestStatus.PASSED:
|
|
69
|
+
yield test_case
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class TestSuiteResult(pydantic.BaseModel):
|
|
73
|
+
suite_identifier: str
|
|
74
|
+
suite_title: str
|
|
75
|
+
test_run_start: dt.datetime
|
|
76
|
+
test_run_end: dt.datetime
|
|
77
|
+
test_run_duration: dt.timedelta
|
|
78
|
+
num_tests_total: int
|
|
79
|
+
num_failed_tests: int
|
|
80
|
+
num_skipped_tests: int
|
|
81
|
+
num_passed_tests: int
|
|
82
|
+
inputs: list[TestSuiteInput]
|
|
83
|
+
conformance_class_results: list[ConformanceClassResult]
|
|
84
|
+
passed: bool
|
|
File without changes
|