Exemplo n.º 1
0
    def test_gauge(self):
        with mock.patch('redis.client.StrictRedis') as mock_client:
            instance = mock_client.return_value
            instance._send.return_value = 1

            gauge('testing', 10.5)
            mock_client._send.asert_called_with(mock.ANY, {'slug':'testing', 'current_value':'10.5'})
Exemplo n.º 2
0
    def test_gauge(self):
        with mock.patch('redis.client.StrictRedis') as mock_client:
            instance = mock_client.return_value
            instance._send.return_value = 1

            gauge('testing', 10.5)
            mock_client._send.asert_called_with(mock.ANY, {
                'slug': 'testing',
                'current_value': '10.5'
            })
Exemplo n.º 3
0
    def test_existing_gauge(self):
        self.assertEqual(Gauge.objects.all().count(), 1)
        self.assertEqual(Gauge.objects.get(slug='testing').current_value, Decimal('0.00'))
        gauge('testing', '10.5')

        # We should not have created a new gauge
        self.assertEqual(Gauge.objects.all().count(), 1)
        self.assertEqual(Gauge.objects.get(slug='testing').current_value, Decimal('10.5'))

        # Test updating
        gauge('testing', '11.1')
        self.assertEqual(Gauge.objects.get(slug='testing').current_value, Decimal('11.1'))
Exemplo n.º 4
0
    def test_gauge(self):
        with mock.patch('statsd.Client') as mock_client:
            instance = mock_client.return_value
            instance._send.return_value = 1

            gauge('testing', 10.5)
            mock_client._send.assert_called_with(mock.ANY, {'testing': '10.5|g'})

            gauge('testing', Decimal('6.576'))
            mock_client._send.assert_called_with(mock.ANY, {'testing': '6.576|g'})

            gauge('another', 1)
            mock_client._send.assert_called_with(mock.ANY, {'another': '1|g'})
Exemplo n.º 5
0
    def test_gauge(self):
        with mock.patch('statsd.Client') as mock_client:
            instance = mock_client.return_value
            instance._send.return_value = 1

            gauge('testing', 10.5)
            mock_client._send.assert_called_with(mock.ANY, {'testing': '10.5|g'})

            gauge('testing', Decimal('6.576'))
            mock_client._send.assert_called_with(mock.ANY, {'testing': '6.576|g'})

            gauge('another', 1)
            mock_client._send.assert_called_with(mock.ANY, {'another': '1|g'})
Exemplo n.º 6
0
 def test_new_gauge(self):
     gauge('test_trend1', Decimal('12.373'))
     self.assertEqual(Gauge.objects.all().count(), 2)
     self.assertTrue('test_trend1' in list(Gauge.objects.all().values_list('slug', flat=True)))
     self.assertEqual(Gauge.objects.get(slug='test_trend1').current_value, Decimal('12.373'))