Skip to content

Commit 19b2957

Browse files
authored
Add support for the item update call
1 parent 89850c2 commit 19b2957

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

reportportal_client/service.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def start_launch(self,
207207
mode=None,
208208
**kwargs):
209209
"""Start a new launch with the given parameters."""
210-
if attributes is not None:
210+
if attributes and isinstance(attributes, dict):
211211
attributes = _dict_to_payload(attributes)
212212
data = {
213213
"name": name,
@@ -262,7 +262,7 @@ def start_test_item(self,
262262
...
263263
}
264264
"""
265-
if attributes:
265+
if attributes and isinstance(attributes, dict):
266266
attributes = _dict_to_payload(attributes)
267267
if parameters:
268268
parameters = _dict_to_payload(parameters)
@@ -287,6 +287,24 @@ def start_test_item(self,
287287
logger.debug("start_test_item - ID: %s", item_id)
288288
return item_id
289289

290+
def update_test_item(self, item_uuid, attributes=None, description=None):
291+
"""Update existing test item at the Report Portal.
292+
293+
:param str item_uuid: Test item UUID returned on the item start
294+
:param str description: Test item description
295+
:param list attributes: Test item attributes
296+
[{'key': 'k_name', 'value': 'k_value'}, ...]
297+
"""
298+
data = {
299+
"description": description,
300+
"attributes": attributes,
301+
}
302+
item_id = self.get_item_id_by_uuid(item_uuid)
303+
url = uri_join(self.base_url_v1, "item", item_id, "update")
304+
r = self.session.put(url=url, json=data, verify=self.verify_ssl)
305+
logger.debug("update_test_item - Item: %s", item_id)
306+
return _get_msg(r)
307+
290308
def finish_test_item(self,
291309
item_id,
292310
end_time,
@@ -310,7 +328,7 @@ def finish_test_item(self,
310328
and not self.is_skipped_an_issue:
311329
issue = {"issue_type": "NOT_ISSUE"}
312330

313-
if attributes:
331+
if attributes and isinstance(attributes, dict):
314332
attributes = _dict_to_payload(attributes)
315333

316334
data = {
@@ -325,6 +343,16 @@ def finish_test_item(self,
325343
logger.debug("finish_test_item - ID: %s", item_id)
326344
return _get_msg(r)
327345

346+
def get_item_id_by_uuid(self, uuid):
347+
"""Get test item ID by the given UUID.
348+
349+
:param str uuid: UUID returned on the item start
350+
:return str: Test item id
351+
"""
352+
url = uri_join(self.base_url_v1, "item", "uuid", uuid)
353+
return _get_json(self.session.get(
354+
url=url, verify=self.verify_ssl))["id"]
355+
328356
def get_project_settings(self):
329357
"""
330358
Get settings from project.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup, find_packages
44

5-
__version__ = '5.0.1'
5+
__version__ = '5.0.2'
66

77
setup(
88
name='reportportal-client',

0 commit comments

Comments
 (0)