Skip to content

Commit

Permalink
Add support for the item update call
Browse files Browse the repository at this point in the history
  • Loading branch information
iivanou committed Apr 1, 2020
1 parent 89850c2 commit 19b2957
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
34 changes: 31 additions & 3 deletions reportportal_client/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def start_launch(self,
mode=None,
**kwargs):
"""Start a new launch with the given parameters."""
if attributes is not None:
if attributes and isinstance(attributes, dict):
attributes = _dict_to_payload(attributes)
data = {
"name": name,
Expand Down Expand Up @@ -262,7 +262,7 @@ def start_test_item(self,
...
}
"""
if attributes:
if attributes and isinstance(attributes, dict):
attributes = _dict_to_payload(attributes)
if parameters:
parameters = _dict_to_payload(parameters)
Expand All @@ -287,6 +287,24 @@ def start_test_item(self,
logger.debug("start_test_item - ID: %s", item_id)
return item_id

def update_test_item(self, item_uuid, attributes=None, description=None):
"""Update existing test item at the Report Portal.
:param str item_uuid: Test item UUID returned on the item start
:param str description: Test item description
:param list attributes: Test item attributes
[{'key': 'k_name', 'value': 'k_value'}, ...]
"""
data = {
"description": description,
"attributes": attributes,
}
item_id = self.get_item_id_by_uuid(item_uuid)
url = uri_join(self.base_url_v1, "item", item_id, "update")
r = self.session.put(url=url, json=data, verify=self.verify_ssl)
logger.debug("update_test_item - Item: %s", item_id)
return _get_msg(r)

def finish_test_item(self,
item_id,
end_time,
Expand All @@ -310,7 +328,7 @@ def finish_test_item(self,
and not self.is_skipped_an_issue:
issue = {"issue_type": "NOT_ISSUE"}

if attributes:
if attributes and isinstance(attributes, dict):
attributes = _dict_to_payload(attributes)

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

def get_item_id_by_uuid(self, uuid):
"""Get test item ID by the given UUID.
:param str uuid: UUID returned on the item start
:return str: Test item id
"""
url = uri_join(self.base_url_v1, "item", "uuid", uuid)
return _get_json(self.session.get(
url=url, verify=self.verify_ssl))["id"]

def get_project_settings(self):
"""
Get settings from project.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

__version__ = '5.0.1'
__version__ = '5.0.2'

setup(
name='reportportal-client',
Expand Down

0 comments on commit 19b2957

Please sign in to comment.