Skip to content

Commit

Permalink
Merge pull request #196 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth committed Sep 28, 2022
2 parents cf52b15 + 41a5e0e commit f5cac72
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## [Unreleased]
### Fixed
- Issue [#194](https://github.com/reportportal/client-Python/issues/194): logging URL generation, by @HardNorth
- Issue [#195](https://github.com/reportportal/client-Python/issues/195): `None` mode exception

## [5.2.4]
### Changed
- `LogManager` class moved from `core` package to `logs` package, by @HardNorth
### Fixed
Expand Down
10 changes: 6 additions & 4 deletions reportportal_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@ def start_launch(self,
# We are moving 'mode' param to the constructor, next code for the
# transition period only.
my_kwargs = dict(kwargs)
mode = my_kwargs.get('mode')
if not mode:
mode = self.mode
else:
if 'mode' in my_kwargs.keys():
mode = my_kwargs['mode']
del my_kwargs['mode']
if not mode:
mode = self.mode
else:
mode = self.mode

request_payload = LaunchStartRequest(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion reportportal_client/logs/log_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, rp_url, session, api_version, launch_id, project_name,

self._log_endpoint = (
'{rp_url}/api/{version}/{project_name}/log'
.format(rp_url=rp_url, version=self.api_version,
.format(rp_url=rp_url.rstrip('/'), version=self.api_version,
project_name=self.project_name))

def _send_batch(self):
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.2.4'
__version__ = '5.2.5'

with open('requirements.txt') as f:
requirements = f.read().splitlines()
Expand Down
22 changes: 21 additions & 1 deletion tests/logs/test_log_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
MAX_LOG_BATCH_PAYLOAD_SIZE

RP_URL = 'http://docker.local:8080'
API_VERSION = 'api/v2'
API_VERSION = 'v2'
TEST_LAUNCH_ID = 'test_launch_id'
TEST_ITEM_ID = 'test_item_id'
PROJECT_NAME = 'test_project'
Expand Down Expand Up @@ -52,6 +52,26 @@ def test_log_batch_send_by_length():
assert log_manager._payload_size == helpers.TYPICAL_MULTIPART_FOOTER_LENGTH


# noinspection PyUnresolvedReferences
def test_log_batch_send_url_format():
session = mock.Mock()
log_manager = LogManager(RP_URL + '/', session, API_VERSION,
TEST_LAUNCH_ID,
PROJECT_NAME, max_entry_number=TEST_BATCH_SIZE,
verify_ssl=False)
log_manager._worker = mock.Mock()

for _ in range(TEST_BATCH_SIZE):
log_manager.log(helpers.timestamp(), TEST_MASSAGE, TEST_LEVEL,
item_id=TEST_ITEM_ID)

assert log_manager._worker.send.call_count == 1
batch = log_manager._worker.send.call_args[0][0]
assert batch.http_request is not None
assert batch.http_request.url == \
RP_URL + '/api/' + API_VERSION + '/' + PROJECT_NAME + '/log'


# noinspection PyUnresolvedReferences
def test_log_batch_not_send_by_length():
session = mock.Mock()
Expand Down

0 comments on commit f5cac72

Please sign in to comment.