Skip to content

Commit

Permalink
Merge pull request #70 from iivanou/rp5_initial
Browse files Browse the repository at this point in the history
Initial commit for RP v5 client
  • Loading branch information
Dmitriy Gumeniuk authored Mar 3, 2020
2 parents 8cbcc8c + b9c22d2 commit 8740111
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 12 deletions.
55 changes: 46 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Library used only for implementors of custom listeners for ReportPortal

- [PyTest Framework](https://github.com/reportportal/agent-python-pytest)
- [Robot Framework](https://github.com/reportportal/agent-Python-RobotFramework)
- [Nose Framework](https://github.com/reportportal/agent-python-nosetests)


## Installation
Expand All @@ -20,13 +21,28 @@ The latest stable version is available on PyPI:
pip install reportportal-client
```

**IMPORTANT!**
The lastest version **does** not support Report Portal versions below 5.0.0.

Specify the last one release of the client version 3 to install or update the client for other versions of Report Portal below 5.0.0:

```
pip install reportportal-client~=3.0
```


## Contribution

All the fixes for the client that supports Report Portal versions below 5.0.0 should go into the v3 branch.
The master branch will store the code base for the client for Report Portal versions 5 and above.


## Usage

Main classes are:

- reportportal_client.ReportPortalService
- reportportal_client.ReportPortalServiceAsync
- reportportal_client.ReportPortalServiceAsync(Client version 3.x only)

Basic usage example:

Expand All @@ -37,8 +53,12 @@ import traceback
from mimetypes import guess_type
from time import time

# Report Portal versions below 5.0.0:
from reportportal_client import ReportPortalServiceAsync

# Report Portal versions >= 5.0.0:
from reportportal_client import ReportPortalService


def timestamp():
return str(int(time() * 1000))
Expand All @@ -63,15 +83,20 @@ def my_error_handler(exc_info):
traceback.print_exception(*exc_info)


# Report Portal versions below 5.0.0:
service = ReportPortalServiceAsync(endpoint=endpoint, project=project,
token=token, error_handler=my_error_handler)

# Report Portal versions >= 5.0.0:
service = ReportPortalServiceAsync(endpoint=endpoint, project=project,
token=token)

# Start launch.
launch = service.start_launch(name=launch_name,
start_time=timestamp(),
description=launch_doc)

# Start test item.
# Start test item Report Portal versions below 5.0.0:
test = service.start_test_item(name="Test Case",
description="First Test Case",
tags=["Image", "Smoke"],
Expand All @@ -80,6 +105,15 @@ test = service.start_test_item(name="Test Case",
parameters={"key1": "val1",
"key2": "val2"})

# Start test item Report Portal versions >= 5.0.0:
item_id = service.start_test_item(name="Test Case",
description="First Test Case",
start_time=timestamp(),
item_type="STEP",
parameters={"key1": "val1",
"key2": "val2"})


# Create text log message with INFO level.
service.log(time=timestamp(),
message="Hello World!",
Expand Down Expand Up @@ -112,9 +146,12 @@ service.log(
"INFO",
attachment=subprocess.check_output("ps aux".split()))

# Finish test item.
# Finish test item Report Portal versions below 5.0.0.
service.finish_test_item(end_time=timestamp(), status="PASSED")

# Finish test item Report Portal versions >= 5.0.0.
service.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED")

# Finish launch.
service.finish_launch(end_time=timestamp())

Expand All @@ -135,9 +172,9 @@ There are two ways to pass data as attachment:
```
with open(screenshot_file_path, "rb") as image_file:
rp_logger.info("Some Text Here",
attachment={"name": "test_name_screenshot.png",
"data": image_file,
"mime": "image/png"})
attachment={"name": "test_name_screenshot.png",
"data": image_file,
"mime": "image/png"})
```

### Case 2 - pass file content itself (like you did)
Expand All @@ -146,9 +183,9 @@ with open(screenshot_file_path, "rb") as image_file:
file_data = image_file.read()
rp_logger.info("Some Text Here",
attachment={"name": "test_name_screenshot.png",
"data": file_data,
"mime": "image/png"})
attachment={"name": "test_name_screenshot.png",
"data": file_data,
"mime": "image/png"})
```


Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from setuptools import setup, find_packages

__version__ = '3.2.3'
__version__ = '4.0.0'

setup(
name='reportportal-client',
packages=find_packages(),
version=__version__,
description='Python client for Report Portal',
author='Artsiom Tkachou',
description='Python client for Report Portal v5.',
author_email='[email protected]',
url='https://github.com/reportportal/client-Python',
download_url=('https://github.com/reportportal/client-Python/'
Expand Down

0 comments on commit 8740111

Please sign in to comment.