testit-python-commons 4.2.8__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.
- api_client_syncstorage/__init__.py +27 -0
- api_client_syncstorage/api/__init__.py +3 -0
- api_client_syncstorage/api/completion_api.py +302 -0
- api_client_syncstorage/api/health_api.py +158 -0
- api_client_syncstorage/api/system_api.py +158 -0
- api_client_syncstorage/api/test_results_api.py +182 -0
- api_client_syncstorage/api/workers_api.py +308 -0
- api_client_syncstorage/api_client.py +898 -0
- api_client_syncstorage/apis/__init__.py +21 -0
- api_client_syncstorage/configuration.py +450 -0
- api_client_syncstorage/exceptions.py +158 -0
- api_client_syncstorage/model/__init__.py +5 -0
- api_client_syncstorage/model/completion_response.py +267 -0
- api_client_syncstorage/model/health_status_response.py +267 -0
- api_client_syncstorage/model/register_request.py +275 -0
- api_client_syncstorage/model/register_response.py +279 -0
- api_client_syncstorage/model/set_worker_status_request.py +271 -0
- api_client_syncstorage/model/set_worker_status_response.py +267 -0
- api_client_syncstorage/model/shutdown_response.py +267 -0
- api_client_syncstorage/model/test_result_cut_api_model.py +279 -0
- api_client_syncstorage/model/test_result_save_response.py +267 -0
- api_client_syncstorage/model_utils.py +2058 -0
- api_client_syncstorage/models/__init__.py +20 -0
- api_client_syncstorage/rest.py +356 -0
- testit.py +69 -0
- testit_python_commons/__init__.py +0 -0
- testit_python_commons/app_properties.py +257 -0
- testit_python_commons/client/__init__.py +9 -0
- testit_python_commons/client/api_client.py +560 -0
- testit_python_commons/client/client_configuration.py +74 -0
- testit_python_commons/client/converter.py +618 -0
- testit_python_commons/client/helpers/__init__.py +0 -0
- testit_python_commons/client/helpers/bulk_autotest_helper.py +246 -0
- testit_python_commons/client/helpers/threads_manager.py +86 -0
- testit_python_commons/client/models/__init__.py +8 -0
- testit_python_commons/client/models/threads_for_create_and_result.py +35 -0
- testit_python_commons/client/models/threads_for_update_and_result.py +45 -0
- testit_python_commons/configurations/__init__.py +0 -0
- testit_python_commons/configurations/properties_names.py +51 -0
- testit_python_commons/decorators.py +221 -0
- testit_python_commons/dynamic_methods.py +237 -0
- testit_python_commons/models/__init__.py +5 -0
- testit_python_commons/models/adapter_mode.py +4 -0
- testit_python_commons/models/fixture.py +24 -0
- testit_python_commons/models/link.py +53 -0
- testit_python_commons/models/link_type.py +10 -0
- testit_python_commons/models/outcome_type.py +5 -0
- testit_python_commons/models/status_type.py +6 -0
- testit_python_commons/models/step_result.py +90 -0
- testit_python_commons/models/test_result.py +297 -0
- testit_python_commons/models/test_result_with_all_fixture_step_results_model.py +28 -0
- testit_python_commons/services/__init__.py +41 -0
- testit_python_commons/services/adapter_manager.py +318 -0
- testit_python_commons/services/adapter_manager_configuration.py +42 -0
- testit_python_commons/services/fixture_manager.py +60 -0
- testit_python_commons/services/fixture_storage.py +40 -0
- testit_python_commons/services/logger.py +32 -0
- testit_python_commons/services/plugin_manager.py +101 -0
- testit_python_commons/services/retry.py +92 -0
- testit_python_commons/services/step_manager.py +36 -0
- testit_python_commons/services/step_result_storage.py +26 -0
- testit_python_commons/services/sync_storage/__init__.py +9 -0
- testit_python_commons/services/sync_storage/sync_storage_runner.py +589 -0
- testit_python_commons/services/utils.py +132 -0
- testit_python_commons/step.py +101 -0
- testit_python_commons/utils/__init__.py +3 -0
- testit_python_commons/utils/html_escape_utils.py +219 -0
- testit_python_commons-4.2.8.dist-info/METADATA +52 -0
- testit_python_commons-4.2.8.dist-info/RECORD +71 -0
- testit_python_commons-4.2.8.dist-info/WHEEL +5 -0
- testit_python_commons-4.2.8.dist-info/top_level.txt +3 -0
|
@@ -0,0 +1,618 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
from testit_api_client.models import (
|
|
5
|
+
ApiV2TestResultsSearchPostRequest,
|
|
6
|
+
AutoTestApiResult,
|
|
7
|
+
AttachmentPutModelAutoTestStepResultsModel,
|
|
8
|
+
AutoTestStepResultUpdateRequest,
|
|
9
|
+
CreateAutoTestRequest,
|
|
10
|
+
UpdateAutoTestRequest,
|
|
11
|
+
AutoTestCreateApiModel,
|
|
12
|
+
AutoTestUpdateApiModel,
|
|
13
|
+
AutoTestResultsForTestRunModel,
|
|
14
|
+
AutoTestStepApiModel,
|
|
15
|
+
AvailableTestResultOutcome,
|
|
16
|
+
LinkPostModel,
|
|
17
|
+
LinkCreateApiModel,
|
|
18
|
+
LinkUpdateApiModel,
|
|
19
|
+
LinkType,
|
|
20
|
+
CreateEmptyRequest,
|
|
21
|
+
TestRunV2ApiResult,
|
|
22
|
+
TestResultShortResponse,
|
|
23
|
+
AutoTestSearchApiModelFilter,
|
|
24
|
+
AutoTestSearchApiModelIncludes,
|
|
25
|
+
ApiV2AutoTestsSearchPostRequest,
|
|
26
|
+
ApiV2TestResultsIdPutRequest,
|
|
27
|
+
TestResultResponse,
|
|
28
|
+
AttachmentApiResult,
|
|
29
|
+
AttachmentUpdateRequest,
|
|
30
|
+
AttachmentPutModel,
|
|
31
|
+
UpdateEmptyRequest,
|
|
32
|
+
LinkApiResult,
|
|
33
|
+
UpdateLinkApiModel,
|
|
34
|
+
AssignAttachmentApiModel,
|
|
35
|
+
TestStatusType,
|
|
36
|
+
TestStatusApiType,
|
|
37
|
+
CreateLinkApiModel,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
from testit_python_commons.models.link import Link
|
|
41
|
+
from testit_python_commons.models.step_result import StepResult
|
|
42
|
+
from testit_python_commons.models.test_result import TestResult
|
|
43
|
+
from testit_python_commons.models.test_result_with_all_fixture_step_results_model import TestResultWithAllFixtureStepResults
|
|
44
|
+
from testit_python_commons.services.logger import adapter_logger
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Converter:
|
|
48
|
+
@staticmethod
|
|
49
|
+
@adapter_logger
|
|
50
|
+
def test_run_to_test_run_short_model(project_id: str, name: str) -> CreateEmptyRequest:
|
|
51
|
+
return CreateEmptyRequest(
|
|
52
|
+
project_id=project_id,
|
|
53
|
+
name=name
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
@staticmethod
|
|
57
|
+
@adapter_logger
|
|
58
|
+
def get_id_from_create_test_run_response(response: TestRunV2ApiResult) -> str:
|
|
59
|
+
return response.id
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
@adapter_logger
|
|
63
|
+
def build_update_empty_request(cls, test_run: TestRunV2ApiResult) -> UpdateEmptyRequest:
|
|
64
|
+
return UpdateEmptyRequest(
|
|
65
|
+
id=test_run.id,
|
|
66
|
+
name=test_run.name,
|
|
67
|
+
description=test_run.description,
|
|
68
|
+
launch_source=test_run.launch_source,
|
|
69
|
+
attachments=list(map(cls.build_assign_attachment_api_model, test_run.attachments)),
|
|
70
|
+
links=list(map(cls.build_update_link_api_model, test_run.links))
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
@adapter_logger
|
|
75
|
+
def build_update_link_api_model(link: LinkApiResult) -> UpdateLinkApiModel:
|
|
76
|
+
return UpdateLinkApiModel(
|
|
77
|
+
id=link.id,
|
|
78
|
+
title=link.title,
|
|
79
|
+
description=link.description,
|
|
80
|
+
type=link.type,
|
|
81
|
+
url=link.url,
|
|
82
|
+
has_info=link.has_info
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
@staticmethod
|
|
86
|
+
@adapter_logger
|
|
87
|
+
def build_create_link_api_model(link: LinkApiResult) -> CreateLinkApiModel:
|
|
88
|
+
return CreateLinkApiModel(
|
|
89
|
+
title=link.title,
|
|
90
|
+
description=link.description,
|
|
91
|
+
type=link.type,
|
|
92
|
+
url=link.url,
|
|
93
|
+
has_info=link.has_info
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
@staticmethod
|
|
97
|
+
@adapter_logger
|
|
98
|
+
def build_assign_attachment_api_model(attachment: AttachmentApiResult) -> AssignAttachmentApiModel:
|
|
99
|
+
return AssignAttachmentApiModel(id=attachment.id)
|
|
100
|
+
|
|
101
|
+
@staticmethod
|
|
102
|
+
@adapter_logger
|
|
103
|
+
def project_id_and_external_id_to_auto_tests_search_post_request(
|
|
104
|
+
project_id: str,
|
|
105
|
+
external_id: str
|
|
106
|
+
) -> ApiV2AutoTestsSearchPostRequest:
|
|
107
|
+
autotests_filter = AutoTestSearchApiModelFilter(
|
|
108
|
+
project_ids=[project_id],
|
|
109
|
+
external_ids=[external_id],
|
|
110
|
+
is_deleted=False)
|
|
111
|
+
autotests_includes = AutoTestSearchApiModelIncludes(
|
|
112
|
+
include_steps=False,
|
|
113
|
+
include_links=False,
|
|
114
|
+
include_labels=False)
|
|
115
|
+
|
|
116
|
+
return ApiV2AutoTestsSearchPostRequest(filter=autotests_filter, includes=autotests_includes)
|
|
117
|
+
|
|
118
|
+
@staticmethod
|
|
119
|
+
@adapter_logger
|
|
120
|
+
def build_test_results_search_post_request_with_in_progress_outcome(
|
|
121
|
+
testrun_id: str,
|
|
122
|
+
configuration_id: str) -> ApiV2TestResultsSearchPostRequest:
|
|
123
|
+
return ApiV2TestResultsSearchPostRequest(
|
|
124
|
+
test_run_ids=[testrun_id],
|
|
125
|
+
configuration_ids=[configuration_id],
|
|
126
|
+
status_types=[TestStatusApiType("InProgress")])
|
|
127
|
+
|
|
128
|
+
@staticmethod
|
|
129
|
+
@adapter_logger
|
|
130
|
+
def autotest_ids_to_autotests_search_post_request(
|
|
131
|
+
autotest_ids: List[int]) -> ApiV2AutoTestsSearchPostRequest:
|
|
132
|
+
autotests_filter = AutoTestSearchApiModelFilter(
|
|
133
|
+
global_ids=autotest_ids)
|
|
134
|
+
autotests_includes = AutoTestSearchApiModelIncludes(
|
|
135
|
+
include_steps=False,
|
|
136
|
+
include_links=False,
|
|
137
|
+
include_labels=False)
|
|
138
|
+
|
|
139
|
+
return ApiV2AutoTestsSearchPostRequest(filter=autotests_filter, includes=autotests_includes)
|
|
140
|
+
|
|
141
|
+
@staticmethod
|
|
142
|
+
@adapter_logger
|
|
143
|
+
def get_external_ids_from_autotest_response_list(
|
|
144
|
+
autotests: List[TestResultShortResponse],
|
|
145
|
+
configuration: str) -> List[str]:
|
|
146
|
+
external_ids: List[str] = []
|
|
147
|
+
|
|
148
|
+
for autotest in autotests:
|
|
149
|
+
if configuration == autotest.configuration_id:
|
|
150
|
+
external_ids.append(autotest.autotest_external_id)
|
|
151
|
+
|
|
152
|
+
return external_ids
|
|
153
|
+
|
|
154
|
+
@classmethod
|
|
155
|
+
@adapter_logger
|
|
156
|
+
def test_result_to_autotest_post_model(
|
|
157
|
+
cls,
|
|
158
|
+
test_result: TestResult,
|
|
159
|
+
project_id: str) -> AutoTestCreateApiModel:
|
|
160
|
+
return AutoTestCreateApiModel(
|
|
161
|
+
external_id=test_result.get_external_id(),
|
|
162
|
+
project_id=project_id,
|
|
163
|
+
name=test_result.get_autotest_name(),
|
|
164
|
+
steps=cls.step_results_to_autotest_steps_model(
|
|
165
|
+
test_result.get_step_results()),
|
|
166
|
+
setup=cls.step_results_to_autotest_steps_model(
|
|
167
|
+
test_result.get_setup_results()),
|
|
168
|
+
teardown=cls.step_results_to_autotest_steps_model(
|
|
169
|
+
test_result.get_teardown_results()),
|
|
170
|
+
namespace=test_result.get_namespace(),
|
|
171
|
+
classname=test_result.get_classname(),
|
|
172
|
+
title=test_result.get_title(),
|
|
173
|
+
description=test_result.get_description(),
|
|
174
|
+
links=cls.links_to_links_create_api_model(test_result.get_links()),
|
|
175
|
+
labels=test_result.get_labels(),
|
|
176
|
+
tags=test_result.get_tags(),
|
|
177
|
+
should_create_work_item=test_result.get_automatic_creation_test_cases(),
|
|
178
|
+
external_key=test_result.get_external_key()
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
@adapter_logger
|
|
183
|
+
def test_result_to_create_autotest_request(
|
|
184
|
+
cls,
|
|
185
|
+
test_result: TestResult,
|
|
186
|
+
project_id: str) -> CreateAutoTestRequest:
|
|
187
|
+
return CreateAutoTestRequest(
|
|
188
|
+
external_id=test_result.get_external_id(),
|
|
189
|
+
project_id=project_id,
|
|
190
|
+
name=test_result.get_autotest_name(),
|
|
191
|
+
steps=cls.step_results_to_autotest_steps_model(
|
|
192
|
+
test_result.get_step_results()),
|
|
193
|
+
setup=cls.step_results_to_autotest_steps_model(
|
|
194
|
+
test_result.get_setup_results()),
|
|
195
|
+
teardown=cls.step_results_to_autotest_steps_model(
|
|
196
|
+
test_result.get_teardown_results()),
|
|
197
|
+
namespace=test_result.get_namespace(),
|
|
198
|
+
classname=test_result.get_classname(),
|
|
199
|
+
title=test_result.get_title(),
|
|
200
|
+
description=test_result.get_description(),
|
|
201
|
+
links=cls.links_to_links_create_api_model(test_result.get_links()),
|
|
202
|
+
labels=test_result.get_labels(),
|
|
203
|
+
tags=test_result.get_tags(),
|
|
204
|
+
should_create_work_item=test_result.get_automatic_creation_test_cases(),
|
|
205
|
+
external_key=test_result.get_external_key()
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
@classmethod
|
|
209
|
+
@adapter_logger
|
|
210
|
+
def test_result_to_autotest_put_model(
|
|
211
|
+
cls,
|
|
212
|
+
test_result: TestResult,
|
|
213
|
+
project_id: str) -> AutoTestUpdateApiModel:
|
|
214
|
+
return AutoTestUpdateApiModel(
|
|
215
|
+
external_id=test_result.get_external_id(),
|
|
216
|
+
project_id=project_id,
|
|
217
|
+
name=test_result.get_autotest_name(),
|
|
218
|
+
steps=cls.step_results_to_autotest_steps_model(
|
|
219
|
+
test_result.get_step_results()),
|
|
220
|
+
setup=cls.step_results_to_autotest_steps_model(
|
|
221
|
+
test_result.get_setup_results()),
|
|
222
|
+
teardown=cls.step_results_to_autotest_steps_model(
|
|
223
|
+
test_result.get_teardown_results()),
|
|
224
|
+
namespace=test_result.get_namespace(),
|
|
225
|
+
classname=test_result.get_classname(),
|
|
226
|
+
title=test_result.get_title(),
|
|
227
|
+
description=test_result.get_description(),
|
|
228
|
+
links=cls.links_to_links_put_model(test_result.get_links()),
|
|
229
|
+
labels=test_result.get_labels(),
|
|
230
|
+
tags=test_result.get_tags(),
|
|
231
|
+
external_key=test_result.get_external_key()
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
@classmethod
|
|
235
|
+
@adapter_logger
|
|
236
|
+
def test_result_to_update_autotest_request(
|
|
237
|
+
cls,
|
|
238
|
+
test_result: TestResult,
|
|
239
|
+
project_id: str) -> UpdateAutoTestRequest:
|
|
240
|
+
return UpdateAutoTestRequest(
|
|
241
|
+
external_id=test_result.get_external_id(),
|
|
242
|
+
project_id=project_id,
|
|
243
|
+
name=test_result.get_autotest_name(),
|
|
244
|
+
steps=cls.step_results_to_autotest_steps_model(
|
|
245
|
+
test_result.get_step_results()),
|
|
246
|
+
setup=cls.step_results_to_autotest_steps_model(
|
|
247
|
+
test_result.get_setup_results()),
|
|
248
|
+
teardown=cls.step_results_to_autotest_steps_model(
|
|
249
|
+
test_result.get_teardown_results()),
|
|
250
|
+
namespace=test_result.get_namespace(),
|
|
251
|
+
classname=test_result.get_classname(),
|
|
252
|
+
title=test_result.get_title(),
|
|
253
|
+
description=test_result.get_description(),
|
|
254
|
+
links=cls.links_to_links_put_model(test_result.get_links()),
|
|
255
|
+
labels=test_result.get_labels(),
|
|
256
|
+
tags=test_result.get_tags(),
|
|
257
|
+
external_key=test_result.get_external_key()
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
@classmethod
|
|
261
|
+
@adapter_logger
|
|
262
|
+
def test_result_to_testrun_result_post_model(
|
|
263
|
+
cls,
|
|
264
|
+
test_result: TestResult,
|
|
265
|
+
configuration_id: str,
|
|
266
|
+
status_codes: List[str]) -> AutoTestResultsForTestRunModel:
|
|
267
|
+
model = AutoTestResultsForTestRunModel(
|
|
268
|
+
configuration_id=configuration_id,
|
|
269
|
+
auto_test_external_id=test_result.get_external_id(),
|
|
270
|
+
status_type=TestStatusType(test_result.get_status_type()),
|
|
271
|
+
step_results=cls.step_results_to_attachment_put_model_autotest_step_results_model(
|
|
272
|
+
test_result.get_step_results()),
|
|
273
|
+
setup_results=cls.step_results_to_attachment_put_model_autotest_step_results_model(
|
|
274
|
+
test_result.get_setup_results()),
|
|
275
|
+
teardown_results=cls.step_results_to_attachment_put_model_autotest_step_results_model(
|
|
276
|
+
test_result.get_teardown_results()),
|
|
277
|
+
traces=test_result.get_traces(),
|
|
278
|
+
attachments=test_result.get_attachments(),
|
|
279
|
+
parameters=test_result.get_parameters(),
|
|
280
|
+
properties=test_result.get_properties(),
|
|
281
|
+
links=cls.links_to_links_post_model(
|
|
282
|
+
test_result.get_result_links()),
|
|
283
|
+
duration=round(test_result.get_duration()),
|
|
284
|
+
message=test_result.get_message(),
|
|
285
|
+
started_on=test_result.get_started_on(),
|
|
286
|
+
completed_on=test_result.get_completed_on()
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
if test_result.get_outcome().upper() in status_codes:
|
|
290
|
+
model.status_code = test_result.get_outcome()
|
|
291
|
+
|
|
292
|
+
return model
|
|
293
|
+
|
|
294
|
+
@classmethod
|
|
295
|
+
@adapter_logger
|
|
296
|
+
def convert_test_result_model_to_test_results_id_put_request(
|
|
297
|
+
cls,
|
|
298
|
+
test_result: TestResultResponse) -> ApiV2TestResultsIdPutRequest:
|
|
299
|
+
return ApiV2TestResultsIdPutRequest(
|
|
300
|
+
failure_class_ids=test_result.failure_class_ids,
|
|
301
|
+
status_code=test_result.status.code,
|
|
302
|
+
comment=test_result.comment,
|
|
303
|
+
links=list(map(cls.build_create_link_api_model, test_result.links)),
|
|
304
|
+
step_results=test_result.step_results,
|
|
305
|
+
attachments=cls.attachment_models_to_attachment_put_models(test_result.attachments),
|
|
306
|
+
duration_in_ms=test_result.duration_in_ms,
|
|
307
|
+
step_comments=test_result.step_comments,
|
|
308
|
+
# setup_results=test_result.setup_results,
|
|
309
|
+
# teardown_results=test_result.teardown_results,
|
|
310
|
+
message=test_result.message,
|
|
311
|
+
trace=test_result.traces)
|
|
312
|
+
|
|
313
|
+
@classmethod
|
|
314
|
+
@adapter_logger
|
|
315
|
+
def convert_test_result_with_all_setup_and_teardown_steps_to_test_results_id_put_request(
|
|
316
|
+
cls,
|
|
317
|
+
test_result: TestResultWithAllFixtureStepResults) -> ApiV2TestResultsIdPutRequest:
|
|
318
|
+
return ApiV2TestResultsIdPutRequest(
|
|
319
|
+
setup_results=cls.step_results_to_auto_test_step_result_update_request(
|
|
320
|
+
test_result.get_setup_results()),
|
|
321
|
+
teardown_results=cls.step_results_to_auto_test_step_result_update_request(
|
|
322
|
+
test_result.get_teardown_results()))
|
|
323
|
+
|
|
324
|
+
@classmethod
|
|
325
|
+
@adapter_logger
|
|
326
|
+
def get_test_result_id_from_testrun_result_post_response(cls, response) -> str:
|
|
327
|
+
return response[0]
|
|
328
|
+
|
|
329
|
+
@staticmethod
|
|
330
|
+
@adapter_logger
|
|
331
|
+
def link_to_link_post_model(link: Link) -> LinkPostModel:
|
|
332
|
+
if link.get_link_type():
|
|
333
|
+
return LinkPostModel(
|
|
334
|
+
url=link.get_url(),
|
|
335
|
+
title=link.get_title(),
|
|
336
|
+
type=LinkType(link.get_link_type()),
|
|
337
|
+
description=link.get_description(),
|
|
338
|
+
has_info=True,
|
|
339
|
+
)
|
|
340
|
+
else:
|
|
341
|
+
return LinkPostModel(
|
|
342
|
+
url=link.get_url(),
|
|
343
|
+
title=link.get_title(),
|
|
344
|
+
description=link.get_description(),
|
|
345
|
+
has_info=True,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
@staticmethod
|
|
349
|
+
@adapter_logger
|
|
350
|
+
def link_to_link_create_api_model(link: Link) -> LinkCreateApiModel:
|
|
351
|
+
if link.get_link_type():
|
|
352
|
+
return LinkCreateApiModel(
|
|
353
|
+
url=link.get_url(),
|
|
354
|
+
title=link.get_title(),
|
|
355
|
+
type=LinkType(link.get_link_type()),
|
|
356
|
+
description=link.get_description(),
|
|
357
|
+
has_info=True,
|
|
358
|
+
)
|
|
359
|
+
else:
|
|
360
|
+
return LinkCreateApiModel(
|
|
361
|
+
url=link.get_url(),
|
|
362
|
+
title=link.get_title(),
|
|
363
|
+
description=link.get_description(),
|
|
364
|
+
has_info=True,
|
|
365
|
+
)
|
|
366
|
+
|
|
367
|
+
@staticmethod
|
|
368
|
+
@adapter_logger
|
|
369
|
+
def link_to_link_put_model(link: Link) -> LinkUpdateApiModel:
|
|
370
|
+
if link.get_link_type():
|
|
371
|
+
return LinkUpdateApiModel(
|
|
372
|
+
url=link.get_url(),
|
|
373
|
+
title=link.get_title(),
|
|
374
|
+
type=LinkType(link.get_link_type()),
|
|
375
|
+
description=link.get_description(),
|
|
376
|
+
has_info=True,
|
|
377
|
+
)
|
|
378
|
+
else:
|
|
379
|
+
return LinkUpdateApiModel(
|
|
380
|
+
url=link.get_url(),
|
|
381
|
+
title=link.get_title(),
|
|
382
|
+
description=link.get_description(),
|
|
383
|
+
has_info=True,
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
@classmethod
|
|
387
|
+
@adapter_logger
|
|
388
|
+
def links_to_links_post_model(cls, links: List[Link]) -> List[LinkPostModel]:
|
|
389
|
+
post_model_links = []
|
|
390
|
+
|
|
391
|
+
for link in links:
|
|
392
|
+
post_model_links.append(
|
|
393
|
+
cls.link_to_link_post_model(link)
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
return post_model_links
|
|
397
|
+
|
|
398
|
+
@classmethod
|
|
399
|
+
@adapter_logger
|
|
400
|
+
def links_to_links_create_api_model(cls, links: List[Link]) -> List[LinkCreateApiModel]:
|
|
401
|
+
create_api_model_links = []
|
|
402
|
+
|
|
403
|
+
for link in links:
|
|
404
|
+
create_api_model_links.append(
|
|
405
|
+
cls.link_to_link_create_api_model(link)
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
return create_api_model_links
|
|
409
|
+
|
|
410
|
+
@classmethod
|
|
411
|
+
@adapter_logger
|
|
412
|
+
def links_to_links_put_model(cls, links: List[Link]) -> List[LinkUpdateApiModel]:
|
|
413
|
+
put_model_links = []
|
|
414
|
+
|
|
415
|
+
for link in links:
|
|
416
|
+
put_model_links.append(
|
|
417
|
+
cls.link_to_link_put_model(link)
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
return put_model_links
|
|
421
|
+
|
|
422
|
+
@classmethod
|
|
423
|
+
@adapter_logger
|
|
424
|
+
def attachment_models_to_attachment_put_models(
|
|
425
|
+
cls, attachments: List[AttachmentApiResult]) -> List[AttachmentUpdateRequest]:
|
|
426
|
+
put_model_attachments = []
|
|
427
|
+
|
|
428
|
+
for attachment in attachments:
|
|
429
|
+
put_model_attachments.append(
|
|
430
|
+
cls.attachment_model_to_attachment_put_model(attachment)
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
return put_model_attachments
|
|
434
|
+
|
|
435
|
+
@staticmethod
|
|
436
|
+
@adapter_logger
|
|
437
|
+
def attachment_model_to_attachment_put_model(attachment: AttachmentApiResult) -> AttachmentUpdateRequest:
|
|
438
|
+
return AttachmentUpdateRequest(id=attachment.id)
|
|
439
|
+
|
|
440
|
+
@classmethod
|
|
441
|
+
@adapter_logger
|
|
442
|
+
def build_attachment_update_requests(
|
|
443
|
+
cls, attachments: List[AttachmentPutModel]) -> List[AttachmentUpdateRequest]:
|
|
444
|
+
put_model_attachments = []
|
|
445
|
+
|
|
446
|
+
for attachment in attachments:
|
|
447
|
+
put_model_attachments.append(
|
|
448
|
+
cls.build_attachment_update_request(attachment)
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
return put_model_attachments
|
|
452
|
+
|
|
453
|
+
@staticmethod
|
|
454
|
+
@adapter_logger
|
|
455
|
+
def build_attachment_update_request(attachment: AttachmentPutModel) -> AttachmentUpdateRequest:
|
|
456
|
+
return AttachmentUpdateRequest(id=attachment.id)
|
|
457
|
+
|
|
458
|
+
@classmethod
|
|
459
|
+
# @adapter_logger
|
|
460
|
+
def step_results_to_autotest_steps_model(
|
|
461
|
+
cls, step_results: List[StepResult]) -> List[AutoTestStepApiModel]:
|
|
462
|
+
autotest_model_steps = []
|
|
463
|
+
|
|
464
|
+
for step_result in step_results:
|
|
465
|
+
autotest_model_steps.append(
|
|
466
|
+
AutoTestStepApiModel(
|
|
467
|
+
title=step_result.get_title(),
|
|
468
|
+
description=step_result.get_description(),
|
|
469
|
+
steps=cls.step_results_to_autotest_steps_model(
|
|
470
|
+
step_result.get_step_results()))
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
return autotest_model_steps
|
|
474
|
+
|
|
475
|
+
@classmethod
|
|
476
|
+
@adapter_logger
|
|
477
|
+
def step_results_to_attachment_put_model_autotest_step_results_model(
|
|
478
|
+
cls, step_results: List[StepResult]) -> List[AttachmentPutModelAutoTestStepResultsModel]:
|
|
479
|
+
autotest_model_step_results = []
|
|
480
|
+
|
|
481
|
+
for step_result in step_results:
|
|
482
|
+
autotest_model_step_results.append(
|
|
483
|
+
AttachmentPutModelAutoTestStepResultsModel(
|
|
484
|
+
title=step_result.get_title(),
|
|
485
|
+
outcome=AvailableTestResultOutcome(step_result.get_outcome()),
|
|
486
|
+
description=step_result.get_description(),
|
|
487
|
+
duration=step_result.get_duration(),
|
|
488
|
+
parameters=step_result.get_parameters(),
|
|
489
|
+
attachments=step_result.get_attachments(),
|
|
490
|
+
started_on=step_result.get_started_on(),
|
|
491
|
+
completed_on=step_result.get_completed_on(),
|
|
492
|
+
step_results=cls.step_results_to_attachment_put_model_autotest_step_results_model(
|
|
493
|
+
step_result.get_step_results())
|
|
494
|
+
)
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
return autotest_model_step_results
|
|
498
|
+
|
|
499
|
+
@staticmethod
|
|
500
|
+
@adapter_logger
|
|
501
|
+
def fixtures_containers_to_test_results_with_all_fixture_step_results(
|
|
502
|
+
fixtures_containers: dict,
|
|
503
|
+
test_result_ids: dict) -> List[TestResultWithAllFixtureStepResults]:
|
|
504
|
+
test_results_with_all_fixture_step_results = []
|
|
505
|
+
|
|
506
|
+
for external_id, test_result_id in test_result_ids.items():
|
|
507
|
+
test_result_with_all_fixture_step_results = TestResultWithAllFixtureStepResults(test_result_id)
|
|
508
|
+
|
|
509
|
+
for uuid, fixtures_container in fixtures_containers.items():
|
|
510
|
+
if external_id in fixtures_container.external_ids:
|
|
511
|
+
if fixtures_container.befores:
|
|
512
|
+
test_result_with_all_fixture_step_results.set_setup_results(fixtures_container.befores[0].steps)
|
|
513
|
+
|
|
514
|
+
if fixtures_container.afters:
|
|
515
|
+
test_result_with_all_fixture_step_results.set_teardown_results(
|
|
516
|
+
fixtures_container.afters[0].steps)
|
|
517
|
+
|
|
518
|
+
if (test_result_with_all_fixture_step_results.get_setup_results()
|
|
519
|
+
or test_result_with_all_fixture_step_results.get_teardown_results()):
|
|
520
|
+
test_results_with_all_fixture_step_results.append(test_result_with_all_fixture_step_results)
|
|
521
|
+
|
|
522
|
+
return test_results_with_all_fixture_step_results
|
|
523
|
+
|
|
524
|
+
@classmethod
|
|
525
|
+
@adapter_logger
|
|
526
|
+
def step_results_to_auto_test_step_result_update_request(
|
|
527
|
+
cls, step_results: List[StepResult]) -> List[AutoTestStepResultUpdateRequest]:
|
|
528
|
+
autotest_model_step_results = []
|
|
529
|
+
|
|
530
|
+
for step_result in step_results:
|
|
531
|
+
autotest_model_step_results.append(
|
|
532
|
+
AutoTestStepResultUpdateRequest(
|
|
533
|
+
title=step_result.get_title(),
|
|
534
|
+
outcome=AvailableTestResultOutcome(step_result.get_outcome()),
|
|
535
|
+
description=step_result.get_description(),
|
|
536
|
+
duration=step_result.get_duration(),
|
|
537
|
+
parameters=step_result.get_parameters(),
|
|
538
|
+
attachments=cls.build_attachment_update_requests(step_result.get_attachments()),
|
|
539
|
+
started_on=step_result.get_started_on(),
|
|
540
|
+
completed_on=step_result.get_completed_on(),
|
|
541
|
+
step_results=cls.step_results_to_auto_test_step_result_update_request(
|
|
542
|
+
step_result.get_step_results())
|
|
543
|
+
)
|
|
544
|
+
)
|
|
545
|
+
|
|
546
|
+
return autotest_model_step_results
|
|
547
|
+
|
|
548
|
+
@classmethod
|
|
549
|
+
@adapter_logger
|
|
550
|
+
def prepare_to_create_autotest(
|
|
551
|
+
cls,
|
|
552
|
+
test_result: TestResult,
|
|
553
|
+
project_id: str,
|
|
554
|
+
work_item_ids_for_link_with_auto_test: list) -> CreateAutoTestRequest:
|
|
555
|
+
logging.debug('Preparing to create the auto test ' + test_result.get_external_id())
|
|
556
|
+
|
|
557
|
+
model = cls.test_result_to_create_autotest_request(
|
|
558
|
+
test_result,
|
|
559
|
+
project_id)
|
|
560
|
+
model.work_item_ids_for_link_with_auto_test = work_item_ids_for_link_with_auto_test
|
|
561
|
+
|
|
562
|
+
return model
|
|
563
|
+
|
|
564
|
+
@classmethod
|
|
565
|
+
@adapter_logger
|
|
566
|
+
def prepare_to_mass_create_autotest(
|
|
567
|
+
cls,
|
|
568
|
+
test_result: TestResult,
|
|
569
|
+
project_id: str,
|
|
570
|
+
work_item_ids_for_link_with_auto_test: list) -> AutoTestCreateApiModel:
|
|
571
|
+
logging.debug('Preparing to create the auto test ' + test_result.get_external_id())
|
|
572
|
+
|
|
573
|
+
model = cls.test_result_to_autotest_post_model(
|
|
574
|
+
test_result,
|
|
575
|
+
project_id)
|
|
576
|
+
model.work_item_ids_for_link_with_auto_test = work_item_ids_for_link_with_auto_test
|
|
577
|
+
|
|
578
|
+
return model
|
|
579
|
+
|
|
580
|
+
@classmethod
|
|
581
|
+
@adapter_logger
|
|
582
|
+
def prepare_to_update_autotest(
|
|
583
|
+
cls,
|
|
584
|
+
test_result: TestResult,
|
|
585
|
+
autotest: AutoTestApiResult,
|
|
586
|
+
project_id: str) -> UpdateAutoTestRequest:
|
|
587
|
+
logging.debug('Preparing to update the auto test ' + test_result.get_external_id())
|
|
588
|
+
|
|
589
|
+
model = cls.test_result_to_update_autotest_request(
|
|
590
|
+
test_result,
|
|
591
|
+
project_id)
|
|
592
|
+
model.is_flaky = autotest.is_flaky
|
|
593
|
+
# TODO: return after fix PUT/api/v2/autoTests
|
|
594
|
+
# model.work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
595
|
+
# test_result.get_work_item_ids(),
|
|
596
|
+
# str(autotest.global_id))
|
|
597
|
+
|
|
598
|
+
return model
|
|
599
|
+
|
|
600
|
+
@classmethod
|
|
601
|
+
@adapter_logger
|
|
602
|
+
def prepare_to_mass_update_autotest(
|
|
603
|
+
cls,
|
|
604
|
+
test_result: TestResult,
|
|
605
|
+
autotest: AutoTestApiResult,
|
|
606
|
+
project_id: str) -> AutoTestUpdateApiModel:
|
|
607
|
+
logging.debug('Preparing to update the auto test ' + test_result.get_external_id())
|
|
608
|
+
|
|
609
|
+
model = cls.test_result_to_autotest_put_model(
|
|
610
|
+
test_result,
|
|
611
|
+
project_id)
|
|
612
|
+
model.is_flaky = autotest.is_flaky
|
|
613
|
+
# TODO: return after fix PUT/api/v2/autoTests
|
|
614
|
+
# model.work_item_ids_for_link_with_auto_test = self.__get_work_item_uuids_for_link_with_auto_test(
|
|
615
|
+
# test_result.get_work_item_ids(),
|
|
616
|
+
# str(autotest.global_id))
|
|
617
|
+
|
|
618
|
+
return model
|
|
File without changes
|