|
| 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' |
0 commit comments