Skip to content

Commit

Permalink
fixup! Move channel creation with dispersy function to more general c…
Browse files Browse the repository at this point in the history
…lass
  • Loading branch information
ardhipoetra committed Nov 30, 2016
1 parent 686fc30 commit abc7894
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
4 changes: 1 addition & 3 deletions Tribler/Test/Core/CreditMining/test_creditmining_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def __init__(self, *argv, **kwargs):

@blocking_call_on_reactor_thread
@inlineCallbacks
def setUp(self, autoload_discovery=True):
def setUp(self, annotate=True, autoload_discovery=True):
yield super(TestBoostingManagerSysChannel, self).setUp()
self.channel_db_handler = self.session.open_dbhandler(NTFY_CHANNELCAST)
self.channel_db_handler._get_my_dispersy_cid = lambda: "myfakedispersyid"
Expand Down Expand Up @@ -537,6 +537,4 @@ def check_torrents_channel(src, defer_param=None):
@inlineCallbacks
def tearDown(self):
self.session.lm.dispersy._communities['allchannel'].cancel_all_pending_tasks()
self.session.lm.dispersy.cancel_all_pending_tasks()
self.session.lm.dispersy = None
yield super(TestBoostingManagerSysChannel, self).tearDown()
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from Tribler.Core.exceptions import DuplicateChannelNameError
from Tribler.Core.simpledefs import NTFY_CHANNELCAST, NTFY_VOTECAST
from Tribler.Test.Core.Modules.RestApi.base_api_test import AbstractApiTest
from Tribler.Test.Core.base_test_channel import BaseTestChannel


class ChannelCommunityMock(object):
Expand All @@ -30,7 +31,7 @@ def get_channel_mode(self):
return self._channel_mode


class AbstractTestChannelsEndpoint(AbstractApiTest):
class AbstractTestChannelsEndpoint(AbstractApiTest, BaseTestChannel):

def setUp(self, autoload_discovery=True):
super(AbstractTestChannelsEndpoint, self).setUp(autoload_discovery)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ def on_dispersy_create_votecast(self, cid, vote, _):
return succeed(None)


@blocking_call_on_reactor_thread
@inlineCallbacks
def tearDown(self, annotate=True):
self.session.lm.dispersy = None
yield super(TestChannelsSubscriptionEndpoint, self).tearDown(annotate=annotate)

@deferred(timeout=10)
def test_subscribe_channel_already_subscribed(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions Tribler/Test/Core/Modules/RestApi/base_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from Tribler.Core.Utilities.network_utils import get_random_port
from Tribler.Core.Utilities.twisted_thread import reactor
from Tribler.Core.version import version_id
from Tribler.Test.Core.base_test_channel import BaseTestChannel
from Tribler.Test.test_as_server import TestAsServer
from Tribler.dispersy.util import blocking_call_on_reactor_thread


Expand All @@ -34,7 +34,7 @@ def startProducing(self, consumer):
return succeed(None)


class AbstractBaseApiTest(BaseTestChannel):
class AbstractBaseApiTest(TestAsServer):
"""
Tests for the Tribler HTTP API should create a subclass of this class.
"""
Expand Down
10 changes: 8 additions & 2 deletions Tribler/Test/Core/base_test_channel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from twisted.internet.defer import inlineCallbacks

from Tribler.Core.simpledefs import NTFY_CHANNELCAST
from Tribler.Core.simpledefs import NTFY_VOTECAST
from Tribler.Test.Core.base_test import MockObject
Expand All @@ -11,11 +13,13 @@

class BaseTestChannel(TestAsServer):

@blocking_call_on_reactor_thread
@inlineCallbacks
def setUp(self, annotate=True, autoload_discovery=True):
"""
Setup some classes and files that are used by the tests in this module.
"""
super(BaseTestChannel, self).setUp(autoload_discovery=autoload_discovery)
yield super(BaseTestChannel, self).setUp(autoload_discovery=autoload_discovery)

if annotate:
self.annotate(self._testMethodName, start=True)
Expand Down Expand Up @@ -63,7 +67,9 @@ def create_fake_allchannel_community(self):
self.session.lm.dispersy._communities = {"allchannel": fake_community}
return fake_community

@blocking_call_on_reactor_thread
@inlineCallbacks
def tearDown(self, annotate=True):
self.session.lm.dispersy.cancel_all_pending_tasks()
self.session.lm.dispersy = None
super(BaseTestChannel, self).tearDown()
yield super(BaseTestChannel, self).tearDown()

0 comments on commit abc7894

Please sign in to comment.