コード例 #1
0
    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()
コード例 #2
0
    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()
コード例 #3
0
    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)
コード例 #4
0
 def test_respond(self):
     with mock_zmq():
         clientserver.Server(port=self.port.format(48650)).respond(
             self.message)
コード例 #5
0
    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()