blob: a3398362f4034d3b94affbee85231bd236dfdb1a [file] [log] [blame]
Mike Frysingera7f08bc2019-08-27 15:16:33 -04001#!/usr/bin/env python2
2# -*- coding: utf-8 -*-
xixuan52c2fba2016-05-20 17:02:48 -07003# 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()