python-utility-scripts 0.0.42__tar.gz → 0.0.44__tar.gz
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.
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/PKG-INFO +2 -2
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/polarion/polarion_set_automated.py +8 -7
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/polarion/polarion_utils.py +5 -6
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/polarion/polarion_verify_tc_requirements.py +9 -8
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/unused_code/unused_code.py +4 -5
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/pyproject.toml +2 -2
- python_utility_scripts-0.0.42/apps/polarion/exceptions.py +0 -6
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/LICENSE +0 -0
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/README.md +0 -0
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/__init__.py +0 -0
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/polarion/README.md +0 -0
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/polarion/__init__.py +0 -0
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/unused_code/README.md +0 -0
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/unused_code/__init__.py +0 -0
- {python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-utility-scripts
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.44
|
|
4
4
|
Summary: Python utility scripts
|
|
5
5
|
Home-page: https://github.com/RedHatQE/python-utility-scripts
|
|
6
6
|
License: Apache-2.0
|
|
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Requires-Dist: pyhelper-utils (>=0.0.
|
|
18
|
+
Requires-Dist: pyhelper-utils (>=0.0.41,<0.0.42)
|
|
19
19
|
Requires-Dist: pylero (>=0.1.0,<0.2.0)
|
|
20
20
|
Requires-Dist: pytest-mock (>=3.14.0,<4.0.0)
|
|
21
21
|
Requires-Dist: python-simple-logger (>=1.0.8,<2.0.0)
|
|
@@ -2,10 +2,9 @@ from __future__ import annotations
|
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
4
|
from simple_logger.logger import get_logger
|
|
5
|
-
|
|
5
|
+
import sys
|
|
6
6
|
import click
|
|
7
7
|
|
|
8
|
-
from apps.polarion.exceptions import PolarionTestCaseApprovalError
|
|
9
8
|
from apps.polarion.polarion_utils import get_polarion_project_id, find_polarion_ids, update_polarion_ids
|
|
10
9
|
from typing import List, Dict, Optional
|
|
11
10
|
|
|
@@ -48,16 +47,18 @@ def remove_approved_tests(
|
|
|
48
47
|
@click.option("--verbose", default=False, is_flag=True)
|
|
49
48
|
def polarion_approve_automate(config_file_path: str, project_id: str, branch: str, verbose: bool) -> None:
|
|
50
49
|
if verbose:
|
|
51
|
-
LOGGER.setLevel(logging.
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
LOGGER.setLevel(logging.DEBUG)
|
|
51
|
+
# since the utilities are in apps.polarion.polarion_utils, we need to change log level
|
|
52
|
+
# for apps.polarion.polarion_utils as well
|
|
53
|
+
logging.getLogger("apps.polarion.polarion_utils").setLevel(logging.DEBUG)
|
|
54
|
+
|
|
54
55
|
polarion_project_id = project_id or get_polarion_project_id(
|
|
55
56
|
config_file_path=config_file_path, util_name="pyutils-polarion-set-automated"
|
|
56
57
|
)
|
|
57
58
|
added_polarions = {}
|
|
58
59
|
if added_ids := find_polarion_ids(polarion_project_id=polarion_project_id, string_to_match="added", branch=branch):
|
|
59
60
|
added_polarions = approve_tests(polarion_project_id=polarion_project_id, added_ids=added_ids)
|
|
60
|
-
LOGGER.
|
|
61
|
+
LOGGER.debug(f"Following polarion ids were marked automated and approved: {added_polarions.get('updated')}")
|
|
61
62
|
|
|
62
63
|
removed_polarions = remove_approved_tests(
|
|
63
64
|
polarion_project_id=polarion_project_id, added_ids=added_ids, branch=branch
|
|
@@ -69,7 +70,7 @@ def polarion_approve_automate(config_file_path: str, project_id: str, branch: st
|
|
|
69
70
|
if added_polarions.get("failed"):
|
|
70
71
|
error += f" Added ids:: {added_polarions.get('failed')}."
|
|
71
72
|
LOGGER.error(error)
|
|
72
|
-
|
|
73
|
+
sys.exit(1)
|
|
73
74
|
|
|
74
75
|
|
|
75
76
|
if __name__ == "__main__":
|
{python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/polarion/polarion_utils.py
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
import re
|
|
3
|
-
|
|
4
|
-
import click
|
|
3
|
+
import sys
|
|
5
4
|
from simple_logger.logger import get_logger
|
|
6
5
|
import shlex
|
|
7
6
|
import subprocess
|
|
@@ -23,7 +22,7 @@ def git_diff(branch: str) -> str:
|
|
|
23
22
|
def git_diff_lines(branch: str) -> Dict[str, List[str]]:
|
|
24
23
|
diff: Dict[str, List[str]] = {}
|
|
25
24
|
for line in git_diff(branch=branch).splitlines():
|
|
26
|
-
LOGGER.
|
|
25
|
+
LOGGER.debug(line)
|
|
27
26
|
if line.startswith("+"):
|
|
28
27
|
diff.setdefault("added", []).append(line)
|
|
29
28
|
if line.startswith("-"):
|
|
@@ -42,7 +41,7 @@ def validate_polarion_requirements(
|
|
|
42
41
|
|
|
43
42
|
for _id in polarion_test_ids:
|
|
44
43
|
has_req = False
|
|
45
|
-
LOGGER.
|
|
44
|
+
LOGGER.debug(f"Checking if {_id} verifies any requirement")
|
|
46
45
|
tc = TestCase(project_id=polarion_project_id, work_item_id=_id)
|
|
47
46
|
for link in tc.linked_work_items:
|
|
48
47
|
try:
|
|
@@ -70,7 +69,7 @@ def get_polarion_project_id(util_name: str, config_file_path: str) -> str:
|
|
|
70
69
|
polarion_project_id = get_util_config(util_name=util_name, config_file_path=config_file_path).get("project_id")
|
|
71
70
|
if not polarion_project_id:
|
|
72
71
|
LOGGER.error("Polarion project id must be passed via config file or command line")
|
|
73
|
-
|
|
72
|
+
sys.exit(1)
|
|
74
73
|
return polarion_project_id
|
|
75
74
|
|
|
76
75
|
|
|
@@ -91,7 +90,7 @@ def update_polarion_ids(
|
|
|
91
90
|
if is_approved:
|
|
92
91
|
tc.status = APPROVED
|
|
93
92
|
tc.update()
|
|
94
|
-
LOGGER.
|
|
93
|
+
LOGGER.debug(f"Polarion {id}: marked as: {automation_status}, approved status set: {is_approved}")
|
|
95
94
|
updated_ids.setdefault("updated", []).append(id)
|
|
96
95
|
except PyleroLibException as polarion_exception:
|
|
97
96
|
error = f"{id}: {polarion_exception}"
|
|
@@ -2,8 +2,8 @@ import logging
|
|
|
2
2
|
from simple_logger.logger import get_logger
|
|
3
3
|
import os
|
|
4
4
|
import click
|
|
5
|
+
import sys
|
|
5
6
|
|
|
6
|
-
from apps.polarion.exceptions import PolarionTestCaseWithoutRequirementError
|
|
7
7
|
from apps.polarion.polarion_utils import validate_polarion_requirements, find_polarion_ids, get_polarion_project_id
|
|
8
8
|
|
|
9
9
|
LOGGER = get_logger(name="polarion-verify-tc-requirements")
|
|
@@ -21,21 +21,22 @@ LOGGER = get_logger(name="polarion-verify-tc-requirements")
|
|
|
21
21
|
@click.option("--verbose", default=False, is_flag=True)
|
|
22
22
|
def has_verify(config_file_path: str, project_id: str, branch: str, verbose: bool) -> None:
|
|
23
23
|
if verbose:
|
|
24
|
-
LOGGER.setLevel(logging.
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
LOGGER.setLevel(logging.DEBUG)
|
|
25
|
+
# since the utilities are in apps.polarion.polarion_utils, we need to change log level
|
|
26
|
+
# for apps.polarion.polarion_utils as well
|
|
27
|
+
logging.getLogger("apps.polarion.polarion_utils").setLevel(logging.DEBUG)
|
|
28
|
+
|
|
27
29
|
polarion_project_id = project_id or get_polarion_project_id(
|
|
28
30
|
config_file_path=config_file_path, util_name="pyutils-polarion-verify-tc-requirements"
|
|
29
31
|
)
|
|
30
32
|
if added_ids := find_polarion_ids(polarion_project_id=polarion_project_id, string_to_match="added", branch=branch):
|
|
31
|
-
LOGGER.
|
|
33
|
+
LOGGER.debug(f"Checking following ids: {added_ids}")
|
|
32
34
|
if tests_with_missing_requirements := validate_polarion_requirements(
|
|
33
35
|
polarion_test_ids=added_ids,
|
|
34
36
|
polarion_project_id=polarion_project_id,
|
|
35
37
|
):
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
38
|
+
LOGGER.error(f"TestCases with missing requirement: {tests_with_missing_requirements}")
|
|
39
|
+
sys.exit(1)
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
if __name__ == "__main__":
|
{python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/unused_code/unused_code.py
RENAMED
|
@@ -2,6 +2,8 @@ import ast
|
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
4
|
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
|
|
5
7
|
import click
|
|
6
8
|
from simple_logger.logger import get_logger
|
|
7
9
|
|
|
@@ -69,10 +71,7 @@ def is_ignore_function_list(ignore_prefix_list: List[str], function: ast.Functio
|
|
|
69
71
|
def get_unused_functions(
|
|
70
72
|
config_file_path: Any, exclude_files: Any, exclude_function_prefixes: Any, verbose: bool
|
|
71
73
|
) -> Any:
|
|
72
|
-
if verbose
|
|
73
|
-
LOGGER.setLevel(logging.DEBUG)
|
|
74
|
-
else:
|
|
75
|
-
logging.disable(logging.CRITICAL)
|
|
74
|
+
LOGGER.setLevel(logging.DEBUG if verbose else logging.INFO)
|
|
76
75
|
|
|
77
76
|
_unused_functions = []
|
|
78
77
|
unused_code_config = get_util_config(util_name="pyutils-unusedcode", config_file_path=config_file_path)
|
|
@@ -104,7 +103,7 @@ def get_unused_functions(
|
|
|
104
103
|
)
|
|
105
104
|
if _unused_functions:
|
|
106
105
|
click.echo("\n".join(_unused_functions))
|
|
107
|
-
|
|
106
|
+
sys.exit(1)
|
|
108
107
|
|
|
109
108
|
|
|
110
109
|
if __name__ == "__main__":
|
|
@@ -29,7 +29,7 @@ exclude = [".git", ".venv", ".mypy_cache", ".tox", "__pycache__"]
|
|
|
29
29
|
|
|
30
30
|
[tool.poetry]
|
|
31
31
|
name = "python-utility-scripts"
|
|
32
|
-
version = "0.0.
|
|
32
|
+
version = "0.0.44"
|
|
33
33
|
description = "Python utility scripts"
|
|
34
34
|
authors = ["dbasunag <dbasunag@redhat.com>"]
|
|
35
35
|
license = "Apache License 2.0"
|
|
@@ -53,7 +53,7 @@ pyutils-polarion-set-automated = "apps.polarion.polarion_set_automated:polarion_
|
|
|
53
53
|
python = "^3.8"
|
|
54
54
|
python-simple-logger = "^1.0.8"
|
|
55
55
|
pylero = "^0.1.0"
|
|
56
|
-
pyhelper-utils = "^0.0.
|
|
56
|
+
pyhelper-utils = "^0.0.41"
|
|
57
57
|
pytest-mock = "^3.14.0"
|
|
58
58
|
pyyaml = "^6.0.1"
|
|
59
59
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_utility_scripts-0.0.42 → python_utility_scripts-0.0.44}/apps/unused_code/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|