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

Unified Diff: infra_libs/test/app_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/test/app_test.py
diff --git a/infra_libs/test/app_test.py b/infra_libs/test/app_test.py
deleted file mode 100644
index 567f7dc3472634867af1a00e734d966cec3a3b1a..0000000000000000000000000000000000000000
--- a/infra_libs/test/app_test.py
+++ /dev/null
@@ -1,97 +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 argparse
-import unittest
-
-import mock
-
-from infra_libs import app
-from infra_libs import logs
-from infra_libs import ts_mon
-
-
-class MockApplication(app.BaseApplication):
- main = mock.Mock()
-
-
-class AppTest(unittest.TestCase):
- def setUp(self):
- self.mock_logs_process_argparse_options = mock.patch(
- 'infra_libs.logs.process_argparse_options').start()
- self.mock_ts_mon_process_argparse_options = mock.patch(
- 'infra_libs.ts_mon.process_argparse_options').start()
-
- def tearDown(self):
- mock.patch.stopall()
-
- def test_initialises_standard_modules(self):
- with self.assertRaises(SystemExit):
- MockApplication().run(['appname'])
-
- self.mock_logs_process_argparse_options.assert_called_once()
- self.mock_ts_mon_process_argparse_options.assert_called_once()
-
- def test_initialises_standard_modules_except_ts_mon(self):
- class Application(MockApplication):
- USES_TS_MON = False
-
- with self.assertRaises(SystemExit):
- Application().run(['appname'])
-
- self.mock_logs_process_argparse_options.assert_called_once()
- self.assertFalse(self.mock_ts_mon_process_argparse_options.called)
-
- def test_initialises_standard_modules_except_logs(self):
- class Application(MockApplication):
- USES_STANDARD_LOGGING = False
-
- with self.assertRaises(SystemExit):
- Application().run(['appname'])
-
- self.assertFalse(self.mock_logs_process_argparse_options.called)
- self.mock_ts_mon_process_argparse_options.assert_called_once()
-
- def test_argparse_options(self):
- test_case = self
- class App(MockApplication):
- def add_argparse_options(self, p):
- test_case.assertIsInstance(p, argparse.ArgumentParser)
-
- def process_argparse_options(self, o):
- test_case.assertIsInstance(o, argparse.Namespace)
-
- a = App()
- with self.assertRaises(SystemExit):
- a.run(['appname'])
-
- def test_exit_status(self):
- class App(app.BaseApplication):
- def main(self, opts):
- return 42
-
- with self.assertRaises(SystemExit) as cm:
- App().run(['appname'])
- self.assertEqual(42, cm.exception.code)
-
- def test_catches_exceptions(self):
- a = MockApplication()
- a.main.side_effect = Exception
- ts_mon.reset_for_unittest(disable=True)
-
- with self.assertRaises(SystemExit) as cm:
- a.run(['appname'])
- self.assertEqual(1, cm.exception.code)
-
- def test_catches_exceptions_with_ts_mon_disabled(self):
- class Application(MockApplication):
- USES_TS_MON = False
-
- a = Application()
- a.main.side_effect = Exception
- ts_mon.reset_for_unittest(disable=True)
-
- with self.assertRaises(SystemExit) as cm:
- a.run(['appname'])
- self.assertEqual(1, cm.exception.code)

Powered by Google App Engine
This is Rietveld 408576698