blob: f7e8c7b326da83a38bc24b3d75e82d2c4ed6318b [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):
Alex Klein1699fab2022-09-08 08:46:06 -060013 """Test the main functionality."""
Ryan Cui47f80e42013-04-01 19:01:54 -070014
Alex Klein1699fab2022-09-08 08:46:06 -060015 def setUp(self):
16 self.PatchObject(cros, "_RunSubCommand", autospec=True)
Ryan Cui47f80e42013-04-01 19:01:54 -070017
Alex Klein1699fab2022-09-08 08:46:06 -060018 def testDefaultLogLevel(self):
19 """Test that the default log level is set to notice."""
20 arg_parser = self.PatchObject(
21 commandline,
22 "ArgumentParser",
23 return_value=commandline.ArgumentParser(),
24 )
25 cros.GetOptions()
26 arg_parser.assert_called_with(caching=True, default_log_level="notice")
Mike Frysinger1a470812019-11-07 01:19:17 -050027
Alex Klein1699fab2022-09-08 08:46:06 -060028 def testSubcommand(self):
29 """Test parser when given a subcommand."""
30 parser = cros.GetOptions("lint")
31 opts = parser.parse_args(["lint"])
32 self.assertEqual(opts.subcommand, "lint")