3 # Copyright 2008 Google Inc. All Rights Reserved.
7 import unittest
, os
, sys
, StringIO
10 from autotest_lib
.cli
import cli_mock
13 class main_unittest(cli_mock
.cli_unittest
):
14 def _test_help(self
, argv
, out_words_ok
, err_words_ok
):
16 for help in ['-h', '--help', 'help']:
17 outputs
= self
.run_cmd(argv
+ [help], exit_code
=0,
18 out_words_ok
=out_words_ok
,
19 err_words_ok
=err_words_ok
)
21 saved_outputs
= outputs
23 self
.assertEqual(outputs
, saved_outputs
)
26 def test_main_help(self
):
28 self
._test
_help
(argv
=['atest'],
29 out_words_ok
=['atest [acl|host|job|label|atomicgroup'
30 '|test|user] [action] [options]'],
34 def test_main_help_topic(self
):
35 """Topic level help"""
36 self
._test
_help
(argv
=['atest', 'host'],
37 out_words_ok
=['atest host ',
38 '[create|delete|list|stat|mod|jobs]'
43 def test_main_help_action(self
):
44 """Action level help"""
45 self
._test
_help
(argv
=['atest:', 'host', 'mod'],
46 out_words_ok
=['atest host mod [options]'],
50 def test_main_no_topic(self
):
51 self
.run_cmd(['atest'], exit_code
=1,
52 out_words_ok
=['atest '
53 '[acl|host|job|label|atomicgroup|test|user] '
54 '[action] [options]'],
55 err_words_ok
=['No topic argument'])
58 def test_main_bad_topic(self
):
59 self
.run_cmd(['atest', 'bad_topic'], exit_code
=1,
60 out_words_ok
=['atest [acl|host|job|label|atomicgroup'
61 '|test|user] [action] [options]'],
62 err_words_ok
=['Invalid topic bad_topic\n'])
65 def test_main_bad_action(self
):
66 self
.run_cmd(['atest', 'host', 'bad_action'], exit_code
=1,
67 out_words_ok
=['atest host [create|delete|list|stat|'
68 'mod|jobs] [options]'],
69 err_words_ok
=['Invalid action bad_action'])
72 if __name__
== '__main__':