| 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 import gae_ts_mon | 8 import gae_ts_mon |
| 9 import mock | 9 import mock |
| 10 import webapp2 | 10 import webapp2 |
| 11 | 11 |
| 12 from infra_libs.ts_mon import config | 12 from infra_libs.ts_mon import config |
| 13 from infra_libs.ts_mon import handlers | 13 from infra_libs.ts_mon import handlers |
| 14 from infra_libs.ts_mon import shared | 14 from infra_libs.ts_mon import shared |
| 15 from infra_libs.ts_mon.common import interface | 15 from infra_libs.ts_mon.common import interface |
| 16 from infra_libs.ts_mon.common import targets | 16 from infra_libs.ts_mon.common import targets |
| 17 from infra_libs.ts_mon.common.test import stubs | |
| 18 from testing_utils import testing | 17 from testing_utils import testing |
| 19 | 18 |
| 20 | 19 |
| 21 class HelperFunctionsTest(unittest.TestCase): | 20 class HelperFunctionsTest(unittest.TestCase): |
| 22 def test_find_gaps(self): | 21 def test_find_gaps(self): |
| 23 self.assertEqual( | 22 self.assertEqual( |
| 24 list(zip(xrange(5), handlers.find_gaps([1, 3, 5]))), | 23 list(zip(xrange(5), handlers.find_gaps([1, 3, 5]))), |
| 25 list(enumerate([0, 2, 4, 6, 7]))) | 24 list(enumerate([0, 2, 4, 6, 7]))) |
| 26 self.assertEqual( | 25 self.assertEqual( |
| 27 list(zip(xrange(5), handlers.find_gaps([0, 1, 2, 3, 5]))), | 26 list(zip(xrange(5), handlers.find_gaps([0, 1, 2, 3, 5]))), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 callback_mock = mock.Mock(callback, set_auto=True) | 88 callback_mock = mock.Mock(callback, set_auto=True) |
| 90 shared.register_global_metrics_callback('cb', callback_mock) | 89 shared.register_global_metrics_callback('cb', callback_mock) |
| 91 | 90 |
| 92 request = webapp2.Request.blank('/internal/cron/ts_mon/send') | 91 request = webapp2.Request.blank('/internal/cron/ts_mon/send') |
| 93 request.headers['X-Appengine-Cron'] = 'true' | 92 request.headers['X-Appengine-Cron'] = 'true' |
| 94 self.mock_state.global_monitor = mock.Mock() | 93 self.mock_state.global_monitor = mock.Mock() |
| 95 response = request.get_response(handlers.app) | 94 response = request.get_response(handlers.app) |
| 96 | 95 |
| 97 self.assertEqual(response.status_int, 200) | 96 self.assertEqual(response.status_int, 200) |
| 98 callback_mock.assert_called_once_with() | 97 callback_mock.assert_called_once_with() |
| OLD | NEW |