def test_meters_oops_passing_a_context(self): """The service is able to meter an oops passing a context.""" service_meter = METER_UTILITY.get_service_meter() with patch.object(service_meter, 'meter', spec=NamespaceMeter) as meter: oops_saved(context='some oops context') meter.assert_called_with('oops_saved')
def test_meters_oops_with_normal_meter(self): """The service is able to meter an oops by normal meter.""" service_meter = METER_UTILITY.get_service_meter() with patch.object(service_meter, 'meter', spec=NamespaceMeter) as meter: oops_saved() meter.assert_called_with('oops_saved')
def test_meters_oops_passing_a_report(self): """The service is able to meter an oops passing a report.""" service_meter = METER_UTILITY.get_service_meter() with patch.object(service_meter, 'meter', spec=NamespaceMeter) as meter: oops_saved(report=dict()) meter.assert_called_with('oops_saved')
def test_meters_oops_by_service(self): """The service is able to meter an oops scoped to services.""" service_meter = METER_UTILITY.get_service_meter() with patch.object(METER_UTILITY, 'get_service_meter'): METER_UTILITY.get_service_meter.return_value = service_meter oops_saved() self.assertTrue(METER_UTILITY.get_service_meter.called)
def test_oops_saved_with_report_with_id(self): """oops_saved returns a non-empty list with an id in the report.""" service_meter = METER_UTILITY.get_service_meter() with patch.object(METER_UTILITY, 'get_service_meter'): METER_UTILITY.get_service_meter.return_value = service_meter the_id = 'an id' self.assertEqual([the_id], oops_saved(report=dict(id=the_id)))
def test_oops_saved_with_report_with_no_id(self): """oops_saved returns an empty list with no id in the report.""" service_meter = METER_UTILITY.get_service_meter() with patch.object(METER_UTILITY, 'get_service_meter'): METER_UTILITY.get_service_meter.return_value = service_meter self.assertEqual([], oops_saved(report=dict()))