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'})
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' })
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'))
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'})
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'))