testit-python-commons 5.1.1.post580__py3-none-any.whl → 5.1.2__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.
@@ -563,26 +563,27 @@ class ApiClientWorker:
563
563
 
564
564
  def __has_valid_test_point_id_v2(self, test_result_id: str) -> bool:
565
565
  """Hack: adapters OpenAPI omits testPointId — read GET /api/v2/testResults/{id}."""
566
- import requests
566
+ import json
567
+ import ssl
568
+ import urllib.error
569
+ import urllib.request
567
570
 
568
571
  base = (self.__config.get_url() or "").rstrip("/")
569
572
  url = f"{base}/api/v2/testResults/{test_result_id}"
570
573
  try:
571
- response = requests.get(
574
+ request = urllib.request.Request(
572
575
  url,
573
576
  headers={
574
577
  "Accept": "application/json",
575
578
  "Authorization": f"PrivateToken {self.__config.get_private_token()}",
576
579
  },
577
- timeout=10,
578
- verify=self.__config.get_cert_validation(),
580
+ method="GET",
579
581
  )
580
- if response.status_code < 200 or response.status_code >= 300:
581
- logging.debug(
582
- "v2 getTestResult %s HTTP %s", test_result_id, response.status_code
583
- )
584
- return False
585
- payload = response.json()
582
+ context = None
583
+ if not self.__config.get_cert_validation():
584
+ context = ssl._create_unverified_context()
585
+ with urllib.request.urlopen(request, timeout=10, context=context) as response:
586
+ payload = json.loads(response.read().decode("utf-8"))
586
587
  test_point_id = payload.get("testPointId")
587
588
  if test_point_id is None:
588
589
  return False
@@ -77,27 +77,47 @@ class Converter:
77
77
  test_run: TestRunApiResult,
78
78
  tags: List[str] = None,
79
79
  links: List[Link] = None) -> AdaptersTestRunsPutRequest:
80
- merged_tags = list(test_run.tags or [])
80
+ existing_tags = cls._safe_model_attr(test_run, 'tags') or []
81
+ merged_tags = list(existing_tags)
81
82
  for tag in tags or []:
82
83
  if tag not in merged_tags:
83
84
  merged_tags.append(tag)
84
85
 
85
- update_links = list(map(cls.build_update_link_api_model, test_run.links or []))
86
- existing_urls = {link.url for link in (test_run.links or [])}
86
+ existing_links = cls._safe_model_attr(test_run, 'links') or []
87
+ update_links = list(map(cls.build_update_link_api_model, existing_links))
88
+ existing_urls = {link.url for link in existing_links}
87
89
  for link in links or []:
88
90
  if link.get_url() not in existing_urls:
89
91
  update_links.append(cls.link_to_update_link_api_model(link))
90
92
  existing_urls.add(link.get_url())
91
93
 
92
- return AdaptersTestRunsPutRequest(
93
- id=test_run.id,
94
- name=test_run.name,
95
- description=test_run.description,
96
- launch_source=test_run.launch_source,
97
- attachments=list(map(cls.build_assign_attachment_api_model, test_run.attachments or [])),
98
- links=update_links,
99
- tags=merged_tags,
100
- )
94
+ existing_attachments = cls._safe_model_attr(test_run, 'attachments') or []
95
+ kwargs = {
96
+ 'id': test_run.id,
97
+ 'name': test_run.name,
98
+ 'attachments': list(map(cls.build_assign_attachment_api_model, existing_attachments)),
99
+ 'links': update_links,
100
+ 'tags': merged_tags,
101
+ }
102
+ # Adapters TestRunApiResult DTO has no description/launch_source; omit if absent.
103
+ description = cls._safe_model_attr(test_run, 'description')
104
+ if description is not None:
105
+ kwargs['description'] = description
106
+ launch_source = cls._safe_model_attr(test_run, 'launch_source')
107
+ if launch_source is not None:
108
+ kwargs['launch_source'] = launch_source
109
+
110
+ return AdaptersTestRunsPutRequest(**kwargs)
111
+
112
+ @staticmethod
113
+ def _safe_model_attr(obj, name, default=None):
114
+ try:
115
+ return obj[name]
116
+ except Exception:
117
+ try:
118
+ return getattr(obj, name)
119
+ except Exception:
120
+ return default
101
121
 
102
122
  @staticmethod
103
123
  @adapter_logger
@@ -123,9 +143,9 @@ class Converter:
123
143
  @adapter_logger
