OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import unittest | 5 import unittest |
6 | 6 |
7 import mock | 7 import mock |
8 | 8 |
9 from infra_libs.ts_mon import helpers | |
10 from infra_libs.ts_mon import metrics | 9 from infra_libs.ts_mon import metrics |
| 10 from infra_libs.ts_mon.gae import helpers |
11 | 11 |
12 | 12 |
13 class ScopedIncrementCounterTest(unittest.TestCase): | 13 class ScopedIncrementCounterTest(unittest.TestCase): |
14 | 14 |
15 def test_success(self): | 15 def test_success(self): |
16 counter = mock.Mock(metrics.CounterMetric) | 16 counter = mock.Mock(metrics.CounterMetric) |
17 with helpers.ScopedIncrementCounter(counter): | 17 with helpers.ScopedIncrementCounter(counter): |
18 pass | 18 pass |
19 counter.increment.assert_called_once_with({'status': 'success'}) | 19 counter.increment.assert_called_once_with({'status': 'success'}) |
20 | 20 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'): | 57 with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'): |
58 pass | 58 pass |
59 counter.increment.assert_called_once_with({'a': 'b'}) | 59 counter.increment.assert_called_once_with({'a': 'b'}) |
60 | 60 |
61 def test_custom_label_exception(self): | 61 def test_custom_label_exception(self): |
62 counter = mock.Mock(metrics.CounterMetric) | 62 counter = mock.Mock(metrics.CounterMetric) |
63 with self.assertRaises(Exception): | 63 with self.assertRaises(Exception): |
64 with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'): | 64 with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'): |
65 raise Exception() | 65 raise Exception() |
66 counter.increment.assert_called_once_with({'a': 'c'}) | 66 counter.increment.assert_called_once_with({'a': 'c'}) |
OLD | NEW |