testit-python-commons 3.7.2.post540__tar.gz → 3.9.0__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.post540 → testit_python_commons-3.9.0}/PKG-INFO +2 -2
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/setup.py +2 -2
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/client/api_client.py +47 -105
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/client/converter.py +74 -0
- testit_python_commons-3.9.0/src/testit_python_commons/client/helpers/__init__.py +0 -0
- testit_python_commons-3.9.0/src/testit_python_commons/client/helpers/bulk_autotest_helper.py +158 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons.egg-info/PKG-INFO +2 -2
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons.egg-info/SOURCES.txt +2 -0
- testit_python_commons-3.9.0/src/testit_python_commons.egg-info/requires.txt +3 -0
- testit_python_commons-3.7.2.post540/src/testit_python_commons.egg-info/requires.txt +0 -3
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/README.md +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/setup.cfg +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/__init__.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/app_properties.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/client/__init__.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/client/client_configuration.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/decorators.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/dynamic_methods.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/__init__.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/adapter_mode.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/fixture.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/link.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/link_type.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/outcome_type.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/step_result.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/test_result.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/models/test_result_with_all_fixture_step_results_model.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/__init__.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/adapter_manager.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/adapter_manager_configuration.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/fixture_manager.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/fixture_storage.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/logger.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/plugin_manager.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/retry.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/step_manager.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/step_result_storage.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/services/utils.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/step.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/utils/__init__.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons/utils/html_escape_utils.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons.egg-info/dependency_links.txt +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/src/testit_python_commons.egg-info/top_level.txt +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/tests/test_app_properties.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/tests/test_dynamic_methods.py +0 -0
- {testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/tests/test_html_escape_utils.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.9.0
|
|
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.
|
|
20
|
+
Requires-Dist: testit-api-client==7.1.0
|
|
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.9.0"
|
|
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.
|
|
28
|
+
install_requires=['pluggy', 'tomli', 'testit-api-client==7.1.0']
|
|
29
29
|
)
|
|
@@ -12,12 +12,13 @@ from testit_api_client.models import (
|
|
|
12
12
|
AttachmentPutModel,
|
|
13
13
|
AutoTestResultsForTestRunModel,
|
|
14
14
|
TestResultResponse,
|
|
15
|
-
|
|
15
|
+
LinkAutoTestToWorkItemRequest,
|
|
16
16
|
WorkItemIdentifierModel
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
from testit_python_commons.client.client_configuration import ClientConfiguration
|
|
20
20
|
from testit_python_commons.client.converter import Converter
|
|
21
|
+
from testit_python_commons.client.helpers.bulk_autotest_helper import BulkAutotestHelper
|
|
21
22
|
from testit_python_commons.models.test_result import TestResult
|
|
22
23
|
from testit_python_commons.services.logger import adapter_logger
|
|
23
24
|
from testit_python_commons.services.retry import retry
|
|
@@ -89,6 +90,14 @@ class ApiClientWorker:
|
|
|
89
90
|
response,
|
|
90
91
|
self.__config.get_configuration_id())
|
|
91
92
|
|
|
93
|
+
@adapter_logger
|
|
94
|
+
def __get_autotests_by_external_id(self, external_id: str) -> list:
|
|
95
|
+
model = Converter.project_id_and_external_id_to_auto_tests_search_post_request(
|
|
96
|
+
self.__config.get_project_id(),
|
|
97
|
+
external_id)
|
|
98
|
+
|
|
99
|
+
return self.__autotest_api.api_v2_auto_tests_search_post(api_v2_auto_tests_search_post_request=model)
|
|
100
|
+
|
|
92
101
|
@adapter_logger
|
|
93
102
|
def write_test(self, test_result: TestResult):
|
|
94
103
|
model = Converter.project_id_and_external_id_to_auto_tests_search_post_request(
|
|
@@ -99,6 +108,10 @@ class ApiClientWorker:
|
|
|
99
108
|
|
|
100
109
|
if autotests:
|
|
101
110
|
self.__update_test(test_result, autotests[0])
|
|
111
|
+
|
|
112
|
+
autotest_id = autotests[0].id
|
|
113
|
+
|
|
114
|
+
self.__update_autotest_link_from_work_items(autotest_id, test_result.get_work_item_ids())
|
|
102
115
|
else:
|
|
103
116
|
self.__create_test(test_result)
|
|
104
117
|
|
|
@@ -106,120 +119,43 @@ class ApiClientWorker:
|
|
|
106
119
|
|
|
107
120
|
@adapter_logger
|
|
108
121
|
def write_tests(self, test_results: typing.List[TestResult], fixture_containers: dict):
|
|
109
|
-
|
|
110
|
-
autotests_for_update = []
|
|
111
|
-
results_for_autotests_being_created = []
|
|
112
|
-
results_for_autotests_being_updated = []
|
|
122
|
+
bulk_autotest_helper = BulkAutotestHelper(self.__autotest_api, self.__test_run_api, self.__config)
|
|
113
123
|
|
|
114
124
|
for test_result in test_results:
|
|
115
125
|
test_result = self.__add_fixtures_to_test_result(test_result, fixture_containers)
|
|
116
126
|
|
|
117
|
-
model = Converter.project_id_and_external_id_to_auto_tests_search_post_request(
|
|
118
|
-
self.__config.get_project_id(),
|
|
119
|
-
test_result.get_external_id())
|
|
120
|
-
|
|
121
127
|
test_result_model = Converter.test_result_to_testrun_result_post_model(
|
|
122
128
|
test_result,
|
|
123
129
|
self.__config.get_configuration_id())
|
|
124
130
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if autotests:
|
|
128
|
-
autotest_for_update = self.__prepare_to_mass_update_autotest(test_result, autotests[0])
|
|
129
|
-
|
|
130
|
-
autotests_for_update.append(autotest_for_update)
|
|
131
|
-
results_for_autotests_being_updated.append(test_result_model)
|
|
131
|
+
work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
132
|
+
test_result.get_work_item_ids())
|
|
132
133
|
|
|
133
|
-
|
|
134
|
-
self.__update_tests(autotests_for_update)
|
|
135
|
-
self.__load_test_results(results_for_autotests_being_updated)
|
|
134
|
+
autotests = self.__get_autotests_by_external_id(test_result.get_external_id())
|
|
136
135
|
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
if autotests:
|
|
137
|
+
autotest_links_to_wi_for_update = {}
|
|
138
|
+
autotest_for_update = Converter.prepare_to_mass_update_autotest(
|
|
139
|
+
test_result,
|
|
140
|
+
autotests[0],
|
|
141
|
+
self.__config.get_project_id())
|
|
142
|
+
|
|
143
|
+
autotest_id = autotests[0].id
|
|
144
|
+
autotest_links_to_wi_for_update[autotest_id] = test_result.get_work_item_ids()
|
|
145
|
+
|
|
146
|
+
bulk_autotest_helper.add_for_update(
|
|
147
|
+
autotest_for_update,
|
|
148
|
+
test_result_model,
|
|
149
|
+
autotest_links_to_wi_for_update)
|
|
139
150
|
else:
|
|
140
|
-
autotest_for_create =
|
|
151
|
+
autotest_for_create = Converter.prepare_to_mass_create_autotest(
|
|
152
|
+
test_result,
|
|
153
|
+
self.__config.get_project_id(),
|
|
154
|
+
work_item_ids_for_link_with_auto_test)
|
|
141
155
|
|
|
142
|
-
|
|
143
|
-
results_for_autotests_being_created.append(test_result_model)
|
|
156
|
+
bulk_autotest_helper.add_for_create(autotest_for_create, test_result_model)
|
|
144
157
|
|
|
145
|
-
|
|
146
|
-
self.__create_tests(autotests_for_create)
|
|
147
|
-
self.__load_test_results(results_for_autotests_being_created)
|
|
148
|
-
|
|
149
|
-
autotests_for_create.clear()
|
|
150
|
-
results_for_autotests_being_created.clear()
|
|
151
|
-
|
|
152
|
-
if len(autotests_for_update) > 0:
|
|
153
|
-
self.__update_tests(autotests_for_update)
|
|
154
|
-
self.__load_test_results(results_for_autotests_being_updated)
|
|
155
|
-
|
|
156
|
-
autotests_for_update.clear()
|
|
157
|
-
results_for_autotests_being_updated.clear()
|
|
158
|
-
|
|
159
|
-
if len(autotests_for_create) > 0:
|
|
160
|
-
self.__create_tests(autotests_for_create)
|
|
161
|
-
self.__load_test_results(results_for_autotests_being_created)
|
|
162
|
-
|
|
163
|
-
autotests_for_create.clear()
|
|
164
|
-
results_for_autotests_being_created.clear()
|
|
165
|
-
|
|
166
|
-
@adapter_logger
|
|
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())
|
|
169
|
-
|
|
170
|
-
model = Converter.test_result_to_create_autotest_request(
|
|
171
|
-
test_result,
|
|
172
|
-
self.__config.get_project_id())
|
|
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())
|
|
175
|
-
|
|
176
|
-
return model
|
|
177
|
-
|
|
178
|
-
@adapter_logger
|
|
179
|
-
def __prepare_to_mass_create_autotest(self, test_result: TestResult) -> AutoTestPostModel:
|
|
180
|
-
logging.debug('Preparing to create the auto test ' + test_result.get_external_id())
|
|
181
|
-
|
|
182
|
-
model = Converter.test_result_to_autotest_post_model(
|
|
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
|
|
189
|
-
|
|
190
|
-
@adapter_logger
|
|
191
|
-
def __prepare_to_update_autotest(
|
|
192
|
-
self,
|
|
193
|
-
test_result: TestResult,
|
|
194
|
-
autotest: AutoTestApiResult) -> AutoTestPutModel:
|
|
195
|
-
logging.debug('Preparing to update the auto test ' + test_result.get_external_id())
|
|
196
|
-
|
|
197
|
-
model = Converter.test_result_to_update_autotest_request(
|
|
198
|
-
test_result,
|
|
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))
|
|
204
|
-
|
|
205
|
-
return model
|
|
206
|
-
|
|
207
|
-
@adapter_logger
|
|
208
|
-
def __prepare_to_mass_update_autotest(
|
|
209
|
-
self,
|
|
210
|
-
test_result: TestResult,
|
|
211
|
-
autotest: AutoTestApiResult) -> AutoTestPutModel:
|
|
212
|
-
logging.debug('Preparing to update the auto test ' + test_result.get_external_id())
|
|
213
|
-
|
|
214
|
-
model = Converter.test_result_to_autotest_put_model(
|
|
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))
|
|
221
|
-
|
|
222
|
-
return model
|
|
158
|
+
bulk_autotest_helper.teardown()
|
|
223
159
|
|
|
224
160
|
@staticmethod
|
|
225
161
|
@adapter_logger
|
|
@@ -323,7 +259,13 @@ class ApiClientWorker:
|
|
|
323
259
|
def __create_test(self, test_result: TestResult) -> str:
|
|
324
260
|
logging.debug(f'Autotest "{test_result.get_autotest_name()}" was not found')
|
|
325
261
|
|
|
326
|
-
|
|
262
|
+
work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
263
|
+
test_result.get_work_item_ids())
|
|
264
|
+
|
|
265
|
+
model = Converter.prepare_to_create_autotest(
|
|
266
|
+
test_result,
|
|
267
|
+
self.__config.get_project_id(),
|
|
268
|
+
work_item_ids_for_link_with_auto_test)
|
|
327
269
|
model = self._escape_html_in_model(model)
|
|
328
270
|
|
|
329
271
|
autotest_response = self.__autotest_api.create_auto_test(create_auto_test_request=model)
|
|
@@ -345,7 +287,7 @@ class ApiClientWorker:
|
|
|
345
287
|
def __update_test(self, test_result: TestResult, autotest: AutoTestApiResult):
|
|
346
288
|
logging.debug(f'Autotest "{test_result.get_autotest_name()}" was found')
|
|
347
289
|
|
|
348
|
-
model =
|
|
290
|
+
model = Converter.prepare_to_update_autotest(test_result, autotest, self.__config.get_project_id())
|
|
349
291
|
model = self._escape_html_in_model(model)
|
|
350
292
|
|
|
351
293
|
try:
|
|
@@ -378,7 +320,7 @@ class ApiClientWorker:
|
|
|
378
320
|
def __link_test_to_work_item(self, autotest_global_id: str, work_item_id: str):
|
|
379
321
|
self.__autotest_api.link_auto_test_to_work_item(
|
|
380
322
|
autotest_global_id,
|
|
381
|
-
|
|
323
|
+
link_auto_test_to_work_item_request=LinkAutoTestToWorkItemRequest(id=work_item_id))
|
|
382
324
|
|
|
383
325
|
logging.debug(f'Autotest was linked with workItem "{work_item_id}" by global id "{autotest_global_id}')
|
|
384
326
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import typing
|
|
2
3
|
|
|
3
4
|
from testit_api_client.models import (
|
|
5
|
+
AutoTestApiResult,
|
|
4
6
|
AttachmentPutModelAutoTestStepResultsModel,
|
|
5
7
|
AutoTestStepResultUpdateRequest,
|
|
6
8
|
CreateAutoTestRequest,
|
|
@@ -450,3 +452,75 @@ class Converter:
|
|
|
450
452
|
)
|
|
451
453
|
|
|
452
454
|
return autotest_model_step_results
|
|
455
|
+
|
|
456
|
+
@classmethod
|
|
457
|
+
@adapter_logger
|
|
458
|
+
def prepare_to_create_autotest(
|
|
459
|
+
cls,
|
|
460
|
+
test_result: TestResult,
|
|
461
|
+
project_id: str,
|
|
462
|
+
work_item_ids_for_link_with_auto_test: list) -> AutoTestPostModel:
|
|
463
|
+
logging.debug('Preparing to create the auto test ' + test_result.get_external_id())
|
|
464
|
+
|
|
465
|
+
model = cls.test_result_to_create_autotest_request(
|
|
466
|
+
test_result,
|
|
467
|
+
project_id)
|
|
468
|
+
model.work_item_ids_for_link_with_auto_test = work_item_ids_for_link_with_auto_test
|
|
469
|
+
|
|
470
|
+
return model
|
|
471
|
+
|
|
472
|
+
@classmethod
|
|
473
|
+
@adapter_logger
|
|
474
|
+
def prepare_to_mass_create_autotest(
|
|
475
|
+
cls,
|
|
476
|
+
test_result: TestResult,
|
|
477
|
+
project_id: str,
|
|
478
|
+
work_item_ids_for_link_with_auto_test: list) -> AutoTestPostModel:
|
|
479
|
+
logging.debug('Preparing to create the auto test ' + test_result.get_external_id())
|
|
480
|
+
|
|
481
|
+
model = cls.test_result_to_autotest_post_model(
|
|
482
|
+
test_result,
|
|
483
|
+
project_id)
|
|
484
|
+
model.work_item_ids_for_link_with_auto_test = work_item_ids_for_link_with_auto_test
|
|
485
|
+
|
|
486
|
+
return model
|
|
487
|
+
|
|
488
|
+
@classmethod
|
|
489
|
+
@adapter_logger
|
|
490
|
+
def prepare_to_update_autotest(
|
|
491
|
+
cls,
|
|
492
|
+
test_result: TestResult,
|
|
493
|
+
autotest: AutoTestApiResult,
|
|
494
|
+
project_id: str) -> UpdateAutoTestRequest:
|
|
495
|
+
logging.debug('Preparing to update the auto test ' + test_result.get_external_id())
|
|
496
|
+
|
|
497
|
+
model = cls.test_result_to_update_autotest_request(
|
|
498
|
+
test_result,
|
|
499
|
+
project_id)
|
|
500
|
+
model.is_flaky = autotest.is_flaky
|
|
501
|
+
# TODO: return after fix PUT/api/v2/autoTests
|
|
502
|
+
# model.work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
503
|
+
# test_result.get_work_item_ids(),
|
|
504
|
+
# str(autotest.global_id))
|
|
505
|
+
|
|
506
|
+
return model
|
|
507
|
+
|
|
508
|
+
@classmethod
|
|
509
|
+
@adapter_logger
|
|
510
|
+
def prepare_to_mass_update_autotest(
|
|
511
|
+
cls,
|
|
512
|
+
test_result: TestResult,
|
|
513
|
+
autotest: AutoTestApiResult,
|
|
514
|
+
project_id: str) -> AutoTestPutModel:
|
|
515
|
+
logging.debug('Preparing to update the auto test ' + test_result.get_external_id())
|
|
516
|
+
|
|
517
|
+
model = cls.test_result_to_autotest_put_model(
|
|
518
|
+
test_result,
|
|
519
|
+
project_id)
|
|
520
|
+
model.is_flaky = autotest.is_flaky
|
|
521
|
+
# TODO: return after fix PUT/api/v2/autoTests
|
|
522
|
+
# model.work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
523
|
+
# test_result.get_work_item_ids(),
|
|
524
|
+
# str(autotest.global_id))
|
|
525
|
+
|
|
526
|
+
return model
|
|
File without changes
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from testit_api_client.apis import AutoTestsApi, TestRunsApi
|
|
5
|
+
from testit_api_client.models import (
|
|
6
|
+
AutoTestPostModel,
|
|
7
|
+
AutoTestPutModel,
|
|
8
|
+
AutoTestResultsForTestRunModel,
|
|
9
|
+
LinkAutoTestToWorkItemRequest,
|
|
10
|
+
WorkItemIdentifierModel,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from testit_python_commons.client.client_configuration import ClientConfiguration
|
|
14
|
+
from testit_python_commons.services.logger import adapter_logger
|
|
15
|
+
from testit_python_commons.services.retry import retry
|
|
16
|
+
from testit_python_commons.utils.html_escape_utils import HtmlEscapeUtils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BulkAutotestHelper:
|
|
20
|
+
__max_tests_for_import = 100
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
autotests_api: AutoTestsApi,
|
|
25
|
+
test_runs_api: TestRunsApi,
|
|
26
|
+
config: ClientConfiguration):
|
|
27
|
+
self.__autotests_api = autotests_api
|
|
28
|
+
self.__test_runs_api = test_runs_api
|
|
29
|
+
self.__test_run_id = config.get_test_run_id()
|
|
30
|
+
self.__automatic_updation_links_to_test_cases = config.get_automatic_updation_links_to_test_cases()
|
|
31
|
+
self.__autotests_for_create = []
|
|
32
|
+
self.__autotests_for_update = []
|
|
33
|
+
self.__autotest_links_to_wi_for_update = {}
|
|
34
|
+
self.__results_for_autotests_being_created = []
|
|
35
|
+
self.__results_for_autotests_being_updated = []
|
|
36
|
+
|
|
37
|
+
@adapter_logger
|
|
38
|
+
def add_for_create(
|
|
39
|
+
self,
|
|
40
|
+
create_model: AutoTestPostModel,
|
|
41
|
+
result_model: AutoTestResultsForTestRunModel):
|
|
42
|
+
self.__autotests_for_create.append(create_model)
|
|
43
|
+
self.__results_for_autotests_being_created.append(result_model)
|
|
44
|
+
|
|
45
|
+
if len(self.__autotests_for_create) >= self.__max_tests_for_import:
|
|
46
|
+
self.__bulk_create()
|
|
47
|
+
|
|
48
|
+
@adapter_logger
|
|
49
|
+
def add_for_update(
|
|
50
|
+
self,
|
|
51
|
+
update_model: AutoTestPutModel,
|
|
52
|
+
result_model: AutoTestResultsForTestRunModel,
|
|
53
|
+
autotest_links_to_wi_for_update: dict):
|
|
54
|
+
self.__autotests_for_update.append(update_model)
|
|
55
|
+
self.__results_for_autotests_being_updated.append(result_model)
|
|
56
|
+
self.__autotest_links_to_wi_for_update.update(autotest_links_to_wi_for_update)
|
|
57
|
+
|
|
58
|
+
if len(self.__autotests_for_create) >= self.__max_tests_for_import:
|
|
59
|
+
self.__bulk_update()
|
|
60
|
+
|
|
61
|
+
@adapter_logger
|
|
62
|
+
def teardown(self):
|
|
63
|
+
if len(self.__autotests_for_create) > 0:
|
|
64
|
+
self.__bulk_create()
|
|
65
|
+
|
|
66
|
+
if len(self.__autotests_for_update) > 0:
|
|
67
|
+
self.__bulk_update()
|
|
68
|
+
|
|
69
|
+
@adapter_logger
|
|
70
|
+
def __bulk_create(self):
|
|
71
|
+
self.__create_tests(self.__autotests_for_create)
|
|
72
|
+
self.__load_test_results(self.__results_for_autotests_being_created)
|
|
73
|
+
|
|
74
|
+
self.__autotests_for_create.clear()
|
|
75
|
+
self.__results_for_autotests_being_created.clear()
|
|
76
|
+
|
|
77
|
+
@adapter_logger
|
|
78
|
+
def __bulk_update(self):
|
|
79
|
+
self.__update_tests(self.__autotests_for_update)
|
|
80
|
+
self.__load_test_results(self.__results_for_autotests_being_updated)
|
|
81
|
+
|
|
82
|
+
for autotest_id, work_item_ids in self.__autotest_links_to_wi_for_update.items():
|
|
83
|
+
self.__update_autotest_link_from_work_items(autotest_id, work_item_ids)
|
|
84
|
+
|
|
85
|
+
self.__autotests_for_update.clear()
|
|
86
|
+
self.__results_for_autotests_being_updated.clear()
|
|
87
|
+
self.__autotest_links_to_wi_for_update.clear()
|
|
88
|
+
|
|
89
|
+
@adapter_logger
|
|
90
|
+
def __create_tests(self, autotests_for_create: typing.List[AutoTestPostModel]):
|
|
91
|
+
logging.debug(f'Creating autotests: "{autotests_for_create}')
|
|
92
|
+
|
|
93
|
+
autotests_for_create = HtmlEscapeUtils.escape_html_in_object(autotests_for_create)
|
|
94
|
+
self.__autotests_api.create_multiple(auto_test_post_model=autotests_for_create)
|
|
95
|
+
|
|
96
|
+
logging.debug(f'Autotests were created')
|
|
97
|
+
|
|
98
|
+
@adapter_logger
|
|
99
|
+
def __update_tests(self, autotests_for_update: typing.List[AutoTestPutModel]):
|
|
100
|
+
logging.debug(f'Updating autotests: {autotests_for_update}')
|
|
101
|
+
|
|
102
|
+
autotests_for_update = HtmlEscapeUtils.escape_html_in_object(autotests_for_update)
|
|
103
|
+
self.__autotests_api.update_multiple(auto_test_put_model=autotests_for_update)
|
|
104
|
+
|
|
105
|
+
logging.debug(f'Autotests were updated')
|
|
106
|
+
|
|
107
|
+
@adapter_logger
|
|
108
|
+
def __load_test_results(self, test_results: typing.List[AutoTestResultsForTestRunModel]):
|
|
109
|
+
logging.debug(f'Loading test results: {test_results}')
|
|
110
|
+
|
|
111
|
+
test_results = HtmlEscapeUtils.escape_html_in_object(test_results)
|
|
112
|
+
self.__test_runs_api.set_auto_test_results_for_test_run(
|
|
113
|
+
id=self.__test_run_id,
|
|
114
|
+
auto_test_results_for_test_run_model=test_results)
|
|
115
|
+
|
|
116
|
+
# TODO: delete after fix PUT/api/v2/autoTests
|
|
117
|
+
@adapter_logger
|
|
118
|
+
def __get_work_items_linked_to_autotest(self, autotest_global_id: str) -> typing.List[WorkItemIdentifierModel]:
|
|
119
|
+
return self.__autotests_api.get_work_items_linked_to_auto_test(id=autotest_global_id)
|
|
120
|
+
|
|
121
|
+
# TODO: delete after fix PUT/api/v2/autoTests
|
|
122
|
+
@adapter_logger
|
|
123
|
+
@retry
|
|
124
|
+
def __unlink_test_to_work_item(self, autotest_global_id: str, work_item_id: str):
|
|
125
|
+
self.__autotests_api.delete_auto_test_link_from_work_item(
|
|
126
|
+
id=autotest_global_id,
|
|
127
|
+
work_item_id=work_item_id)
|
|
128
|
+
|
|
129
|
+
logging.debug(f'Autotest was unlinked with workItem "{work_item_id}" by global id "{autotest_global_id}')
|
|
130
|
+
|
|
131
|
+
# TODO: delete after fix PUT/api/v2/autoTests
|
|
132
|
+
@adapter_logger
|
|
133
|
+
@retry
|
|
134
|
+
def __link_test_to_work_item(self, autotest_global_id: str, work_item_id: str):
|
|
135
|
+
self.__autotests_api.link_auto_test_to_work_item(
|
|
136
|
+
autotest_global_id,
|
|
137
|
+
link_auto_test_to_work_item_request=LinkAutoTestToWorkItemRequest(id=work_item_id))
|
|
138
|
+
|
|
139
|
+
logging.debug(f'Autotest was linked with workItem "{work_item_id}" by global id "{autotest_global_id}')
|
|
140
|
+
|
|
141
|
+
# TODO: delete after fix PUT/api/v2/autoTests
|
|
142
|
+
@adapter_logger
|
|
143
|
+
def __update_autotest_link_from_work_items(self, autotest_global_id: str, work_item_ids: list):
|
|
144
|
+
linked_work_items = self.__get_work_items_linked_to_autotest(autotest_global_id)
|
|
145
|
+
|
|
146
|
+
for linked_work_item in linked_work_items:
|
|
147
|
+
linked_work_item_id = str(linked_work_item.global_id)
|
|
148
|
+
|
|
149
|
+
if linked_work_item_id in work_item_ids:
|
|
150
|
+
work_item_ids.remove(linked_work_item_id)
|
|
151
|
+
|
|
152
|
+
continue
|
|
153
|
+
|
|
154
|
+
if self.__automatic_updation_links_to_test_cases != 'false':
|
|
155
|
+
self.__unlink_test_to_work_item(autotest_global_id, linked_work_item_id)
|
|
156
|
+
|
|
157
|
+
for work_item_id in work_item_ids:
|
|
158
|
+
self.__link_test_to_work_item(autotest_global_id, work_item_id)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: testit-python-commons
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.9.0
|
|
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.
|
|
20
|
+
Requires-Dist: testit-api-client==7.1.0
|
|
21
21
|
Dynamic: author
|
|
22
22
|
Dynamic: author-email
|
|
23
23
|
Dynamic: classifier
|
|
@@ -15,6 +15,8 @@ src/testit_python_commons/client/__init__.py
|
|
|
15
15
|
src/testit_python_commons/client/api_client.py
|
|
16
16
|
src/testit_python_commons/client/client_configuration.py
|
|
17
17
|
src/testit_python_commons/client/converter.py
|
|
18
|
+
src/testit_python_commons/client/helpers/__init__.py
|
|
19
|
+
src/testit_python_commons/client/helpers/bulk_autotest_helper.py
|
|
18
20
|
src/testit_python_commons/models/__init__.py
|
|
19
21
|
src/testit_python_commons/models/adapter_mode.py
|
|
20
22
|
src/testit_python_commons/models/fixture.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/tests/test_app_properties.py
RENAMED
|
File without changes
|
{testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/tests/test_dynamic_methods.py
RENAMED
|
File without changes
|
{testit_python_commons-3.7.2.post540 → testit_python_commons-3.9.0}/tests/test_html_escape_utils.py
RENAMED
|
File without changes
|