124
144
  def build_update_link_api_model(link: LinkApiResult) -> UpdateLinkApiModel:
125
145
  return UpdateLinkApiModel(
126
- id=link.id,
127
- title=link.title,
128
- description=link.description,
146
+ id=Converter._safe_model_attr(link, 'id'),
147
+ title=Converter._safe_model_attr(link, 'title'),
148
+ description=Converter._safe_model_attr(link, 'description'),
129
149
  type=link.type,
130
150
  url=link.url,
131
151
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testit-python-commons
3
- Version: 5.1.1.post580
3
+ Version: 5.1.2
4
4
  Summary: Python commons for Test IT
5
5
  Home-page: https://github.com/testit-tms/adapters-python/
6
6
  Author: Integration team
@@ -211,9 +211,9 @@ testit_python_commons/decorators.py,sha256=QI8qMjDincTRZmcZByP5y5wHsf_Fwd1oc67Wu
211
211
  testit_python_commons/dynamic_methods.py,sha256=WKHHA6Uj61tWXI3DphALYOi2BV6TnQKvQy0-Vt2JR2I,8816
212
212
  testit_python_commons/step.py,sha256=CYUs_S8opmRg1tsTY1dVJOPzzt-HYR3_uLTBpYtHSfQ,3244
213
213
  testit_python_commons/client/__init__.py,sha256=zSJhxDHzWWTFHJ0s8bqCaBtM5FK2GcPgZxaKdI8zf-o,165
214
- testit_python_commons/client/api_client.py,sha256=izH0bRWjC37aubt5hhREzCRc7SPe6DfFlcpkj0M3YXA,27693
214
+ testit_python_commons/client/api_client.py,sha256=iNzv6tXx-X3bWfP8VYU2XtgjuZVlZlijNiDSzKBplY4,27742
215
215
  testit_python_commons/client/client_configuration.py,sha256=1M-OrROU3Xj0YGsUX4venG-l6Ewr43LNvUcyFfY57ys,2776
216
- testit_python_commons/client/converter.py,sha256=pjnCHtaQNGTot-YWYb6IJ9gX9XlEos708Vi98oJBxws,26272
216
+ testit_python_commons/client/converter.py,sha256=c4jea5FDSUqt_FeRhAW829aouDJbaHUHIHL7ayro0GE,27172
217
217
  testit_python_commons/client/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
218
218
  testit_python_commons/client/helpers/bulk_autotest_helper.py,sha256=L480JYYA3zphCciJOzefCOg1upWeRgdJWd6qWEKM45k,10920
219
219
  testit_python_commons/client/helpers/threads_manager.py,sha256=Ix8NJm3Yp9_7jxGTtojsAWqfuNvtYHEia9CiHFW9b3k,3509
@@ -248,7 +248,7 @@ testit_python_commons/services/sync_storage/__init__.py,sha256=Qmjs6Xk5l-i5FFItk
248
248
  testit_python_commons/services/sync_storage/sync_storage_runner.py,sha256=9FCbMxzGa84I79X7QOjYO_oSiUUu43LhJqPDs_JEEb0,20549
249
249
  testit_python_commons/utils/__init__.py,sha256=CUHziylwvFAuKyUM1tCp13ik5Z2Mw-VK8n7c92aVy-I,78
250
250
  testit_python_commons/utils/html_escape_utils.py,sha256=wx20lAVrMvhNiQ7bEu_f-SGqDBp85D-EBL2sgTmnJPY,8135
251
- testit_python_commons-5.1.1.post580.dist-info/METADATA,sha256=BIKAbvAbBubFZyly2iBoMs5Sfvu7ju8GvdIBJ-WBAH8,1683
252
- testit_python_commons-5.1.1.post580.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
253
- testit_python_commons-5.1.1.post580.dist-info/top_level.txt,sha256=Jme7mbm0CtX-96d3cUiEonamIeb7kAo3Je4bSlxBndI,72
254
- testit_python_commons-5.1.1.post580.dist-info/RECORD,,
251
+ testit_python_commons-5.1.2.dist-info/METADATA,sha256=zc91PBMfgTPiDkwm7AR36Zi8E4raK23LUbG7kNBmGbU,1675
252
+ testit_python_commons-5.1.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
253
+ testit_python_commons-5.1.2.dist-info/top_level.txt,sha256=Jme7mbm0CtX-96d3cUiEonamIeb7kAo3Je4bSlxBndI,72
254
+ testit_python_commons-5.1.2.dist-info/RECORD,,