Skip to content

Commit

Permalink
A try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Oct 10, 2023
1 parent 1e1a206 commit 27a2042
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions tests/aio/test_aio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,15 @@ async def test_start_launch(aio_client: Client):
verify_attributes(attributes, actual_attributes)


if sys.version_info >= (3, 8):
ASYNC_STAT_MOCK = mock.AsyncMock()
else:
ASYNC_STAT_MOCK = None


@pytest.mark.skipif(sys.version_info < (3, 8),
reason="the test requires AsyncMock which was introduced in Python 3.8")
@mock.patch('reportportal_client.aio.client.async_send_event', ASYNC_STAT_MOCK)
@mock.patch('reportportal_client.aio.client.async_send_event')
@pytest.mark.asyncio
async def test_start_launch_event_send():
async def test_start_launch_event_send(async_send_event):
# noinspection PyTypeChecker
session = mock.AsyncMock()
client = Client('http://endpoint', 'project', api_key='api_key')
client._skip_analytics = False
client._session = session
mock_basic_post_response(session)

Expand All @@ -304,12 +299,8 @@ async def test_start_launch_event_send():
agent_version = '5.0.4'
attributes = {'agent': f'{agent_name}|{agent_version}'}
await client.start_launch(launch_name, start_time, attributes=attributes)
# noinspection PyUnresolvedReferences
stat_task = client._Client__stat_task
assert stat_task is not None
await stat_task
ASYNC_STAT_MOCK.assert_called_once()
call_args = ASYNC_STAT_MOCK.call_args_list[0]
async_send_event.assert_called_once()
call_args = async_send_event.call_args_list[0]
args = call_args[0]
kwargs = call_args[1]
assert len(args) == 3
Expand Down

0 comments on commit 27a2042

Please sign in to comment.