예제 #1
0
class TestAllChannelCommunity(AbstractTestCommunity):

    @inlineCallbacks
    def setUp(self):
        yield super(TestAllChannelCommunity, self).setUp()
        self.community = AllChannelCommunity(self.dispersy, self.master_member, self.member)
        self.dispersy._communities['a' * 20] = self.community
        self.community.initialize(auto_join_channel=True)

    @trial_timeout(10)
    def test_create_votecast(self):
        """
        Testing whether a votecast can be created in the community
        """
        def verify(message):
            self.assertTrue(isinstance(message, Message.Implementation))

        return self.community.disp_create_votecast("c" * 20, 2, 300).addCallback(verify)

    @trial_timeout(10)
    def test_unload_preview(self):
        """
        Test the unloading of the preview community
        """
        def verify_unloaded(_):
            self.assertEqual(len(self.dispersy.get_communities()), 1)

        preview_member = DummyMember(self.dispersy, 2, "c" * 20)
        preview_community = PreviewChannelCommunity(self.dispersy, preview_member, self.member)
        preview_community.initialize()
        preview_community.init_timestamp = -500
        self.dispersy._communities['c' * 20] = preview_community
        return self.community.unload_preview().addCallback(verify_unloaded)
예제 #2
0
class TestAllChannelCommunity(AbstractTestCommunity):

    @blocking_call_on_reactor_thread
    def setUp(self, annotate=True):
        super(TestAllChannelCommunity, self).setUp(annotate=annotate)
        self.community = AllChannelCommunity(self.dispersy, self.master_member, self.member)
        self.dispersy._communities['a' * 20] = self.community
        self.community.initialize(auto_join_channel=True)

    @deferred(timeout=10)
    def test_create_votecast(self):
        """
        Testing whether a votecast can be created in the community
        """
        def verify(message):
            self.assertTrue(isinstance(message, Message.Implementation))

        return self.community.disp_create_votecast("c" * 20, 2, 300).addCallback(verify)

    @deferred(timeout=10)
    def test_unload_preview(self):
        """
        Test the unloading of the preview community
        """
        def verify_unloaded(_):
            self.assertEqual(len(self.dispersy.get_communities()), 1)

        preview_member = DummyMember(self.dispersy, 2, "c" * 20)
        preview_community = PreviewChannelCommunity(self.dispersy, preview_member, self.member)
        preview_community.initialize()
        preview_community.init_timestamp = -500
        self.dispersy._communities['c' * 20] = preview_community
        return self.community.unload_preview().addCallback(verify_unloaded)
 def create_fake_allchannel_community(self):
     """
     This method creates a fake AllChannel community so we can check whether a request is made in the community
     when doing stuff with a channel.
     """
     self.session.lm.dispersy._database.open()
     fake_member = DummyMember(self.session.lm.dispersy, 1, "a" * 20)
     member = self.session.lm.dispersy.get_new_member(u"curve25519")
     fake_community = AllChannelCommunity(self.session.lm.dispersy,
                                          fake_member, member)
     fake_community.disp_create_votecast = self.on_dispersy_create_votecast
     self.session.lm.dispersy._communities = {"allchannel": fake_community}
예제 #4
0
 def setUp(self, annotate=True):
     super(TestAllChannelCommunity, self).setUp(annotate=annotate)
     self.community = AllChannelCommunity(self.dispersy, self.master_member,
                                          self.member)
     self.dispersy._communities['a' * 20] = self.community
     self.community.initialize(auto_join_channel=True)
예제 #5
0
 def setUp(self):
     yield super(TestAllChannelCommunity, self).setUp()
     self.community = AllChannelCommunity(self.dispersy, self.master_member, self.member)
     self.dispersy._communities['a' * 20] = self.community
     self.community.initialize(auto_join_channel=True)