Skip to content

Commit fe78a2e

Browse files
author
Dmitriy Gumeniuk
authored
Merge pull request #98 from iivanou/duplicate_agent_name
Remove duplicate agent name returned by the get_system_information()
2 parents 85bf231 + 1cbc01b commit fe78a2e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

reportportal_client/service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ def get_system_information(agent_name='agent_name'):
475475
'machine': "Windows10_pc"}
476476
"""
477477
try:
478-
agent_version = pkg_resources.get_distribution(agent_name)
478+
agent_version = pkg_resources.get_distribution(
479+
agent_name).version
479480
agent = '{0}-{1}'.format(agent_name, agent_version)
480481
except pkg_resources.DistributionNotFound:
481482
agent = 'not found'

tests/test_service.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,23 @@ def test_finish_launch(self, mock_get, rp_service):
8383
:param rp_service: Pytest fixture
8484
"""
8585
mock_get.return_value = {"id": 111}
86-
_get_msg = rp_service.finish_launch('name', datetime.now().isoformat())
86+
_get_msg = rp_service.finish_launch(
87+
'name', datetime.now().isoformat())
8788
assert _get_msg == {"id": 111}
8889

8990
@mock.patch('platform.system', mock.Mock(return_value='linux'))
9091
@mock.patch('platform.machine', mock.Mock(return_value='Windows-PC'))
9192
@mock.patch('platform.processor', mock.Mock(return_value='amd'))
92-
@mock.patch('pkg_resources.get_distribution',
93-
mock.Mock(return_value='pytest 5.0'))
94-
def test_get_system_information(self):
93+
@mock.patch('pkg_resources.get_distribution')
94+
def test_get_system_information(self, distro):
9595
"""Test for validate get_system_information."""
96-
97-
expected_result = {'agent': 'pytest-pytest 5.0',
96+
distro.return_value.version = '5.0'
97+
expected_result = {'agent': 'reportportal-client-5.0',
9898
'cpu': 'amd',
9999
'machine': 'Windows-PC',
100100
'os': 'linux'}
101-
102-
cond = (ReportPortalService.get_system_information('pytest')
103-
== expected_result)
101+
cond = (ReportPortalService.get_system_information(
102+
'reportportal-client') == expected_result)
104103
assert cond
105104

106105
@mock.patch('platform.system', mock.Mock())

0 commit comments

Comments
 (0)