def test_receive(self): with mock_zmq() as zmq_mock: topics = ('test', ) publisher_address = 'tcp://localhost:48641' subscriber = pubsub.Subscriber( publishers=(publisher_address, ), topics=topics ) message = messages.JSON(topic=topics[0], data='test') zmq_mock.recv.return_value = message.serialize() subscriber.receive()
def test_receive(self): with mock_zmq() as zmq_mock: topics = ('test', ) publisher_to_forward_address = 'tcp://localhost:48642' forwarder = pubsub.Publisher(port='tcp://*:48643') subscriber = pubsub.MessageForwarder( publisher=forwarder, publishers=(publisher_to_forward_address, ), topics=topics ) message = messages.JSON(topic=topics[0], data='test') zmq_mock.recv.return_value = message.serialize() subscriber.receive()
def test_request(self): with mock_zmq() as zmq_mock: message = messages.JSON(data='test') zmq_mock.recv.return_value = message.serialize() clientserver.Client(servers=self.servers).request(self.message)
def test_respond(self): with mock_zmq(): clientserver.Server(port=self.port.format(48650)).respond( self.message)
def test_receive(self): with mock_zmq() as zmq_mock: zmq_mock.recv.return_value = self.message.serialize() clientserver.Server(port=self.port.format(48651)).receive()