blob: 9aae81558116b1c4b4a003e20e0a8b0d8d483230 [file] [log] [blame]
xixuan52c2fba2016-05-21 00:02:481#!/usr/bin/python2
2
3# Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Unit tests for cros_update_parser.py."""
8
9from __future__ import print_function
10
11import sys
12import unittest
13
14import cros_update
15
16class CrosUpdateParserTest(unittest.TestCase):
17 """Tests for the autoupdate.Autoupdate class."""
18
19 def setUp(self):
20 self.orig_sys_argv = sys.argv
21
22 def tearDown(self):
23 self.argv = self.orig_sys_argv
24
25 def _get_parser(self):
26 return cros_update.CrOSAUParser()
27
28 def test_parse_args(self):
29 host_name = '100.0.0.1'
30 build_name = 'fake/image'
31 sys.argv = ['run.py', '-d', host_name, '-b', build_name, '-q', 'test']
32 parser = self._get_parser()
33 parser.ParseArgs()
34 self.assertEqual(host_name, parser.options.host_name)
35 self.assertEqual(build_name, parser.options.build_name)
36 self.assertEqual(['-q', 'test'], parser.removed_args)
37
38
39if __name__ == '__main__':
40 unittest.main()