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 datetime | 5 import datetime |
6 import unittest | 6 import unittest |
7 | 7 |
8 from infra_libs import http_metrics | 8 from infra_libs.ts_mon.common import http_metrics |
9 from infra_libs import instrumented_requests | 9 from infra_libs import instrumented_requests |
10 | 10 |
11 import requests | 11 import requests |
12 import mock | 12 import mock |
13 | 13 |
14 | 14 |
15 class InstrumentedRequestsTest(unittest.TestCase): | 15 class InstrumentedRequestsTest(unittest.TestCase): |
16 def setUp(self): | 16 def setUp(self): |
17 super(InstrumentedRequestsTest, self).setUp() | 17 super(InstrumentedRequestsTest, self).setUp() |
18 http_metrics._reset_for_testing() | 18 http_metrics._reset_for_testing() |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 '_instrumented_test', 'foo', 'http://example.com', | 97 '_instrumented_test', 'foo', 'http://example.com', |
98 hooks={'foo': lambda: 42}) | 98 hooks={'foo': lambda: 42}) |
99 | 99 |
100 self.assertTrue(f.called) | 100 self.assertTrue(f.called) |
101 self.assertEquals(('http://example.com',), f.call_args[0]) | 101 self.assertEquals(('http://example.com',), f.call_args[0]) |
102 self.assertIn('hooks', f.call_args[1]) | 102 self.assertIn('hooks', f.call_args[1]) |
103 self.assertIn('response', f.call_args[1]['hooks']) | 103 self.assertIn('response', f.call_args[1]['hooks']) |
104 self.assertIn('foo', f.call_args[1]['hooks']) | 104 self.assertIn('foo', f.call_args[1]['hooks']) |
105 self.assertTrue(hasattr(f.call_args[1]['hooks']['response'], '__call__')) | 105 self.assertTrue(hasattr(f.call_args[1]['hooks']['response'], '__call__')) |
106 self.assertEquals(42, f.call_args[1]['hooks']['foo']()) | 106 self.assertEquals(42, f.call_args[1]['hooks']['foo']()) |
OLD | NEW |