Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
frankwiles committed Sep 6, 2012
1 parent 2896cce commit 756459e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 4 additions & 3 deletions app_metrics/tasks.py
Expand Up @@ -31,7 +31,8 @@
# For librato support
try:
import librato
from librato.metrics import Gauge, Counter
from librato.metrics import Gauge as LibratoGauge
from librato.metrics import Counter as LibratoCounter
except ImportError:
librato = None

Expand Down Expand Up @@ -178,8 +179,8 @@ def librato_metric_task(name, num, attributes=None, metric_type="gauge",
settings.APP_METRICS_LIBRATO_TOKEN)

if metric_type == "counter":
metric = Counter(connection, name, attributes=attributes)
metric = LibratoCounter(connection, name, attributes=attributes)
else:
metric = Gauge(connection, name, attributes=attributes)
metric = LibratoGauge(connection, name, attributes=attributes)

metric.add(num, source=settings.APP_METRICS_LIBRATO_SOURCE)
7 changes: 6 additions & 1 deletion app_metrics/tests/base_tests.py
Expand Up @@ -113,9 +113,10 @@ def setUp(self):

def test_disabled(self):
self.assertEqual(MetricItem.objects.filter(metric__slug='test_disable').count(), 0)
settings.APP_METRICS_DISABLE = True
settings.APP_METRICS_DISABLED = True
metric('test_disable')
self.assertEqual(MetricItem.objects.filter(metric__slug='test_disable').count(), 0)
self.assertTrue(collection_disabled())

def tearDown(self):
settings.APP_METRICS_DISABLED = self.old_disabled
Expand Down Expand Up @@ -256,6 +257,10 @@ def test_existing_gauge(self):
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_new_gauge(self):
gauge('test_trend1', Decimal('12.373'))
self.assertEqual(Gauge.objects.all().count(), 2)
Expand Down
11 changes: 5 additions & 6 deletions app_metrics/tests/settings.py
@@ -1,9 +1,6 @@
import os

import django
import djcelery

djcelery.setup_loader()

BASE_PATH = os.path.dirname(__file__)

Expand All @@ -22,13 +19,15 @@

DEBUG = True

#TEST_RUNNER = 'django_coverage.coverage_runner.CoverageRunner'
TEST_RUNNER = 'django_coverage.coverage_runner.CoverageRunner'

COVERAGE_MODULE_EXCLUDES = [
'tests$', 'settings$', 'urls$',
'common.views.test', '__init__', 'django',
'migrations', 'djcelery']
#COVERAGE_REPORT_HTML_OUTPUT_DIR = os.path.join(BASE_PATH, 'coverage')
'migrations', 'djcelery'
]

COVERAGE_REPORT_HTML_OUTPUT_DIR = os.path.join(BASE_PATH, 'coverage')

INSTALLED_APPS = [
'django.contrib.admin',
Expand Down

0 comments on commit 756459e

Please sign in to comment.