Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Oct 11, 2023
1 parent 25b816b commit 85d187a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
4 changes: 1 addition & 3 deletions reportportal_client/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ async def get_launch_ui_url(self, launch_uuid_future: Union[str, Task[str]]) ->

launch_type = 'launches' if mode.upper() == 'DEFAULT' else 'userdebug'

path = 'ui/#{project_name}/{launch_type}/all/{launch_id}'.format(
project_name=self.project.lower(), launch_type=launch_type,
launch_id=launch_id)
path = f'ui/#{self.project.lower()}/{launch_type}/all/{launch_id}'
url = uri_join(self.endpoint, path)
logger.debug('get_launch_ui_url - ID: %s', launch_uuid)
return url
Expand Down
36 changes: 36 additions & 0 deletions tests/aio/test_aio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,3 +736,39 @@ async def test_update_item(aio_client: Client):
assert actual_json is not None
actual_attributes = actual_json.get('attributes')
verify_attributes(attributes, actual_attributes)


@pytest.mark.skipif(sys.version_info < (3, 8),
reason='the test requires AsyncMock which was introduced in Python 3.8')
@pytest.mark.asyncio
async def test_get_item_id_by_uuid(aio_client: Client):
# noinspection PyTypeChecker
session: mock.AsyncMock = await aio_client.session()
mock_basic_get_response(session)

item_id = 'test_item_uuid'
expected_uri = f'/api/v1/project/item/uuid/{item_id}'

result = await aio_client.get_item_id_by_uuid(item_id)
assert result == GET_RESPONSE_ID
session.get.assert_called_once()
call_args = session.get.call_args_list[0]
assert expected_uri == call_args[0][0]


@pytest.mark.skipif(sys.version_info < (3, 8),
reason='the test requires AsyncMock which was introduced in Python 3.8')
@pytest.mark.asyncio
async def test_get_launch_ui_url(aio_client: Client):
# noinspection PyTypeChecker
session: mock.AsyncMock = await aio_client.session()
mock_basic_get_response(session)

launch_id = 'test_launch_uuid'
expected_uri = f'/api/v1/project/launch/uuid/{launch_id}'

result = await aio_client.get_launch_ui_url(launch_id)
assert result == f'http://endpoint/ui/#project/launches/all/{GET_RESPONSE_ID}'
session.get.assert_called_once()
call_args = session.get.call_args_list[0]
assert expected_uri == call_args[0][0]

0 comments on commit 85d187a

Please sign in to comment.