コード例 #1
0
 def test_publish(self):
     publisher = StatsPublisher()
     publisher.socket = mock.MagicMock()
     stat = {'subtopic': 1, 'foo': 'bar'}
     publisher.publish('foobar', stat)
     publisher.socket.send_multipart.assert_called_with(
         ['stat.foobar.1', json.dumps(stat)])
コード例 #2
0
 def test_publish(self):
     publisher = StatsPublisher()
     publisher.socket = mock.MagicMock()
     stat = {'subtopic': 1, 'foo': 'bar'}
     publisher.publish('foobar', stat)
     publisher.socket.send_multipart.assert_called_with(
         ['stat.foobar.1', json.dumps(stat)])
コード例 #3
0
    def test_publish_silent_zmq_errors_when_socket_closed(self):
        publisher = StatsPublisher()
        publisher.socket = mock.MagicMock()
        publisher.socket.closed = True
        publisher.socket.send_multipart.side_effect = zmq.ZMQError()

        stat = {'subtopic': 1, 'foo': 'bar'}
        publisher.publish('foobar', stat)
コード例 #4
0
    def test_publish_reraise_zmq_errors(self):
        publisher = StatsPublisher()
        publisher.socket = mock.MagicMock()
        publisher.socket.closed = False
        publisher.socket.send_multipart.side_effect = zmq.ZMQError()

        stat = {'subtopic': 1, 'foo': 'bar'}
        self.assertRaises(zmq.ZMQError, publisher.publish, 'foobar', stat)
コード例 #5
0
    def test_publish_silent_zmq_errors_when_socket_closed(self):
        publisher = StatsPublisher()
        publisher.socket = mock.MagicMock()
        publisher.socket.closed = True
        publisher.socket.send_multipart.side_effect = zmq.ZMQError()

        stat = {'subtopic': 1, 'foo': 'bar'}
        publisher.publish('foobar', stat)
コード例 #6
0
    def test_publish_reraise_zmq_errors(self):
        publisher = StatsPublisher()
        publisher.socket = mock.MagicMock()
        publisher.socket.closed = False
        publisher.socket.send_multipart.side_effect = zmq.ZMQError()

        stat = {'subtopic': 1, 'foo': 'bar'}
        self.assertRaises(zmq.ZMQError, publisher.publish, 'foobar', stat)