示例#1
0
 def test_socket_sendto_logs_exception(self):
     with mock.patch('socket.socket.sendto') as sendto:
         with mock.patch('sprockets.clients.statsd.LOGGER') as LOGGER:
             sendto.side_effect = socket.error
             LOGGER.exception = mock.Mock()
             statsd._send('foo.bar.baz', 2, 'c')
             LOGGER.exception.assert_called_once_with(statsd.SOCKET_ERROR)
 def test_socket_sendto_logs_exception(self):
     with mock.patch('socket.socket.sendto') as sendto:
         with mock.patch('sprockets.clients.statsd.LOGGER') as LOGGER:
             sendto.side_effect = socket.error
             LOGGER.exception = mock.Mock()
             statsd._send('foo.bar.baz', 2, 'c')
             LOGGER.exception.assert_called_once_with(statsd.SOCKET_ERROR)
    def test_statsd_url_format(self):
        os.environ['STATSD'] = 'udp://statsd.service:8675'
        statsd.set_address()

        with mock.patch('socket.socket.sendto') as sendto:
            statsd._send('foo.bar.baz', 2, 'c')
            sendto.assert_called_once_with(b'sprockets.foo.bar.baz:2|c',
                                           ('statsd.service', 8675))

        del os.environ['STATSD']
        statsd.set_address()
示例#4
0
 def test_socket_sendto_is_invoked(self):
     with mock.patch('socket.socket.sendto') as sendto:
         statsd._send('foo.bar.baz', 2, 'c')
         sendto.assert_called_once_with(b'foo.bar.baz:2|c',
                                        ('localhost', 8125))
 def test_socket_sendto_is_invoked(self):
     with mock.patch('socket.socket.sendto') as sendto:
         statsd._send('foo.bar.baz', 2, 'c')
         sendto.assert_called_once_with(b'sprockets.foo.bar.baz:2|c',
                                        ('localhost', 8125))