Exemple #1
0
 def test_custom_status_and_exception(self):
     counter = mock.Mock(metrics.CounterMetric)
     with self.assertRaises(Exception):
         with helpers.ScopedIncrementCounter(counter) as sc:
             sc.set_status('foo')
             raise Exception()
     counter.increment.assert_called_once_with({'status': 'foo'})
 def test_custom_label_exception(self):
     with self.assertRaises(_CustomException):
         with helpers.ScopedIncrementCounter(self.counter, 'a', 'b', 'c'):
             raise _CustomException()
     self.counter.increment.assert_called_once_with({'a': 'c'})
 def test_custom_label_success(self):
     with helpers.ScopedIncrementCounter(self.counter, 'a', 'b', 'c'):
         pass
     self.counter.increment.assert_called_once_with({'a': 'b'})
 def test_multiple_custom_status_calls(self):
     with helpers.ScopedIncrementCounter(self.counter) as sc:
         sc.set_status('foo')
         sc.set_status('bar')
     self.counter.increment.assert_called_once_with({'status': 'bar'})
 def test_custom_status_and_exception(self):
     with self.assertRaises(_CustomException):
         with helpers.ScopedIncrementCounter(self.counter) as sc:
             sc.set_status('foo')
             raise _CustomException()
     self.counter.increment.assert_called_once_with({'status': 'foo'})
 def test_set_failure(self):
     with helpers.ScopedIncrementCounter(self.counter) as sc:
         sc.set_failure()
     self.counter.increment.assert_called_once_with({'status': 'failure'})
 def test_exception(self):
     with self.assertRaises(_CustomException):
         with helpers.ScopedIncrementCounter(self.counter):
             raise _CustomException()
     self.counter.increment.assert_called_once_with({'status': 'failure'})
 def test_success(self):
     with helpers.ScopedIncrementCounter(self.counter):
         pass
     self.counter.increment.assert_called_once_with({'status': 'success'})
Exemple #9
0
 def test_custom_label_exception(self):
     counter = mock.Mock(metrics.CounterMetric)
     with self.assertRaises(Exception):
         with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'):
             raise Exception()
     counter.increment.assert_called_once_with({'a': 'c'})
Exemple #10
0
 def test_custom_label_success(self):
     counter = mock.Mock(metrics.CounterMetric)
     with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'):
         pass
     counter.increment.assert_called_once_with({'a': 'b'})
Exemple #11
0
 def test_multiple_custom_status_calls(self):
     counter = mock.Mock(metrics.CounterMetric)
     with helpers.ScopedIncrementCounter(counter) as sc:
         sc.set_status('foo')
         sc.set_status('bar')
     counter.increment.assert_called_once_with({'status': 'bar'})
Exemple #12
0
 def test_set_failure(self):
     counter = mock.Mock(metrics.CounterMetric)
     with helpers.ScopedIncrementCounter(counter) as sc:
         sc.set_failure()
     counter.increment.assert_called_once_with({'status': 'failure'})
Exemple #13
0
 def test_exception(self):
     counter = mock.Mock(metrics.CounterMetric)
     with self.assertRaises(Exception):
         with helpers.ScopedIncrementCounter(counter):
             raise Exception()
     counter.increment.assert_called_once_with({'status': 'failure'})
Exemple #14
0
 def test_success(self):
     counter = mock.Mock(metrics.CounterMetric)
     with helpers.ScopedIncrementCounter(counter):
         pass
     counter.increment.assert_called_once_with({'status': 'success'})