Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: infra_libs/ts_mon/common/test/helpers_test.py

Issue 1260293009: make version of ts_mon compatible with appengine (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: add noncululativedistribution metric to ts_mon imports Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9 try:
10 from infra_libs.ts_mon import metrics 10 from infra_libs.ts_mon.common import metrics
11 from infra_libs.ts_mon.common import helpers
12 except ImportError: # pragma: no cover
13 from common import metrics
14 from common import helpers
11 15
12 16
13 class ScopedIncrementCounterTest(unittest.TestCase): 17 class ScopedIncrementCounterTest(unittest.TestCase):
14 18
15 def test_success(self): 19 def test_success(self):
16 counter = mock.Mock(metrics.CounterMetric) 20 counter = mock.Mock(metrics.CounterMetric)
17 with helpers.ScopedIncrementCounter(counter): 21 with helpers.ScopedIncrementCounter(counter):
18 pass 22 pass
19 counter.increment.assert_called_once_with({'status': 'success'}) 23 counter.increment.assert_called_once_with({'status': 'success'})
20 24
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'): 61 with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'):
58 pass 62 pass
59 counter.increment.assert_called_once_with({'a': 'b'}) 63 counter.increment.assert_called_once_with({'a': 'b'})
60 64
61 def test_custom_label_exception(self): 65 def test_custom_label_exception(self):
62 counter = mock.Mock(metrics.CounterMetric) 66 counter = mock.Mock(metrics.CounterMetric)
63 with self.assertRaises(Exception): 67 with self.assertRaises(Exception):
64 with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'): 68 with helpers.ScopedIncrementCounter(counter, 'a', 'b', 'c'):
65 raise Exception() 69 raise Exception()
66 counter.increment.assert_called_once_with({'a': 'c'}) 70 counter.increment.assert_called_once_with({'a': 'c'})
OLDNEW
« no previous file with comments | « infra_libs/ts_mon/common/test/errors_test.py ('k') | infra_libs/ts_mon/common/test/metrics_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698