Skip to content

Commit 8740111

Browse files
author
Dmitriy Gumeniuk
authored
Merge pull request #70 from iivanou/rp5_initial
Initial commit for RP v5 client
2 parents 8cbcc8c + b9c22d2 commit 8740111

File tree

2 files changed

+48
-12
lines changed

2 files changed

+48
-12
lines changed

README.md

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Library used only for implementors of custom listeners for ReportPortal
1010

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

1415

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

24+
**IMPORTANT!**
25+
The lastest version **does** not support Report Portal versions below 5.0.0.
26+
27+
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:
28+
29+
```
30+
pip install reportportal-client~=3.0
31+
```
32+
33+
34+
## Contribution
35+
36+
All the fixes for the client that supports Report Portal versions below 5.0.0 should go into the v3 branch.
37+
The master branch will store the code base for the client for Report Portal versions 5 and above.
38+
2339

2440
## Usage
2541

2642
Main classes are:
2743

2844
- reportportal_client.ReportPortalService
29-
- reportportal_client.ReportPortalServiceAsync
45+
- reportportal_client.ReportPortalServiceAsync(Client version 3.x only)
3046

3147
Basic usage example:
3248

@@ -37,8 +53,12 @@ import traceback
3753
from mimetypes import guess_type
3854
from time import time
3955

56+
# Report Portal versions below 5.0.0:
4057
from reportportal_client import ReportPortalServiceAsync
4158

59+
# Report Portal versions >= 5.0.0:
60+
from reportportal_client import ReportPortalService
61+
4262

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

6585

86+
# Report Portal versions below 5.0.0:
6687
service = ReportPortalServiceAsync(endpoint=endpoint, project=project,
6788
token=token, error_handler=my_error_handler)
6889

90+
# Report Portal versions >= 5.0.0:
91+
service = ReportPortalServiceAsync(endpoint=endpoint, project=project,
92+
token=token)
93+
6994
# Start launch.
7095
launch = service.start_launch(name=launch_name,
7196
start_time=timestamp(),
7297
description=launch_doc)
7398

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

108+
# Start test item Report Portal versions >= 5.0.0:
109+
item_id = service.start_test_item(name="Test Case",
110+
description="First Test Case",
111+
start_time=timestamp(),
112+
item_type="STEP",
113+
parameters={"key1": "val1",
114+
"key2": "val2"})
115+
116+
83117
# Create text log message with INFO level.
84118
service.log(time=timestamp(),
85119
message="Hello World!",
@@ -112,9 +146,12 @@ service.log(
112146
"INFO",
113147
attachment=subprocess.check_output("ps aux".split()))
114148

115-
# Finish test item.
149+
# Finish test item Report Portal versions below 5.0.0.
116150
service.finish_test_item(end_time=timestamp(), status="PASSED")
117151

152+
# Finish test item Report Portal versions >= 5.0.0.
153+
service.finish_test_item(item_id=item_id, end_time=timestamp(), status="PASSED")
154+
118155
# Finish launch.
119156
service.finish_launch(end_time=timestamp())
120157

@@ -135,9 +172,9 @@ There are two ways to pass data as attachment:
135172
```
136173
with open(screenshot_file_path, "rb") as image_file:
137174
rp_logger.info("Some Text Here",
138-
attachment={"name": "test_name_screenshot.png",
139-
"data": image_file,
140-
"mime": "image/png"})
175+
attachment={"name": "test_name_screenshot.png",
176+
"data": image_file,
177+
"mime": "image/png"})
141178
```
142179

143180
### Case 2 - pass file content itself (like you did)
@@ -146,9 +183,9 @@ with open(screenshot_file_path, "rb") as image_file:
146183
file_data = image_file.read()
147184
148185
rp_logger.info("Some Text Here",
149-
attachment={"name": "test_name_screenshot.png",
150-
"data": file_data,
151-
"mime": "image/png"})
186+
attachment={"name": "test_name_screenshot.png",
187+
"data": file_data,
188+
"mime": "image/png"})
152189
```
153190

154191

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from setuptools import setup, find_packages
22

3-
__version__ = '3.2.3'
3+
__version__ = '4.0.0'
44

55
setup(
66
name='reportportal-client',
77
packages=find_packages(),
88
version=__version__,
9-
description='Python client for Report Portal',
10-
author='Artsiom Tkachou',
9+
description='Python client for Report Portal v5.',
1110
author_email='[email protected]',
1211
url='https://github.com/reportportal/client-Python',
1312
download_url=('https://github.com/reportportal/client-Python/'

0 commit comments

Comments
 (0)