Exemplo n.º 1
0
    def setUp(self):
        yield CommandsBaseTestCase.setUp(self)

        class TestSubscriber(RedisSubscriber):
            def __init__(self, *args, **kwargs):
                RedisSubscriber.__init__(self, *args, **kwargs)
                self.msg_channel = None
                self.msg_message = None
                self.msg_received = defer.Deferred()
                self.channel_subscribed = defer.Deferred()

            def messageReceived(self, channel, message):
                self.msg_channel = channel
                self.msg_message = message
                self.msg_received.callback(None)
                self.msg_received = defer.Deferred()

            def channelSubscribed(self, channel, numSubscriptions):
                self.channel_subscribed.callback(None)
                self.channel_subscribed = defer.Deferred()

            channelUnsubscribed = channelSubscribed
            channelPatternSubscribed = channelSubscribed
            channelPatternUnsubscribed = channelSubscribed

        clientCreator = protocol.ClientCreator(reactor, TestSubscriber)
        self.subscriber = yield clientCreator.connectTCP(
            REDIS_HOST, REDIS_PORT)
Exemplo n.º 2
0
    def setUp(self):
        yield CommandsBaseTestCase.setUp(self)

        class TestSubscriber(RedisSubscriber):
            def __init__(self, *args, **kwargs):
                RedisSubscriber.__init__(self, *args, **kwargs)
                self.msg_channel = None
                self.msg_message = None
                self.msg_received = defer.Deferred()
                self.channel_subscribed = defer.Deferred()

            def messageReceived(self, channel, message):
                self.msg_channel = channel
                self.msg_message = message
                self.msg_received.callback(None)
                self.msg_received = defer.Deferred()

            def channelSubscribed(self, channel, numSubscriptions):
                self.channel_subscribed.callback(None)
                self.channel_subscribed = defer.Deferred()

            channelUnsubscribed = channelSubscribed
            channelPatternSubscribed = channelSubscribed
            channelPatternUnsubscribed = channelSubscribed

        clientCreator = protocol.ClientCreator(reactor, TestSubscriber)
        self.subscriber = yield clientCreator.connectTCP(REDIS_HOST, REDIS_PORT)
Exemplo n.º 3
0
 def setUp(self):
     yield CommandsBaseTestCase.setUp(self)
     if ScriptingCommandsTestCase._skipped:
         self.redis.transport.loseConnection()
         raise SkipTest(ScriptingCommandsTestCase._skipped)
     info = yield self.redis.info()
     if 'used_memory_lua' not in info:
         ScriptingCommandsTestCase._skipped = (
             'Scripting commands not available in Redis version %s' %
             info['redis_version'])
         self.redis.transport.loseConnection()
         raise SkipTest(ScriptingCommandsTestCase._skipped)
Exemplo n.º 4
0
 def setUp(self):
     d = CommandsBaseTestCase.setUp(self)
     def do_setup(_res):
         self.factory = RedisClientFactory()
         reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
         d = self.factory.deferred
         def cannot_connect(_res):
             raise unittest.SkipTest('Cannot connect to Redis.')
         d.addErrback(cannot_connect)
         return d
     d.addCallback(do_setup)
     return d
Exemplo n.º 5
0
 def setUp(self):
     yield CommandsBaseTestCase.setUp(self)
     if ScriptingCommandsTestCase._skipped:
         self.redis.transport.loseConnection()
         raise SkipTest(ScriptingCommandsTestCase._skipped)
     info = yield self.redis.info()
     if 'used_memory_lua' not in info:
         ScriptingCommandsTestCase._skipped = (
             'Scripting commands not available in Redis version %s' %
             info['redis_version'])
         self.redis.transport.loseConnection()
         raise SkipTest(ScriptingCommandsTestCase._skipped)
Exemplo n.º 6
0
    def setUp(self):
        d = CommandsBaseTestCase.setUp(self)

        def do_setup(_res):
            self.factory = RedisClientFactory()
            reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
            d = self.factory.deferred

            def cannot_connect(_res):
                raise unittest.SkipTest('Cannot connect to Redis.')

            d.addErrback(cannot_connect)
            return d

        d.addCallback(do_setup)
        return d