Skip to content

Commit

Permalink
Fix for issue #194
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Sep 16, 2022
1 parent ca9ab28 commit 1b4db05
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

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

## [5.2.4]
### Changed
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
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 1b4db05

Please sign in to comment.