Skip to content

Commit 8e4f29c

Browse files
authored
Merge pull request #106 from dmrlx/add_client
Add ReportPortal client
2 parents bc39f56 + c489c10 commit 8e4f29c

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-0
lines changed

reportportal_client/client.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
"""This module contains Report Portal Client class.
2+
3+
Copyright (c) 2018 http://reportportal.io .
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
"""
17+
18+
19+
class RPClient(object):
20+
"""Report portal client."""
21+
22+
def __init__(self, base_url, username, password, project_name, api_version,
23+
**kwargs):
24+
"""Initialize required attributes.
25+
26+
:param base_url: Base url of Report Portal
27+
:param username: Username
28+
:param password: Password
29+
:param project_name: Name of project
30+
:param api_version: Version of API
31+
"""
32+
self._launch_uuid = None
33+
self._token = None
34+
self.api_version = api_version
35+
self.base_url = base_url
36+
self.password = password
37+
self.port = kwargs.get('port', None)
38+
self.project_name = project_name
39+
self.username = username
40+
41+
@property
42+
def launch_uuid(self):
43+
"""Get launch uuid."""
44+
return self._launch_uuid
45+
46+
@property
47+
def token(self):
48+
"""Get the token."""
49+
return self._token
50+
51+
def _request(self, uri, token, **kwargs):
52+
"""Make Rest calls with necessary params.
53+
54+
:param uri: Request URI
55+
:param token: Access token
56+
:return: :class:`Response <Response>` object
57+
"""
58+
59+
def start_launch(self, name, start_time, **kwargs):
60+
"""Start launch.
61+
62+
:param name: Name of launch
63+
:param start_time: Launch start time
64+
"""
65+
# uri = f'/api/{self.api_version}/{self.project_name}/launch'
66+
67+
def start_item(self, name, start_time, item_type, parent_uuid=None,
68+
**kwargs):
69+
"""Start case/step/nested step item.
70+
71+
:param name: Name of test item
72+
:param start_time: Test item start time
73+
:param item_type: Type of test item
74+
:param parent_uuid: Parent test item UUID
75+
"""
76+
# uri = f'/api/{self.api_version}/{self.project_name}/item/
77+
# {parent_uuid}'
78+
79+
def finish_item(self, item_uuid, end_time, **kwargs):
80+
"""Finish suite/case/step/nested step item.
81+
82+
:param end_time: Item end time
83+
:param item_uuid: Item UUID
84+
"""
85+
# uri = f'/api/{self.api_version}/{self.project_name}/item/{item_uuid}'
86+
87+
def finish_launch(self, end_time, **kwargs):
88+
"""Finish launch.
89+
90+
:param end_time: Launch end time
91+
"""
92+
# uri = f'/api/{self.api_version}/{self.project_name}/launch' \
93+
# f'/{self.launch_uuid}/finish'
94+
95+
def save_log(self, log_time, **kwargs):
96+
"""Save logs for test items.
97+
98+
:param log_time: Log time
99+
"""
100+
# uri = f'/api/{self.api_version}/{self.project_name}/log'

reportportal_client/client.pyi

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from requests import Response
2+
from typing import Any, Text, Optional
3+
4+
class RPClient:
5+
_launch_uuid: Optional[Text] = ...
6+
_token: Optional[Text] = ...
7+
api_version: Text = ...
8+
base_url: Text = ...
9+
password: Text = ...
10+
port: Optional[Text] = ...
11+
project_name: Text = ...
12+
username: Text = ...
13+
def __init__(
14+
self,
15+
base_url: Text,
16+
username: Text,
17+
password: Text,
18+
project_name: Text,
19+
api_version: Text,
20+
**kwargs: Any) -> None: ...
21+
@property
22+
def launch_uuid(self) -> Text: ...
23+
@property
24+
def token(self) -> Text: ...
25+
def _request(self,
26+
uri: Text,
27+
token: Text,
28+
**kwargs: Any) -> Response: ...
29+
def start_launch(
30+
self,
31+
name: Text,
32+
start_time: Text,
33+
**kwargs: Any) -> None: ...
34+
def start_item(
35+
self,
36+
name: Text,
37+
start_time: Text,
38+
item_type: Text,
39+
launch_uuid: Text,
40+
parent_uuid: Optional[Text],
41+
**kwargs: Any) -> None: ...
42+
def finish_item(
43+
self,
44+
launch_uuid: Text,
45+
item_uuid: Text,
46+
end_time: Text,
47+
**kwargs: Any) -> None: ...
48+
def finish_launch(
49+
self,
50+
launch_uuid: Text,
51+
end_time: Text,
52+
**kwargs: Any) -> None: ...
53+
def save_log(
54+
self,
55+
launch_uuid: Text,
56+
log_time: Text,
57+
**kwargs: Any) -> None: ...

0 commit comments

Comments
 (0)