~nataliabidart/magicicada-server/update-copyright-notices

« back to all changes in this revision

Viewing changes to magicicada/metrics/tests/test_services.py

  • Committer: Magicicada Bot
  • Author(s): Natalia
  • Date: 2016-08-29 13:23:33 UTC
  • mfrom: (61.4.7 remove-oopses)
  • Revision ID: magicicada_bot-20160829132333-bthfd9mixede1lyw
[r=facundo] - No more oopses code nor oopses setups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from testtools import TestCase
25
25
 
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
28
28
 
29
29
 
30
30
class ServicesTest(TestCase):
31
31
    """Tests for metric services."""
32
32
 
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')
39
 
 
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')
46
 
 
47
 
    def test_oops_saved_with_no_report(self):
48
 
        """oops_saved returns an empty list with no report."""
49
 
        self.assertEqual([], oops_saved())
50
 
 
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()))
54
 
 
55
 
    def test_oops_saved_with_report_with_id(self):
56
 
        """oops_saved returns a non-empty list with an id in the report."""
57
 
        the_id = 'an id'
58
 
        self.assertEqual([the_id], oops_saved(report=dict(id=the_id)))
59
 
 
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')