blob: 85098e1ddf05ff7518d3e7d4b7119f1923e89f40 [file] [log] [blame]
Mike Frysingere58c0e22017-10-04 15:43:30 -04001# -*- coding: utf-8 -*-
Ryan Cui47f80e42013-04-01 19:01:54 -07002# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
Don Garrett25f309a2014-03-19 14:02:12 -07006"""Unittests for cros."""
7
Mike Frysinger383367e2014-09-16 15:06:17 -04008from __future__ import print_function
9
Ralph Nathan1fc77f22015-04-21 15:05:48 -070010from chromite.lib import commandline
Ryan Cui47f80e42013-04-01 19:01:54 -070011from chromite.lib import cros_test_lib
Ryan Cui47f80e42013-04-01 19:01:54 -070012from chromite.scripts import cros
13
14
Don Garrett4c2b9172015-10-09 13:27:44 -070015class RunScriptTest(cros_test_lib.MockTempDirTestCase):
Ryan Cui47f80e42013-04-01 19:01:54 -070016 """Test the main functionality."""
17
18 def setUp(self):
Ryan Cui47f80e42013-04-01 19:01:54 -070019 self.PatchObject(cros, '_RunSubCommand', autospec=True)
20
David Pursellc7ba7842015-07-08 10:48:41 -070021 def testDefaultLogLevel(self):
22 """Test that the default log level is set to notice."""
Ralph Nathan1fc77f22015-04-21 15:05:48 -070023 arg_parser = self.PatchObject(commandline, 'ArgumentParser',
24 return_value=commandline.ArgumentParser())
Mike Frysinger1a470812019-11-07 01:19:17 -050025 cros.GetOptions()
26 arg_parser.assert_called_with(caching=True, default_log_level='notice',
27 add_help=False)
28
29 def testSubcommand(self):
30 """Test parser when given a subcommand."""
31 parser = cros.GetOptions('lint')
32 opts = parser.parse_args(['lint'])
33 self.assertEqual(opts.subcommand, 'lint')