Skip to content

Commit

Permalink
Extract tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed Sep 28, 2021
1 parent 300c0f1 commit 7c720be
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from unittest.mock import patch

from tribler_core.components.base import Session
from tribler_core.components.gigachannel_manager.gigachannel_manager_component import GigachannelManagerComponent
from tribler_core.components.libtorrent import LibtorrentComponent
from tribler_core.components.masterkey import MasterKeyComponent
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.components.restapi import RESTComponent
from tribler_core.components.socks_configurator import SocksServersComponent
# pylint: disable=protected-access
from tribler_core.restapi.rest_manager import RESTManager


async def test_gigachannel_manager_component(tribler_config):
components = [SocksServersComponent(), MasterKeyComponent(), RESTComponent(), MetadataStoreComponent(),
LibtorrentComponent(), GigachannelManagerComponent()]
session = Session(tribler_config, components)
with session:
comp = GigachannelManagerComponent.instance()
with patch.object(RESTManager, 'get_endpoint'):
await session.start()

assert comp.gigachannel_manager
assert comp._rest_manager

await session.shutdown()
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from unittest.mock import patch

from tribler_core.components.base import Session
from tribler_core.components.masterkey import MasterKeyComponent
from tribler_core.components.metadata_store.metadata_store_component import MetadataStoreComponent
from tribler_core.components.restapi import RESTComponent
from tribler_core.restapi.rest_manager import RESTManager


# pylint: disable=protected-access

async def test_metadata_store_component(tribler_config):
components = [MasterKeyComponent(), RESTComponent(), MetadataStoreComponent()]
session = Session(tribler_config, components)
with session:
comp = MetadataStoreComponent.instance()
with patch.object(RESTManager, 'get_endpoint'):
await session.start()

assert comp.mds
assert comp._rest_manager

await session.shutdown()
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from tribler_core.components.bandwidth_accounting.bandwidth_accounting_component import BandwidthAccountingComponent
from tribler_core.components.base import Session, SessionError
from tribler_core.components.gigachannel import GigaChannelComponent
from tribler_core.components.gigachannel_manager.gigachannel_manager_component import GigachannelManagerComponent
from tribler_core.components.ipv8 import Ipv8Component
from tribler_core.components.libtorrent import LibtorrentComponent
from tribler_core.components.masterkey import MasterKeyComponent
Expand All @@ -25,6 +24,7 @@

pytestmark = pytest.mark.asyncio


# pylint: disable=protected-access

def test_session_context_manager(loop, tribler_config):
Expand Down Expand Up @@ -62,8 +62,6 @@ async def test_masterkey_component(tribler_config):
await session.shutdown()




async def test_giga_channel_component(tribler_config):
components = [MetadataStoreComponent(), RESTComponent(), MasterKeyComponent(), Ipv8Component(),
GigaChannelComponent()]
Expand All @@ -80,21 +78,6 @@ async def test_giga_channel_component(tribler_config):
await session.shutdown()


async def test_gigachannel_manager_component(tribler_config):
components = [SocksServersComponent(), MasterKeyComponent(), RESTComponent(), MetadataStoreComponent(),
LibtorrentComponent(), GigachannelManagerComponent()]
session = Session(tribler_config, components)
with session:
comp = GigachannelManagerComponent.instance()
with patch.object(RESTManager, 'get_endpoint'):
await session.start()

assert comp.gigachannel_manager
assert comp._rest_manager

await session.shutdown()


async def test_ipv8_component(tribler_config):
components = [MasterKeyComponent(), RESTComponent(), Ipv8Component()]
session = Session(tribler_config, components)
Expand Down Expand Up @@ -127,20 +110,6 @@ async def test_libtorrent_component(tribler_config):
await session.shutdown()


async def test_metadata_store_component(tribler_config):
components = [MasterKeyComponent(), RESTComponent(), MetadataStoreComponent()]
session = Session(tribler_config, components)
with session:
comp = MetadataStoreComponent.instance()
with patch.object(RESTManager, 'get_endpoint'):
await session.start()

assert comp.mds
assert comp._rest_manager

await session.shutdown()


async def test_payout_component(tribler_config):
components = [BandwidthAccountingComponent(), MasterKeyComponent(), RESTComponent(), Ipv8Component(),
PayoutComponent()]
Expand Down

0 comments on commit 7c720be

Please sign in to comment.