testit-python-commons 3.7.2__tar.gz → 3.10.8.post550__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.
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/PKG-INFO +2 -2
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/setup.py +2 -2
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/client/api_client.py +129 -156
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/client/client_configuration.py +5 -9
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/client/converter.py +159 -30
- testit_python_commons-3.10.8.post550/src/testit_python_commons/client/helpers/__init__.py +0 -0
- testit_python_commons-3.10.8.post550/src/testit_python_commons/client/helpers/bulk_autotest_helper.py +222 -0
- testit_python_commons-3.10.8.post550/src/testit_python_commons/client/helpers/threads_manager.py +86 -0
- testit_python_commons-3.10.8.post550/src/testit_python_commons/client/models/__init__.py +8 -0
- testit_python_commons-3.10.8.post550/src/testit_python_commons/client/models/threads_for_create_and_result.py +35 -0
- testit_python_commons-3.10.8.post550/src/testit_python_commons/client/models/threads_for_update_and_result.py +45 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/decorators.py +2 -1
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/link.py +3 -2
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/step_result.py +7 -4
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/test_result.py +26 -23
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/test_result_with_all_fixture_step_results_model.py +5 -6
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/adapter_manager.py +30 -10
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/adapter_manager_configuration.py +7 -2
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/step_manager.py +3 -3
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/step_result_storage.py +2 -2
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/step.py +5 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/utils/html_escape_utils.py +6 -4
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons.egg-info/PKG-INFO +2 -2
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons.egg-info/SOURCES.txt +6 -0
- testit_python_commons-3.10.8.post550/src/testit_python_commons.egg-info/requires.txt +3 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/tests/test_app_properties.py +1 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/tests/test_html_escape_utils.py +13 -13
- testit_python_commons-3.7.2/src/testit_python_commons.egg-info/requires.txt +0 -3
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/README.md +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/setup.cfg +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/__init__.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/app_properties.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/client/__init__.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/dynamic_methods.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/__init__.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/adapter_mode.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/fixture.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/link_type.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/models/outcome_type.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/__init__.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/fixture_manager.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/fixture_storage.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/logger.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/plugin_manager.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/retry.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/services/utils.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons/utils/__init__.py +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons.egg-info/dependency_links.txt +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/src/testit_python_commons.egg-info/top_level.txt +0 -0
- {testit_python_commons-3.7.2 → testit_python_commons-3.10.8.post550}/tests/test_dynamic_methods.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: testit-python-commons
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.10.8.post550
|
|
4
4
|
Summary: Python commons for Test IT
|
|
5
5
|
Home-page: https://github.com/testit-tms/adapters-python/
|
|
6
6
|
Author: Integration team
|
|
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
Requires-Dist: pluggy
|
|
19
19
|
Requires-Dist: tomli
|
|
20
|
-
Requires-Dist: testit-api-client==7.0.
|
|
20
|
+
Requires-Dist: testit-api-client==7.2.0.post550
|
|
21
21
|
Dynamic: author
|
|
22
22
|
Dynamic: author-email
|
|
23
23
|
Dynamic: classifier
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from setuptools import find_packages, setup
|
|
2
2
|
|
|
3
|
-
VERSION = "3.
|
|
3
|
+
VERSION = "3.10.8.post550"
|
|
4
4
|
|
|
5
5
|
setup(
|
|
6
6
|
name='testit-python-commons',
|
|
@@ -25,5 +25,5 @@ setup(
|
|
|
25
25
|
py_modules=['testit', 'testit_python_commons'],
|
|
26
26
|
packages=find_packages(where='src'),
|
|
27
27
|
package_dir={'': 'src'},
|
|
28
|
-
install_requires=['pluggy', 'tomli', 'testit-api-client==7.0.
|
|
28
|
+
install_requires=['pluggy', 'tomli', 'testit-api-client==7.2.0.post550']
|
|
29
29
|
)
|
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
|
-
import typing
|
|
4
3
|
from datetime import datetime
|
|
5
4
|
|
|
6
5
|
from testit_api_client import ApiClient, Configuration
|
|
7
6
|
from testit_api_client.apis import AttachmentsApi, AutoTestsApi, TestRunsApi, TestResultsApi, WorkItemsApi
|
|
8
7
|
from testit_api_client.models import (
|
|
8
|
+
ApiV2TestResultsSearchPostRequest,
|
|
9
9
|
AutoTestApiResult,
|
|
10
10
|
AutoTestPostModel,
|
|
11
11
|
AutoTestPutModel,
|
|
12
12
|
AttachmentPutModel,
|
|
13
|
-
AutoTestResultsForTestRunModel,
|
|
14
13
|
TestResultResponse,
|
|
15
|
-
|
|
14
|
+
TestResultShortResponse,
|
|
15
|
+
TestRunV2ApiResult,
|
|
16
|
+
LinkAutoTestToWorkItemRequest,
|
|
16
17
|
WorkItemIdentifierModel
|
|
17
18
|
)
|
|
18
19
|
|
|
19
20
|
from testit_python_commons.client.client_configuration import ClientConfiguration
|
|
20
21
|
from testit_python_commons.client.converter import Converter
|
|
22
|
+
from testit_python_commons.client.helpers.bulk_autotest_helper import BulkAutotestHelper
|
|
21
23
|
from testit_python_commons.models.test_result import TestResult
|
|
22
24
|
from testit_python_commons.services.logger import adapter_logger
|
|
23
25
|
from testit_python_commons.services.retry import retry
|
|
24
|
-
from
|
|
26
|
+
from typing import List
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
class ApiClientWorker:
|
|
28
|
-
|
|
30
|
+
__tests_limit = 100
|
|
29
31
|
|
|
30
32
|
def __init__(self, config: ClientConfiguration):
|
|
31
33
|
api_client_config = self.__get_api_client_configuration(
|
|
32
34
|
url=config.get_url(),
|
|
33
|
-
verify_ssl=config.get_cert_validation()
|
|
35
|
+
verify_ssl=config.get_cert_validation(),
|
|
34
36
|
proxy=config.get_proxy())
|
|
35
37
|
api_client = self.__get_api_client(api_client_config, config.get_private_token())
|
|
36
38
|
|
|
@@ -58,168 +60,149 @@ class ApiClientWorker:
|
|
|
58
60
|
header_name='Authorization',
|
|
59
61
|
header_value='PrivateToken ' + token)
|
|
60
62
|
|
|
61
|
-
@staticmethod
|
|
62
|
-
def _escape_html_in_model(model):
|
|
63
|
-
"""Apply HTML escaping to all models before sending to API"""
|
|
64
|
-
return HtmlEscapeUtils.escape_html_in_object(model)
|
|
65
|
-
|
|
66
63
|
@adapter_logger
|
|
67
|
-
def create_test_run(self):
|
|
64
|
+
def create_test_run(self, test_run_name: str = None) -> str:
|
|
68
65
|
test_run_name = f'TestRun_{datetime.today().strftime("%Y-%m-%dT%H:%M:%S")}' if \
|
|
69
|
-
not
|
|
66
|
+
not test_run_name else test_run_name
|
|
70
67
|
model = Converter.test_run_to_test_run_short_model(
|
|
71
68
|
self.__config.get_project_id(),
|
|
72
69
|
test_run_name
|
|
73
70
|
)
|
|
74
|
-
model = self._escape_html_in_model(model)
|
|
75
71
|
|
|
76
72
|
response = self.__test_run_api.create_empty(create_empty_request=model)
|
|
77
73
|
|
|
78
74
|
return Converter.get_id_from_create_test_run_response(response)
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
def get_test_run(self, test_run_id: str) -> TestRunV2ApiResult:
|
|
77
|
+
"""Function gets test run and returns test run."""
|
|
78
|
+
logging.debug(f"Getting test run by id {test_run_id}")
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
test_run = self.__test_run_api.get_test_run_by_id(test_run_id)
|
|
81
|
+
if test_run is not None:
|
|
82
|
+
logging.debug(f"Got testrun: {test_run}")
|
|
83
|
+
return test_run
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
self.__config.get_configuration_id())
|
|
91
|
-
|
|
92
|
-
@adapter_logger
|
|
93
|
-
def write_test(self, test_result: TestResult):
|
|
94
|
-
model = Converter.project_id_and_external_id_to_auto_tests_search_post_request(
|
|
95
|
-
self.__config.get_project_id(),
|
|
96
|
-
test_result.get_external_id())
|
|
85
|
+
logging.error(f"Test run by id {test_run_id} not found!")
|
|
86
|
+
raise Exception(f"Test run by id {test_run_id} not found!")
|
|
97
87
|
|
|
98
|
-
|
|
88
|
+
def update_test_run(self, test_run: TestRunV2ApiResult) -> None:
|
|
89
|
+
"""Function updates test run."""
|
|
90
|
+
model = Converter.build_update_empty_request(test_run)
|
|
91
|
+
logging.debug(f"Updating test run with model: {model}")
|
|
99
92
|
|
|
100
|
-
|
|
101
|
-
self.__update_test(test_result, autotests[0])
|
|
102
|
-
else:
|
|
103
|
-
self.__create_test(test_result)
|
|
93
|
+
self.__test_run_api.update_empty(update_empty_request=model)
|
|
104
94
|
|
|
105
|
-
|
|
95
|
+
logging.debug(f'Updated testrun (ID: {test_run.id})')
|
|
106
96
|
|
|
107
97
|
@adapter_logger
|
|
108
|
-
def
|
|
109
|
-
|
|
110
|
-
autotests_for_update = []
|
|
111
|
-
results_for_autotests_being_created = []
|
|
112
|
-
results_for_autotests_being_updated = []
|
|
98
|
+
def set_test_run_id(self, test_run_id: str) -> None:
|
|
99
|
+
self.__config.set_test_run_id(test_run_id)
|
|
113
100
|
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
@adapter_logger
|
|
102
|
+
def get_external_ids_for_test_run_id(self) -> List[str]:
|
|
103
|
+
test_results: List[TestResultShortResponse] = self.__get_test_results()
|
|
104
|
+
external_ids: List[str] = Converter.get_external_ids_from_autotest_response_list(
|
|
105
|
+
test_results,
|
|
106
|
+
self.__config.get_configuration_id())
|
|
116
107
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
test_result.get_external_id())
|
|
108
|
+
if len(external_ids) > 0:
|
|
109
|
+
return external_ids
|
|
120
110
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
self.__config.get_configuration_id())
|
|
111
|
+
raise Exception('The autotests with the status "InProgress" ' +
|
|
112
|
+
f'and the configuration id "{self.__config.get_configuration_id()}" were not found!')
|
|
124
113
|
|
|
125
|
-
|
|
114
|
+
def __get_test_results(self) -> List[TestResultShortResponse]:
|
|
115
|
+
all_test_results = []
|
|
116
|
+
skip = 0
|
|
117
|
+
model: ApiV2TestResultsSearchPostRequest = (
|
|
118
|
+
Converter.build_test_results_search_post_request_with_in_progress_outcome(
|
|
119
|
+
self.__config.get_test_run_id(),
|
|
120
|
+
self.__config.get_configuration_id()))
|
|
126
121
|
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
while skip >= 0:
|
|
123
|
+
logging.debug(f"Getting test results with limit {self.__tests_limit}: {model}")
|
|
129
124
|
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
test_results: List[TestResultShortResponse] = self.__test_results_api.api_v2_test_results_search_post(
|
|
126
|
+
skip=skip,
|
|
127
|
+
take=self.__tests_limit,
|
|
128
|
+
api_v2_test_results_search_post_request=model)
|
|
132
129
|
|
|
133
|
-
|
|
134
|
-
self.__update_tests(autotests_for_update)
|
|
135
|
-
self.__load_test_results(results_for_autotests_being_updated)
|
|
130
|
+
logging.debug(f"Got {len(test_results)} test results: {test_results}")
|
|
136
131
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
else:
|
|
140
|
-
autotest_for_create = self.__prepare_to_mass_create_autotest(test_result)
|
|
132
|
+
all_test_results.extend(test_results)
|
|
133
|
+
skip += self.__tests_limit
|
|
141
134
|
|
|
142
|
-
|
|
143
|
-
|
|
135
|
+
if len(test_results) == 0:
|
|
136
|
+
skip = -1
|
|
144
137
|
|
|
145
|
-
|
|
146
|
-
self.__create_tests(autotests_for_create)
|
|
147
|
-
self.__load_test_results(results_for_autotests_being_created)
|
|
138
|
+
return all_test_results
|
|
148
139
|
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
@adapter_logger
|
|
141
|
+
def __get_autotests_by_external_id(self, external_id: str) -> List[AutoTestApiResult]:
|
|
142
|
+
model = Converter.project_id_and_external_id_to_auto_tests_search_post_request(
|
|
143
|
+
self.__config.get_project_id(),
|
|
144
|
+
external_id)
|
|
151
145
|
|
|
152
|
-
|
|
153
|
-
self.__update_tests(autotests_for_update)
|
|
154
|
-
self.__load_test_results(results_for_autotests_being_updated)
|
|
146
|
+
return self.__autotest_api.api_v2_auto_tests_search_post(api_v2_auto_tests_search_post_request=model)
|
|
155
147
|
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
@adapter_logger
|
|
149
|
+
def write_test(self, test_result: TestResult) -> str:
|
|
150
|
+
model = Converter.project_id_and_external_id_to_auto_tests_search_post_request(
|
|
151
|
+
self.__config.get_project_id(),
|
|
152
|
+
test_result.get_external_id())
|
|
158
153
|
|
|
159
|
-
|
|
160
|
-
self.__create_tests(autotests_for_create)
|
|
161
|
-
self.__load_test_results(results_for_autotests_being_created)
|
|
154
|
+
autotests = self.__autotest_api.api_v2_auto_tests_search_post(api_v2_auto_tests_search_post_request=model)
|
|
162
155
|
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
if autotests:
|
|
157
|
+
self.__update_test(test_result, autotests[0])
|
|
165
158
|
|
|
166
|
-
|
|
167
|
-
def __prepare_to_create_autotest(self, test_result: TestResult) -> AutoTestPostModel:
|
|
168
|
-
logging.debug('Preparing to create the auto test ' + test_result.get_external_id())
|
|
159
|
+
autotest_id = autotests[0].id
|
|
169
160
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
self.
|
|
173
|
-
model.work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
174
|
-
test_result.get_work_item_ids())
|
|
161
|
+
self.__update_autotest_link_from_work_items(autotest_id, test_result.get_work_item_ids())
|
|
162
|
+
else:
|
|
163
|
+
self.__create_test(test_result)
|
|
175
164
|
|
|
176
|
-
return
|
|
165
|
+
return self.__load_test_result(test_result)
|
|
177
166
|
|
|
178
167
|
@adapter_logger
|
|
179
|
-
def
|
|
180
|
-
|
|
168
|
+
def write_tests(self, test_results: List[TestResult], fixture_containers: dict) -> None:
|
|
169
|
+
bulk_autotest_helper = BulkAutotestHelper(self.__autotest_api, self.__test_run_api, self.__config)
|
|
181
170
|
|
|
182
|
-
|
|
183
|
-
test_result,
|
|
184
|
-
self.__config.get_project_id())
|
|
185
|
-
model.work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
186
|
-
test_result.get_work_item_ids())
|
|
187
|
-
|
|
188
|
-
return model
|
|
171
|
+
for test_result in test_results:
|
|
172
|
+
test_result = self.__add_fixtures_to_test_result(test_result, fixture_containers)
|
|
189
173
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
test_result: TestResult,
|
|
194
|
-
autotest: AutoTestApiResult) -> AutoTestPutModel:
|
|
195
|
-
logging.debug('Preparing to update the auto test ' + test_result.get_external_id())
|
|
174
|
+
test_result_model = Converter.test_result_to_testrun_result_post_model(
|
|
175
|
+
test_result,
|
|
176
|
+
self.__config.get_configuration_id())
|
|
196
177
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
self.__config.get_project_id())
|
|
200
|
-
model.is_flaky = autotest.is_flaky
|
|
201
|
-
model.work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
202
|
-
test_result.get_work_item_ids(),
|
|
203
|
-
str(autotest.global_id))
|
|
178
|
+
work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
179
|
+
test_result.get_work_item_ids())
|
|
204
180
|
|
|
205
|
-
|
|
181
|
+
autotests = self.__get_autotests_by_external_id(test_result.get_external_id())
|
|
206
182
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
183
|
+
if autotests:
|
|
184
|
+
autotest_links_to_wi_for_update = {}
|
|
185
|
+
autotest_for_update = Converter.prepare_to_mass_update_autotest(
|
|
186
|
+
test_result,
|
|
187
|
+
autotests[0],
|
|
188
|
+
self.__config.get_project_id())
|
|
189
|
+
|
|
190
|
+
autotest_id = autotests[0].id
|
|
191
|
+
autotest_links_to_wi_for_update[autotest_id] = test_result.get_work_item_ids()
|
|
192
|
+
|
|
193
|
+
bulk_autotest_helper.add_for_update(
|
|
194
|
+
autotest_for_update,
|
|
195
|
+
test_result_model,
|
|
196
|
+
autotest_links_to_wi_for_update)
|
|
197
|
+
else:
|
|
198
|
+
autotest_for_create = Converter.prepare_to_mass_create_autotest(
|
|
199
|
+
test_result,
|
|
200
|
+
self.__config.get_project_id(),
|
|
201
|
+
work_item_ids_for_link_with_auto_test)
|
|
213
202
|
|
|
214
|
-
|
|
215
|
-
test_result,
|
|
216
|
-
self.__config.get_project_id())
|
|
217
|
-
model.is_flaky = autotest.is_flaky
|
|
218
|
-
model.work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
219
|
-
test_result.get_work_item_ids(),
|
|
220
|
-
str(autotest.global_id))
|
|
203
|
+
bulk_autotest_helper.add_for_create(autotest_for_create, test_result_model)
|
|
221
204
|
|
|
222
|
-
|
|
205
|
+
bulk_autotest_helper.teardown()
|
|
223
206
|
|
|
224
207
|
@staticmethod
|
|
225
208
|
@adapter_logger
|
|
@@ -245,8 +228,8 @@ class ApiClientWorker:
|
|
|
245
228
|
@adapter_logger
|
|
246
229
|
def __get_work_item_uuids_for_link_with_auto_test(
|
|
247
230
|
self,
|
|
248
|
-
work_item_ids:
|
|
249
|
-
autotest_global_id: str = None) ->
|
|
231
|
+
work_item_ids: List[str],
|
|
232
|
+
autotest_global_id: str = None) -> List[str]:
|
|
250
233
|
linked_work_items = []
|
|
251
234
|
|
|
252
235
|
if autotest_global_id:
|
|
@@ -259,8 +242,8 @@ class ApiClientWorker:
|
|
|
259
242
|
@adapter_logger
|
|
260
243
|
def __prepare_list_of_work_item_uuids(
|
|
261
244
|
self,
|
|
262
|
-
linked_work_items:
|
|
263
|
-
work_item_ids:
|
|
245
|
+
linked_work_items: List[WorkItemIdentifierModel],
|
|
246
|
+
work_item_ids: List[str]) -> List[str]:
|
|
264
247
|
work_item_uuids = []
|
|
265
248
|
|
|
266
249
|
for linked_work_item in linked_work_items:
|
|
@@ -273,7 +256,7 @@ class ApiClientWorker:
|
|
|
273
256
|
|
|
274
257
|
continue
|
|
275
258
|
|
|
276
|
-
if self.__config.get_automatic_updation_links_to_test_cases()
|
|
259
|
+
if not self.__config.get_automatic_updation_links_to_test_cases():
|
|
277
260
|
work_item_uuids.append(linked_work_item_uuid)
|
|
278
261
|
|
|
279
262
|
for work_item_id in work_item_ids:
|
|
@@ -298,7 +281,7 @@ class ApiClientWorker:
|
|
|
298
281
|
logging.error(f'Getting workitem by id {work_item_id} status: {exc}')
|
|
299
282
|
|
|
300
283
|
@adapter_logger
|
|
301
|
-
def __get_work_items_linked_to_autotest(self, autotest_global_id: str) ->
|
|
284
|
+
def __get_work_items_linked_to_autotest(self, autotest_global_id: str) -> List[WorkItemIdentifierModel]:
|
|
302
285
|
return self.__autotest_api.get_work_items_linked_to_auto_test(id=autotest_global_id)
|
|
303
286
|
|
|
304
287
|
@adapter_logger
|
|
@@ -313,7 +296,7 @@ class ApiClientWorker:
|
|
|
313
296
|
|
|
314
297
|
continue
|
|
315
298
|
|
|
316
|
-
if self.__config.get_automatic_updation_links_to_test_cases()
|
|
299
|
+
if self.__config.get_automatic_updation_links_to_test_cases():
|
|
317
300
|
self.__unlink_test_to_work_item(autotest_global_id, linked_work_item_id)
|
|
318
301
|
|
|
319
302
|
for work_item_id in work_item_ids:
|
|
@@ -323,8 +306,13 @@ class ApiClientWorker:
|
|
|
323
306
|
def __create_test(self, test_result: TestResult) -> str:
|
|
324
307
|
logging.debug(f'Autotest "{test_result.get_autotest_name()}" was not found')
|
|
325
308
|
|
|
326
|
-
|
|
327
|
-
|
|
309
|
+
work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
310
|
+
test_result.get_work_item_ids())
|
|
311
|
+
|
|
312
|
+
model = Converter.prepare_to_create_autotest(
|
|
313
|
+
test_result,
|
|
314
|
+
self.__config.get_project_id(),
|
|
315
|
+
work_item_ids_for_link_with_auto_test)
|
|
328
316
|
|
|
329
317
|
autotest_response = self.__autotest_api.create_auto_test(create_auto_test_request=model)
|
|
330
318
|
|
|
@@ -333,20 +321,18 @@ class ApiClientWorker:
|
|
|
333
321
|
return autotest_response.id
|
|
334
322
|
|
|
335
323
|
@adapter_logger
|
|
336
|
-
def __create_tests(self, autotests_for_create:
|
|
324
|
+
def __create_tests(self, autotests_for_create: List[AutoTestPostModel]) -> None:
|
|
337
325
|
logging.debug(f'Creating autotests: "{autotests_for_create}')
|
|
338
326
|
|
|
339
|
-
autotests_for_create = self._escape_html_in_model(autotests_for_create)
|
|
340
327
|
self.__autotest_api.create_multiple(auto_test_post_model=autotests_for_create)
|
|
341
328
|
|
|
342
329
|
logging.debug(f'Autotests were created')
|
|
343
330
|
|
|
344
331
|
@adapter_logger
|
|
345
|
-
def __update_test(self, test_result: TestResult, autotest: AutoTestApiResult):
|
|
332
|
+
def __update_test(self, test_result: TestResult, autotest: AutoTestApiResult) -> None:
|
|
346
333
|
logging.debug(f'Autotest "{test_result.get_autotest_name()}" was found')
|
|
347
334
|
|
|
348
|
-
model =
|
|
349
|
-
model = self._escape_html_in_model(model)
|
|
335
|
+
model = Converter.prepare_to_update_autotest(test_result, autotest, self.__config.get_project_id())
|
|
350
336
|
|
|
351
337
|
try:
|
|
352
338
|
self.__autotest_api.update_auto_test(update_auto_test_request=model)
|
|
@@ -356,17 +342,16 @@ class ApiClientWorker:
|
|
|
356
342
|
logging.debug(f'Autotest "{test_result.get_autotest_name()}" was updated')
|
|
357
343
|
|
|
358
344
|
@adapter_logger
|
|
359
|
-
def __update_tests(self, autotests_for_update:
|
|
345
|
+
def __update_tests(self, autotests_for_update: List[AutoTestPutModel]) -> None:
|
|
360
346
|
logging.debug(f'Updating autotests: {autotests_for_update}')
|
|
361
347
|
|
|
362
|
-
autotests_for_update = self._escape_html_in_model(autotests_for_update)
|
|
363
348
|
self.__autotest_api.update_multiple(auto_test_put_model=autotests_for_update)
|
|
364
349
|
|
|
365
350
|
logging.debug(f'Autotests were updated')
|
|
366
351
|
|
|
367
352
|
@adapter_logger
|
|
368
353
|
@retry
|
|
369
|
-
def __unlink_test_to_work_item(self, autotest_global_id: str, work_item_id: str):
|
|
354
|
+
def __unlink_test_to_work_item(self, autotest_global_id: str, work_item_id: str) -> None:
|
|
370
355
|
self.__autotest_api.delete_auto_test_link_from_work_item(
|
|
371
356
|
id=autotest_global_id,
|
|
372
357
|
work_item_id=work_item_id)
|
|
@@ -375,10 +360,10 @@ class ApiClientWorker:
|
|
|
375
360
|
|
|
376
361
|
@adapter_logger
|
|
377
362
|
@retry
|
|
378
|
-
def __link_test_to_work_item(self, autotest_global_id: str, work_item_id: str):
|
|
363
|
+
def __link_test_to_work_item(self, autotest_global_id: str, work_item_id: str) -> None:
|
|
379
364
|
self.__autotest_api.link_auto_test_to_work_item(
|
|
380
365
|
autotest_global_id,
|
|
381
|
-
|
|
366
|
+
link_auto_test_to_work_item_request=LinkAutoTestToWorkItemRequest(id=work_item_id))
|
|
382
367
|
|
|
383
368
|
logging.debug(f'Autotest was linked with workItem "{work_item_id}" by global id "{autotest_global_id}')
|
|
384
369
|
|
|
@@ -387,7 +372,6 @@ class ApiClientWorker:
|
|
|
387
372
|
model = Converter.test_result_to_testrun_result_post_model(
|
|
388
373
|
test_result,
|
|
389
374
|
self.__config.get_configuration_id())
|
|
390
|
-
model = self._escape_html_in_model(model)
|
|
391
375
|
|
|
392
376
|
response = self.__test_run_api.set_auto_test_results_for_test_run(
|
|
393
377
|
id=self.__config.get_test_run_id(),
|
|
@@ -398,21 +382,12 @@ class ApiClientWorker:
|
|
|
398
382
|
|
|
399
383
|
return Converter.get_test_result_id_from_testrun_result_post_response(response)
|
|
400
384
|
|
|
401
|
-
@adapter_logger
|
|
402
|
-
def __load_test_results(self, test_results: typing.List[AutoTestResultsForTestRunModel]):
|
|
403
|
-
logging.debug(f'Loading test results: {test_results}')
|
|
404
|
-
|
|
405
|
-
test_results = self._escape_html_in_model(test_results)
|
|
406
|
-
self.__test_run_api.set_auto_test_results_for_test_run(
|
|
407
|
-
id=self.__config.get_test_run_id(),
|
|
408
|
-
auto_test_results_for_test_run_model=test_results)
|
|
409
|
-
|
|
410
385
|
@adapter_logger
|
|
411
386
|
def get_test_result_by_id(self, test_result_id: str) -> TestResultResponse:
|
|
412
387
|
return self.__test_results_api.api_v2_test_results_id_get(id=test_result_id)
|
|
413
388
|
|
|
414
389
|
@adapter_logger
|
|
415
|
-
def update_test_results(self, fixtures_containers: dict, test_result_ids: dict):
|
|
390
|
+
def update_test_results(self, fixtures_containers: dict, test_result_ids: dict) -> None:
|
|
416
391
|
test_results = Converter.fixtures_containers_to_test_results_with_all_fixture_step_results(
|
|
417
392
|
fixtures_containers, test_result_ids)
|
|
418
393
|
|
|
@@ -424,8 +399,6 @@ class ApiClientWorker:
|
|
|
424
399
|
test_result.get_setup_results())
|
|
425
400
|
model.teardown_results = Converter.step_results_to_auto_test_step_result_update_request(
|
|
426
401
|
test_result.get_teardown_results())
|
|
427
|
-
|
|
428
|
-
model = self._escape_html_in_model(model)
|
|
429
402
|
|
|
430
403
|
try:
|
|
431
404
|
self.__test_results_api.api_v2_test_results_id_put(
|
|
@@ -435,7 +408,7 @@ class ApiClientWorker:
|
|
|
435
408
|
logging.error(f'Cannot update test result with id "{test_result.get_test_result_id()}" status: {exc}')
|
|
436
409
|
|
|
437
410
|
@adapter_logger
|
|
438
|
-
def load_attachments(self, attach_paths: list or tuple):
|
|
411
|
+
def load_attachments(self, attach_paths: list or tuple) -> List[AttachmentPutModel]:
|
|
439
412
|
attachments = []
|
|
440
413
|
|
|
441
414
|
for path in attach_paths:
|
|
@@ -16,11 +16,11 @@ class ClientConfiguration:
|
|
|
16
16
|
self.__url = Utils.url_check(app_properties.get('url'))
|
|
17
17
|
self.__private_token = app_properties.get('privatetoken')
|
|
18
18
|
self.__configuration_id = Utils.uuid_check(app_properties.get('configurationid'))
|
|
19
|
-
self.__test_run_name = app_properties.get('testrunname')
|
|
20
19
|
self.__tms_proxy = app_properties.get('tmsproxy')
|
|
21
20
|
self.__adapter_mode = app_properties.get('adaptermode')
|
|
22
|
-
self.__cert_validation = app_properties.get('certvalidation')
|
|
23
|
-
self.__automatic_updation_links_to_test_cases =
|
|
21
|
+
self.__cert_validation = Utils.convert_value_str_to_bool(app_properties.get('certvalidation').lower())
|
|
22
|
+
self.__automatic_updation_links_to_test_cases = Utils.convert_value_str_to_bool(
|
|
23
|
+
app_properties.get('automaticupdationlinkstotestcases').lower())
|
|
24
24
|
|
|
25
25
|
@adapter_logger
|
|
26
26
|
def get_url(self):
|
|
@@ -50,10 +50,6 @@ class ClientConfiguration:
|
|
|
50
50
|
def set_test_run_id(self, test_run_id: str):
|
|
51
51
|
self.__test_run_id = test_run_id
|
|
52
52
|
|
|
53
|
-
@adapter_logger
|
|
54
|
-
def get_test_run_name(self):
|
|
55
|
-
return self.__test_run_name
|
|
56
|
-
|
|
57
53
|
@adapter_logger
|
|
58
54
|
def get_proxy(self):
|
|
59
55
|
return self.__tms_proxy
|
|
@@ -62,8 +58,8 @@ class ClientConfiguration:
|
|
|
62
58
|
def get_mode(self):
|
|
63
59
|
return self.__adapter_mode
|
|
64
60
|
|
|
65
|
-
def get_cert_validation(self):
|
|
61
|
+
def get_cert_validation(self) -> bool:
|
|
66
62
|
return self.__cert_validation
|
|
67
63
|
|
|
68
|
-
def get_automatic_updation_links_to_test_cases(self):
|
|
64
|
+
def get_automatic_updation_links_to_test_cases(self) -> bool:
|
|
69
65
|
return self.__automatic_updation_links_to_test_cases
|