Ryan Cui | 47f80e4 | 2013-04-01 19:01:54 -0700 | [diff] [blame] | 1 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Don Garrett | 25f309a | 2014-03-19 14:02:12 -0700 | [diff] [blame] | 5 | """Unittests for cros.""" |
| 6 | |
Ralph Nathan | 1fc77f2 | 2015-04-21 15:05:48 -0700 | [diff] [blame] | 7 | from chromite.lib import commandline |
Ryan Cui | 47f80e4 | 2013-04-01 19:01:54 -0700 | [diff] [blame] | 8 | from chromite.lib import cros_test_lib |
Ryan Cui | 47f80e4 | 2013-04-01 19:01:54 -0700 | [diff] [blame] | 9 | from chromite.scripts import cros |
| 10 | |
| 11 | |
Don Garrett | 4c2b917 | 2015-10-09 13:27:44 -0700 | [diff] [blame] | 12 | class RunScriptTest(cros_test_lib.MockTempDirTestCase): |
Ryan Cui | 47f80e4 | 2013-04-01 19:01:54 -0700 | [diff] [blame] | 13 | """Test the main functionality.""" |
| 14 | |
| 15 | def setUp(self): |
Ryan Cui | 47f80e4 | 2013-04-01 19:01:54 -0700 | [diff] [blame] | 16 | self.PatchObject(cros, '_RunSubCommand', autospec=True) |
| 17 | |
David Pursell | c7ba784 | 2015-07-08 10:48:41 -0700 | [diff] [blame] | 18 | def testDefaultLogLevel(self): |
| 19 | """Test that the default log level is set to notice.""" |
Ralph Nathan | 1fc77f2 | 2015-04-21 15:05:48 -0700 | [diff] [blame] | 20 | arg_parser = self.PatchObject(commandline, 'ArgumentParser', |
| 21 | return_value=commandline.ArgumentParser()) |
Mike Frysinger | 1a47081 | 2019-11-07 01:19:17 -0500 | [diff] [blame] | 22 | cros.GetOptions() |
Pi-Hsun Shih | fd5a91e | 2019-11-28 15:06:06 +0800 | [diff] [blame] | 23 | arg_parser.assert_called_with(caching=True, default_log_level='notice') |
Mike Frysinger | 1a47081 | 2019-11-07 01:19:17 -0500 | [diff] [blame] | 24 | |
| 25 | def testSubcommand(self): |
| 26 | """Test parser when given a subcommand.""" |
| 27 | parser = cros.GetOptions('lint') |
| 28 | opts = parser.parse_args(['lint']) |
| 29 | self.assertEqual(opts.subcommand, 'lint') |