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

Unified Diff: infra_libs/ts_mon/common/test/helpers_test.py

Issue 2213143002: Add infra_libs as a bootstrap dependency. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Removed the ugly import hack Created 4 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 side-by-side diff with in-line comments
Download patch
Index: infra_libs/ts_mon/common/test/helpers_test.py
diff --git a/infra_libs/ts_mon/common/test/helpers_test.py b/infra_libs/ts_mon/common/test/helpers_test.py
deleted file mode 100755
index cf72faee6b7f149d7898da7eea2bacedcb1417c0..0000000000000000000000000000000000000000
--- a/infra_libs/ts_mon/common/test/helpers_test.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2015 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import unittest
-
-import mock
-
-from infra_libs.ts_mon.common import metrics
-from infra_libs.ts_mon.common import helpers
-
-
-class ScopedIncrementCounterTest(unittest.TestCase):
-
- def test_success(self):
- counter = mock.Mock(metrics.CounterMetric)
- with helpers.ScopedIncrementCounter(counter):
- pass
- counter.increment.assert_called_once_with({'status': 'success'})
-
- 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'})
-
- def test_custom_status(self):
- counter = mock.Mock(metrics.CounterMetric)
- with helpers.ScopedIncrementCounter(counter) as sc:
- sc.set_status('foo')
- counter.increment.assert_called_once_with({'status': 'foo'})
-
- 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'})
-
- 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_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'})
-
- 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'})
-
- 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'})

Powered by Google App Engine
This is Rietveld 408576698