24
24
from testtools import TestCase
26
26
from metrics import get_meter
27
from metrics.services import oops_saved, revno, version_info
27
from metrics.services import revno, version_info
30
30
class ServicesTest(TestCase):
31
31
"""Tests for metric services."""
33
def test_meters_oops_passing_a_report(self):
34
"""The service is able to meter an oops passing a report."""
35
service_meter = get_meter('service')
36
with patch.object(service_meter, 'meter') as meter:
37
oops_saved(report=dict())
38
meter.assert_called_with('oops_saved')
40
def test_meters_oops_passing_a_context(self):
41
"""The service is able to meter an oops passing a context."""
42
service_meter = get_meter('service')
43
with patch.object(service_meter, 'meter') as meter:
44
oops_saved(context='some oops context')
45
meter.assert_called_with('oops_saved')
47
def test_oops_saved_with_no_report(self):
48
"""oops_saved returns an empty list with no report."""
49
self.assertEqual([], oops_saved())
51
def test_oops_saved_with_report_with_no_id(self):
52
"""oops_saved returns an empty list with no id in the report."""
53
self.assertEqual([], oops_saved(report=dict()))
55
def test_oops_saved_with_report_with_id(self):
56
"""oops_saved returns a non-empty list with an id in the report."""
58
self.assertEqual([the_id], oops_saved(report=dict(id=the_id)))
60
33
def test_meters_revno_with_gauge_meter(self):
61
34
"""The service is able to meter a revision by gauge meter."""
62
35
service_meter = get_meter('service')