Skip to content

Commit 1b4db05

Browse files
committed
Fix for issue #194
1 parent ca9ab28 commit 1b4db05

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

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

57
## [5.2.4]
68
### Changed

reportportal_client/logs/log_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, rp_url, session, api_version, launch_id, project_name,
6969

7070
self._log_endpoint = (
7171
'{rp_url}/api/{version}/{project_name}/log'
72-
.format(rp_url=rp_url, version=self.api_version,
72+
.format(rp_url=rp_url.rstrip('/'), version=self.api_version,
7373
project_name=self.project_name))
7474

7575
def _send_batch(self):

tests/logs/test_log_manager.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
MAX_LOG_BATCH_PAYLOAD_SIZE
2121

2222
RP_URL = 'http://docker.local:8080'
23-
API_VERSION = 'api/v2'
23+
API_VERSION = 'v2'
2424
TEST_LAUNCH_ID = 'test_launch_id'
2525
TEST_ITEM_ID = 'test_item_id'
2626
PROJECT_NAME = 'test_project'
@@ -52,6 +52,26 @@ def test_log_batch_send_by_length():
5252
assert log_manager._payload_size == helpers.TYPICAL_MULTIPART_FOOTER_LENGTH
5353

5454

55+
# noinspection PyUnresolvedReferences
56+
def test_log_batch_send_url_format():
57+
session = mock.Mock()
58+
log_manager = LogManager(RP_URL + '/', session, API_VERSION,
59+
TEST_LAUNCH_ID,
60+
PROJECT_NAME, max_entry_number=TEST_BATCH_SIZE,
61+
verify_ssl=False)
62+
log_manager._worker = mock.Mock()
63+
64+
for _ in range(TEST_BATCH_SIZE):
65+
log_manager.log(helpers.timestamp(), TEST_MASSAGE, TEST_LEVEL,
66+
item_id=TEST_ITEM_ID)
67+
68+
assert log_manager._worker.send.call_count == 1
69+
batch = log_manager._worker.send.call_args[0][0]
70+
assert batch.http_request is not None
71+
assert batch.http_request.url == \
72+
RP_URL + '/api/' + API_VERSION + '/' + PROJECT_NAME + '/log'
73+
74+
5575
# noinspection PyUnresolvedReferences
5676
def test_log_batch_not_send_by_length():
5777
session = mock.Mock()

0 commit comments

Comments
 (0)