blob: 91e6c1ea96e0379e0be7076326f10a92724f7a1d [file] [log] [blame]
Ryan Cui47f80e42013-04-01 19:01:54 -07001# 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 Garrett25f309a2014-03-19 14:02:12 -07005"""Unittests for cros."""
6
Ralph Nathan1fc77f22015-04-21 15:05:48 -07007from chromite.lib import commandline
Ryan Cui47f80e42013-04-01 19:01:54 -07008from chromite.lib import cros_test_lib
Ryan Cui47f80e42013-04-01 19:01:54 -07009from chromite.scripts import cros
10
11
Don Garrett4c2b9172015-10-09 13:27:44 -070012class RunScriptTest(cros_test_lib.MockTempDirTestCase):
Ryan Cui47f80e42013-04-01 19:01:54 -070013 """Test the main functionality."""
14
15 def setUp(self):
Ryan Cui47f80e42013-04-01 19:01:54 -070016 self.PatchObject(cros, '_RunSubCommand', autospec=True)
17
David Pursellc7ba7842015-07-08 10:48:41 -070018 def testDefaultLogLevel(self):
19 """Test that the default log level is set to notice."""
Ralph Nathan1fc77f22015-04-21 15:05:48 -070020 arg_parser = self.PatchObject(commandline, 'ArgumentParser',
21 return_value=commandline.ArgumentParser())
Mike Frysinger1a470812019-11-07 01:19:17 -050022 cros.GetOptions()
Pi-Hsun Shihfd5a91e2019-11-28 15:06:06 +080023 arg_parser.assert_called_with(caching=True, default_log_level='notice')
Mike Frysinger1a470812019-11-07 01:19:17 -050024
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')