diff --git a/src/tribler/core/components/gigachannel/community/tests/test_gigachannel_community.py b/src/tribler/core/components/gigachannel/community/tests/test_gigachannel_community.py index 77005b527a0..2e055dc03f2 100644 --- a/src/tribler/core/components/gigachannel/community/tests/test_gigachannel_community.py +++ b/src/tribler/core/components/gigachannel/community/tests/test_gigachannel_community.py @@ -2,14 +2,12 @@ from datetime import datetime from unittest.mock import AsyncMock, Mock, PropertyMock, patch +import pytest from ipv8.keyvault.crypto import default_eccrypto from ipv8.peer import Peer from ipv8.test.base import TestBase - from pony.orm import db_session -import pytest - from tribler.core.components.gigachannel.community.gigachannel_community import ( ChannelsPeersMapping, GigaChannelCommunity, @@ -17,6 +15,7 @@ ) from tribler.core.components.gigachannel.community.settings import ChantSettings from tribler.core.components.metadata_store.db.store import MetadataStore +from tribler.core.components.metadata_store.remote_query_community.remote_query_community import EvaSelectRequest from tribler.core.components.metadata_store.remote_query_community.settings import RemoteQueryCommunitySettings from tribler.core.components.metadata_store.utils import RequestTimeoutException from tribler.core.utilities.notifier import Notifier @@ -348,13 +347,12 @@ async def test_remote_select_channel_contents_empty(self): kwargs["origin_id"] = 333 assert [] == await client.remote_select_channel_contents(**kwargs) + @patch.object(EvaSelectRequest, 'timeout_delay', new=PropertyMock(return_value=0.1)) async def test_remote_select_channel_timeout(self): client, server, kwargs = self.client_server_request_setup() server.send_db_results = Mock() - with patch(f'{BASE_PATH}.EvaSelectRequest.timeout_delay', new_callable=PropertyMock) as zz: - zz.return_value = 2.0 - with pytest.raises(RequestTimeoutException): - await client.remote_select_channel_contents(**kwargs) + with pytest.raises(RequestTimeoutException): + await client.remote_select_channel_contents(**kwargs) async def test_remote_select_channel_no_peers(self): client, _, kwargs = self.client_server_request_setup() @@ -362,6 +360,7 @@ async def test_remote_select_channel_no_peers(self): with pytest.raises(NoChannelSourcesException): await client.remote_select_channel_contents(**kwargs) + @patch.object(EvaSelectRequest, 'timeout_delay', new=PropertyMock(return_value=10)) async def test_remote_select_channel_contents_happy_eyeballs(self): """ Test trying to connect to the first server, then timing out and falling back to the second one