csspin-python 2.0.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.
- csspin_python/aws_auth.py +195 -0
- csspin_python/aws_auth_schema.yaml +38 -0
- csspin_python/behave.py +150 -0
- csspin_python/behave_schema.yaml +39 -0
- csspin_python/debugpy.py +32 -0
- csspin_python/debugpy_schema.yaml +14 -0
- csspin_python/devpi.py +82 -0
- csspin_python/devpi_schema.yaml +17 -0
- csspin_python/playwright.py +126 -0
- csspin_python/playwright_schema.yaml +33 -0
- csspin_python/pytest.py +97 -0
- csspin_python/pytest_schema.yaml +27 -0
- csspin_python/python.py +970 -0
- csspin_python/python_schema.yaml +131 -0
- csspin_python/radon.py +59 -0
- csspin_python/radon_schema.yaml +17 -0
- csspin_python-2.0.0.dist-info/METADATA +109 -0
- csspin_python-2.0.0.dist-info/RECORD +21 -0
- csspin_python-2.0.0.dist-info/WHEEL +5 -0
- csspin_python-2.0.0.dist-info/licenses/LICENSE +176 -0
- csspin_python-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# -*- mode: python; coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2024 CONTACT Software GmbH
|
|
4
|
+
# https://www.contact-software.com/
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
"""Module implementing the playwright plugin for spin"""
|
|
19
|
+
|
|
20
|
+
from csspin import Path, Verbosity, config, die, option, setenv, sh, task
|
|
21
|
+
|
|
22
|
+
defaults = config(
|
|
23
|
+
browsers_path="{spin.data}/playwright_browsers",
|
|
24
|
+
browsers=["chromium"],
|
|
25
|
+
coverage=False,
|
|
26
|
+
coverage_opts=[
|
|
27
|
+
"--cov-reset",
|
|
28
|
+
"--cov",
|
|
29
|
+
"--cov-report=term",
|
|
30
|
+
"--cov-report=html",
|
|
31
|
+
"--cov-report=xml:{playwright.coverage_report}",
|
|
32
|
+
],
|
|
33
|
+
coverage_report="python-playwright-coverage.xml",
|
|
34
|
+
opts=["-m", "e2e"],
|
|
35
|
+
tests=["cs", "tests"], # Strong convention @CONTACT
|
|
36
|
+
test_report="playwright.xml",
|
|
37
|
+
requires=config(
|
|
38
|
+
spin=[
|
|
39
|
+
"csspin_python.debugpy",
|
|
40
|
+
"csspin_python.python",
|
|
41
|
+
"csspin_python.pytest",
|
|
42
|
+
],
|
|
43
|
+
python=[
|
|
44
|
+
"pytest-base-url",
|
|
45
|
+
"pytest-playwright",
|
|
46
|
+
],
|
|
47
|
+
),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@task(when="cept")
|
|
52
|
+
def playwright( # pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
53
|
+
cfg,
|
|
54
|
+
instance: option(
|
|
55
|
+
"-i", # noqa: F821
|
|
56
|
+
"--instance", # noqa: F821
|
|
57
|
+
default=None,
|
|
58
|
+
help="Directory of the CONTACT Elements instance.", # noqa: F722
|
|
59
|
+
),
|
|
60
|
+
coverage: option(
|
|
61
|
+
"-c", # noqa: F821
|
|
62
|
+
"--coverage", # noqa: F821
|
|
63
|
+
is_flag=True,
|
|
64
|
+
help="Run the tests while collecting coverage.", # noqa: F722
|
|
65
|
+
),
|
|
66
|
+
debug: option(
|
|
67
|
+
"--debug", is_flag=True, help="Start debug server." # noqa: F722,F821
|
|
68
|
+
),
|
|
69
|
+
with_test_report: option(
|
|
70
|
+
"--with-test-report", # noqa: F722
|
|
71
|
+
is_flag=True,
|
|
72
|
+
help="Create a test execution report.", # noqa: F722
|
|
73
|
+
),
|
|
74
|
+
args,
|
|
75
|
+
):
|
|
76
|
+
"""Run the playwright tests with pytest."""
|
|
77
|
+
setenv(
|
|
78
|
+
PLAYWRIGHT_BROWSERS_PATH=cfg.playwright.browsers_path,
|
|
79
|
+
PACKAGE_NAME=cfg.spin.project_name,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
opts = cfg.playwright.opts
|
|
83
|
+
if cfg.verbosity == Verbosity.QUIET:
|
|
84
|
+
opts.append("-q")
|
|
85
|
+
if with_test_report and cfg.playwright.test_report:
|
|
86
|
+
opts.append(f"--junitxml={cfg.playwright.test_report}")
|
|
87
|
+
if coverage or cfg.playwright.coverage:
|
|
88
|
+
opts.extend(cfg.playwright.coverage_opts)
|
|
89
|
+
setenv(PLAYWRIGHT_COVERAGE=1)
|
|
90
|
+
|
|
91
|
+
for browser in cfg.playwright.browsers:
|
|
92
|
+
opts.extend(["--browser", browser])
|
|
93
|
+
|
|
94
|
+
if debug:
|
|
95
|
+
cmd = f"debugpy {' '.join(cfg.debugpy.opts)} -m pytest".split()
|
|
96
|
+
else:
|
|
97
|
+
cmd = ["pytest"]
|
|
98
|
+
|
|
99
|
+
# Run the browser download again, so that changes for
|
|
100
|
+
# cfg.playwright.browsers don't require a new provision call. If the
|
|
101
|
+
# browsers are already present it's more or less a noop.
|
|
102
|
+
_download_playwright_browsers(cfg)
|
|
103
|
+
|
|
104
|
+
if cfg.loaded.get("csspin_ce.mkinstance"):
|
|
105
|
+
if not (
|
|
106
|
+
inst := Path(instance or cfg.mkinstance.base.instance_location).absolute()
|
|
107
|
+
).is_dir():
|
|
108
|
+
die(f"Cannot find CE instance '{inst}'.")
|
|
109
|
+
|
|
110
|
+
setenv(CADDOK_BASE=inst)
|
|
111
|
+
sh(*cmd, *opts, *args, *cfg.playwright.tests)
|
|
112
|
+
else:
|
|
113
|
+
sh(*cmd, *opts, *args, *cfg.playwright.tests)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _download_playwright_browsers(cfg):
|
|
117
|
+
"""Let playwright install the browsers"""
|
|
118
|
+
sh(
|
|
119
|
+
f"playwright install {' '.join(cfg.playwright.browsers)}",
|
|
120
|
+
env={"PLAYWRIGHT_BROWSERS_PATH": cfg.playwright.browsers_path},
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def provision(cfg):
|
|
125
|
+
"""Install playwright browsers during provisioning"""
|
|
126
|
+
_download_playwright_browsers(cfg)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# -*- mode: yaml; coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Schema for the playwright plugin for spin
|
|
4
|
+
|
|
5
|
+
playwright:
|
|
6
|
+
type: object
|
|
7
|
+
help: |
|
|
8
|
+
The pytest plugin provides the full pytest experience for spin.
|
|
9
|
+
properties:
|
|
10
|
+
browsers_path:
|
|
11
|
+
type: path
|
|
12
|
+
help: Path for playwright to install the browsers.
|
|
13
|
+
browsers:
|
|
14
|
+
type: list
|
|
15
|
+
help: The browsers to install and to use for running the playwright tests.
|
|
16
|
+
coverage:
|
|
17
|
+
type: bool
|
|
18
|
+
help: Enable or disable code coverage analysis.
|
|
19
|
+
coverage_opts:
|
|
20
|
+
type: list
|
|
21
|
+
help: Additional options for the coverage run.
|
|
22
|
+
coverage_report:
|
|
23
|
+
type: str
|
|
24
|
+
help: File to write the coverage report to.
|
|
25
|
+
opts:
|
|
26
|
+
type: list
|
|
27
|
+
help: Additional options for the pytest command.
|
|
28
|
+
test_report:
|
|
29
|
+
type: path
|
|
30
|
+
help: Path to write the test report to.
|
|
31
|
+
tests:
|
|
32
|
+
type: list
|
|
33
|
+
help: List of test files or directories to include.
|
csspin_python/pytest.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# -*- mode: python; coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2022 CONTACT Software GmbH
|
|
4
|
+
# https://www.contact-software.com/
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
"""Module implementing the pytest plugin for spin"""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
from csspin import Path, Verbosity, config, die, option, setenv, sh, task
|
|
22
|
+
|
|
23
|
+
defaults = config(
|
|
24
|
+
coverage=False,
|
|
25
|
+
coverage_opts=[
|
|
26
|
+
"--cov-reset",
|
|
27
|
+
"--cov",
|
|
28
|
+
"--cov-report=term",
|
|
29
|
+
"--cov-report=html",
|
|
30
|
+
"--cov-report=xml:{pytest.coverage_report}",
|
|
31
|
+
],
|
|
32
|
+
coverage_report="python-pytest-coverage.xml",
|
|
33
|
+
opts=[],
|
|
34
|
+
tests=["cs", "tests"], # Strong convention @CONTACT
|
|
35
|
+
test_report="pytest.xml",
|
|
36
|
+
requires=config(
|
|
37
|
+
spin=[
|
|
38
|
+
"csspin_python.debugpy",
|
|
39
|
+
"csspin_python.python",
|
|
40
|
+
],
|
|
41
|
+
python=[
|
|
42
|
+
"debugpy",
|
|
43
|
+
"pytest",
|
|
44
|
+
"pytest-cov",
|
|
45
|
+
],
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@task(when="test")
|
|
51
|
+
def pytest( # pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
52
|
+
cfg,
|
|
53
|
+
instance: option(
|
|
54
|
+
"-i", # noqa: F821
|
|
55
|
+
"--instance", # noqa: F821
|
|
56
|
+
default=None,
|
|
57
|
+
help="Directory of the CONTACT Elements instance.", # noqa: F722
|
|
58
|
+
),
|
|
59
|
+
coverage: option(
|
|
60
|
+
"-c", # noqa: F821
|
|
61
|
+
"--coverage", # noqa: F821
|
|
62
|
+
is_flag=True,
|
|
63
|
+
help="Run the tests while collecting coverage.", # noqa: F722
|
|
64
|
+
),
|
|
65
|
+
debug: option(
|
|
66
|
+
"--debug", is_flag=True, help="Start debug server." # noqa: F722,F821
|
|
67
|
+
),
|
|
68
|
+
with_test_report: option(
|
|
69
|
+
"--with-test-report", # noqa: F722
|
|
70
|
+
is_flag=True,
|
|
71
|
+
help="Create a test execution report.", # noqa: F722
|
|
72
|
+
),
|
|
73
|
+
args,
|
|
74
|
+
):
|
|
75
|
+
"""Run the 'pytest' command."""
|
|
76
|
+
opts = cfg.pytest.opts
|
|
77
|
+
if cfg.verbosity == Verbosity.QUIET:
|
|
78
|
+
opts.append("-q")
|
|
79
|
+
if with_test_report and cfg.pytest.test_report:
|
|
80
|
+
opts.append(f"--junitxml={cfg.pytest.test_report}")
|
|
81
|
+
if coverage or cfg.pytest.coverage:
|
|
82
|
+
opts.extend(cfg.pytest.coverage_opts)
|
|
83
|
+
if debug:
|
|
84
|
+
cmd = f"debugpy {' '.join(cfg.debugpy.opts)} -m pytest".split()
|
|
85
|
+
else:
|
|
86
|
+
cmd = ["pytest"]
|
|
87
|
+
|
|
88
|
+
if cfg.loaded.get("csspin_ce.mkinstance"):
|
|
89
|
+
if not (
|
|
90
|
+
inst := Path(instance or cfg.mkinstance.base.instance_location).absolute()
|
|
91
|
+
).is_dir():
|
|
92
|
+
die(f"Cannot find CE instance '{inst}'.")
|
|
93
|
+
|
|
94
|
+
setenv(CADDOK_BASE=inst)
|
|
95
|
+
sh(*cmd, *opts, *args, *cfg.pytest.tests)
|
|
96
|
+
else:
|
|
97
|
+
sh(*cmd, *opts, *args, *cfg.pytest.tests)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- mode: yaml; coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Schema for the pytest plugin for spin
|
|
4
|
+
|
|
5
|
+
pytest:
|
|
6
|
+
type: object
|
|
7
|
+
help: |
|
|
8
|
+
The pytest plugin provides the full pytest experience for spin.
|
|
9
|
+
properties:
|
|
10
|
+
coverage:
|
|
11
|
+
type: bool
|
|
12
|
+
help: Enable or disable code coverage analysis.
|
|
13
|
+
opts:
|
|
14
|
+
type: list
|
|
15
|
+
help: Additional options for the pytest command.
|
|
16
|
+
test_report:
|
|
17
|
+
type: path
|
|
18
|
+
help: Path to write the test report to.
|
|
19
|
+
coverage_opts:
|
|
20
|
+
type: list
|
|
21
|
+
help: Additional options for the coverage run.
|
|
22
|
+
coverage_report:
|
|
23
|
+
type: str
|
|
24
|
+
help: File to write the coverage report to.
|
|
25
|
+
tests:
|
|
26
|
+
type: list
|
|
27
|
+
help: List of test files or directories to include.
|