blob: dbbfc2ec071182b3532294543c0662d0083795da [file] [log] [blame]
Shuqian Zhao8754a1a2016-08-24 12:54:11 -07001#!/usr/bin/python
2# Copyright (c) 2014 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
6"""Unittests for deploy_server_local.py."""
7
8from __future__ import print_function
9
10import unittest
11
12import deploy_server as deploy_server
13
14
15class TestDeployServer(unittest.TestCase):
16 """Test deploy_server_local with commands mocked out."""
17
18 def test_parse_arguments(self):
19 """Test deploy_server_local.parse_arguments."""
20 # Only requires args.
21 results = deploy_server.parse_arguments(['--afe', 'foo'])
22 self.assertEqual(
23 {'afe': 'foo', 'servers': [], 'args': [],
24 'cont': False, 'dryrun': False, 'verbose': False,
Shuqian Zhao9febd452017-01-31 15:36:40 -080025 'force_update': False, 'logfile': '/tmp/deployment.log',
26 'update_push_servers': False},
Shuqian Zhao8754a1a2016-08-24 12:54:11 -070027 vars(results))
28
29 # Dryrun, continue
30 results = deploy_server.parse_arguments(['--afe', 'foo',
31 '--dryrun', '--continue'])
32 self.assertDictContainsSubset(
33 {'afe': 'foo', 'servers': [], 'args': [],
34 'cont': True, 'dryrun': True, 'verbose': False,
Shuqian Zhao9febd452017-01-31 15:36:40 -080035 'force_update': False, 'logfile': '/tmp/deployment.log',
36 'update_push_servers': False},
Shuqian Zhao8754a1a2016-08-24 12:54:11 -070037 vars(results))
38
39 # List some servers
40 results = deploy_server.parse_arguments(['--afe', 'foo',
41 'dummy', 'bar'])
42 self.assertDictContainsSubset(
43 {'afe': 'foo', 'servers': ['dummy', 'bar'], 'args': [],
44 'cont': False, 'dryrun': False, 'verbose': False,
Shuqian Zhao9febd452017-01-31 15:36:40 -080045 'force_update': False, 'logfile': '/tmp/deployment.log',
46 'update_push_servers': False},
Shuqian Zhao8754a1a2016-08-24 12:54:11 -070047 vars(results))
48
49 # List some local args
50 results = deploy_server.parse_arguments(['--afe', 'foo',
51 '--', 'dummy', 'bar'])
52 self.assertDictContainsSubset(
53 {'afe': 'foo', 'servers': [], 'args': ['dummy', 'bar'],
54 'cont': False, 'dryrun': False, 'verbose': False,
Shuqian Zhao9febd452017-01-31 15:36:40 -080055 'force_update': False, 'logfile': '/tmp/deployment.log',
56 'update_push_servers': False},
Shuqian Zhao8754a1a2016-08-24 12:54:11 -070057 vars(results))
58
59 # List everything.
60 results = deploy_server.parse_arguments(
61 ['--continue', '--afe', 'foo', '--dryrun', 'dummy', 'bar',
Shuqian Zhaoa3438a52016-09-20 15:11:02 -070062 '--', '--actions-only', '--dryrun', '--update_push_servers',
63 '--force_update'])
Shuqian Zhao8754a1a2016-08-24 12:54:11 -070064 self.assertDictContainsSubset(
65 {'afe': 'foo', 'servers': ['dummy', 'bar'],
66 'args': ['--actions-only', '--dryrun',
Shuqian Zhaoa3438a52016-09-20 15:11:02 -070067 '--update_push_servers', '--force_update'],
Shuqian Zhao8754a1a2016-08-24 12:54:11 -070068 'cont': True, 'dryrun': True, 'verbose': False},
69 vars(results))
70
71
72if __name__ == '__main__':
73 unittest.main()