| 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 from infra.libs.event_mon import router | 7 from infra.libs.event_mon import router |
| 8 from infra.libs.event_mon.log_request_lite_pb2 import LogRequestLite | 8 from infra.libs.event_mon.log_request_lite_pb2 import LogRequestLite |
| 9 | 9 |
| 10 | 10 |
| 11 class RouterTests(unittest.TestCase): | 11 class RouterTests(unittest.TestCase): |
| 12 def test_smoke(self): | 12 def test_smoke(self): |
| 13 # Use dry_run to avoid code that deals with http (including auth). | 13 # Use dry_run to avoid code that deals with http (including auth). |
| 14 r = router._Router(dry_run=True) | 14 r = router._Router(endpoint=None) |
| 15 self.assertTrue(r.close()) | 15 self.assertTrue(r.close()) |
| 16 | 16 |
| 17 def test_push_smoke(self): | 17 def test_push_smoke(self): |
| 18 r = router._Router(dry_run=True) | 18 r = router._Router(endpoint=None) |
| 19 | 19 |
| 20 req = LogRequestLite.LogEventLite() | 20 req = LogRequestLite.LogEventLite() |
| 21 req.event_time_ms = router.time_ms() | 21 req.event_time_ms = router.time_ms() |
| 22 req.event_code = 1 | 22 req.event_code = 1 |
| 23 req.event_flow_id = 2 | 23 req.event_flow_id = 2 |
| 24 r.push_event(req) | 24 r.push_event(req) |
| 25 self.assertTrue(r.close()) | 25 self.assertTrue(r.close()) |
| 26 | 26 |
| 27 def test_push_error_handling(self): | 27 def test_push_error_handling(self): |
| 28 r = router._Router(dry_run=True) | 28 r = router._Router(endpoint=None) |
| 29 r.push_event(None) | 29 r.push_event(None) |
| 30 self.assertTrue(r.close()) | 30 self.assertTrue(r.close()) |
| OLD | NEW |