Exemplo n.º 1
0
    def test_subscribe_success(self):
        def checkSubscribe(ignored):
            self.assertEqual(self.factory.testMessage, "Fake success!")

        def checkConnect(client):
            self.assertEqual(self.factory.testMessage, "")
            d = client.subscribe("tag")
            d.addCallback(checkSubscribe)

        s = ZmqSubConnection(
            ZmqEndpoint(ZmqEndpointType.connect, "tcp://127.0.0.1:5556"))
        self.patchSocket(TestSocketSuccess, s)
        d = s.connect(self.factory)
        d.addCallback(checkConnect)
        return d
Exemplo n.º 2
0
    def test_subscribe_fail(self):
        def checkSubscribe(error):
            self.assertEqual(str(error), "exceptions.Exception: ohnoz!")

        def checkConnect(client):
            self.assertEqual(self.factory.testMessage, "")
            failure = client.subscribe("tag")
            d = self.assertFailure(failure, exceptions.SubscribingError)
            d.addCallback(checkSubscribe)

        s = ZmqSubConnection(
            ZmqEndpoint(ZmqEndpointType.connect, "tcp://127.0.0.1:5556"))
        self.patchSocket(TestSocketFailure, s)
        d = s.connect(self.factory)
        d.addCallback(checkConnect)
        return d
Exemplo n.º 3
0
    def test_subscribe_success(self):

        def checkSubscribe(ignored):
            self.assertEqual(self.factory.testMessage, "Fake success!")

        def checkConnect(client):
            self.assertEqual(self.factory.testMessage, "")
            d = client.subscribe("tag")
            d.addCallback(checkSubscribe)

        s = ZmqSubConnection(
            ZmqEndpoint(ZmqEndpointType.connect, "tcp://127.0.0.1:5556"))
        self.patchSocket(TestSocketSuccess, s)
        d = s.connect(self.factory)
        d.addCallback(checkConnect)
        return d
Exemplo n.º 4
0
    def test_unsubscribe_fail(self):

        def checkUnsubscribe(error):
            self.assertEqual(str(error), "exceptions.Exception: ohnoz!")

        def checkConnect(client):
            self.assertEqual(self.factory.testMessage, "")
            failure = client.unsubscribe(None)
            d = self.assertFailure(failure, exceptions.UnsubscribingError)
            d.addCallback(checkUnsubscribe)

        s = ZmqSubConnection(
            ZmqEndpoint(ZmqEndpointType.connect, "tcp://127.0.0.1:5556"))
        self.patchSocket(TestSocketFailure, s)
        d = s.connect(self.factory)
        d.addCallback(checkConnect)
        return d
Exemplo n.º 5
0
 def messageReceived(self, *a, **kw):
     return ZmqSubConnection.messageReceived(self, *a, **kw)
Exemplo n.º 6
0
 def __init__(self, plugin, factory, endpoint):
     ZmqSubConnection.__init__(self, factory, endpoint)
     self.plugin = plugin
Exemplo n.º 7
0
 def messageReceived(self, *a, **kw):
     return ZmqSubConnection.messageReceived(self, *a, **kw)
Exemplo n.º 8
0
 def __init__(self, plugin, factory, endpoint):
     ZmqSubConnection.__init__(self, factory, endpoint)
     self.plugin = plugin