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
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
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
def messageReceived(self, *a, **kw): return ZmqSubConnection.messageReceived(self, *a, **kw)
def __init__(self, plugin, factory, endpoint): ZmqSubConnection.__init__(self, factory, endpoint) self.plugin = plugin