OLD | NEW |
| (Empty) |
1 # -*- coding: utf-8 -*- | |
2 # Copyright 2013 Google Inc. All Rights Reserved. | |
3 # | |
4 # Permission is hereby granted, free of charge, to any person obtaining a | |
5 # copy of this software and associated documentation files (the | |
6 # "Software"), to deal in the Software without restriction, including | |
7 # without limitation the rights to use, copy, modify, merge, publish, dis- | |
8 # tribute, sublicense, and/or sell copies of the Software, and to permit | |
9 # persons to whom the Software is furnished to do so, subject to the fol- | |
10 # lowing conditions: | |
11 # | |
12 # The above copyright notice and this permission notice shall be included | |
13 # in all copies or substantial portions of the Software. | |
14 # | |
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | |
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | |
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
21 # IN THE SOFTWARE. | |
22 """Unit tests for help command.""" | |
23 | |
24 from __future__ import absolute_import | |
25 | |
26 import gslib.tests.testcase as testcase | |
27 | |
28 | |
29 class HelpUnitTests(testcase.GsUtilUnitTestCase): | |
30 """Help command unit test suite.""" | |
31 | |
32 def test_help_noargs(self): | |
33 stdout = self.RunCommand('help', return_stdout=True) | |
34 self.assertIn('Available commands', stdout) | |
35 | |
36 def test_help_subcommand_arg(self): | |
37 stdout = self.RunCommand('help', ['web', 'set'], return_stdout=True) | |
38 self.assertIn('gsutil web set', stdout) | |
39 self.assertNotIn('gsutil web get', stdout) | |
40 | |
41 def test_help_invalid_subcommand_arg(self): | |
42 stdout = self.RunCommand('help', ['web', 'asdf'], return_stdout=True) | |
43 self.assertIn('help about one of the subcommands', stdout) | |
44 | |
45 def test_help_with_subcommand_for_command_without_subcommands(self): | |
46 stdout = self.RunCommand('help', ['ls', 'asdf'], return_stdout=True) | |
47 self.assertIn('has no subcommands', stdout) | |
48 | |
49 def test_help_command_arg(self): | |
50 stdout = self.RunCommand('help', ['ls'], return_stdout=True) | |
51 self.assertIn('ls - List providers, buckets', stdout) | |
52 | |
53 def test_command_help_arg(self): | |
54 stdout = self.RunCommand('ls', ['--help'], return_stdout=True) | |
55 self.assertIn('ls - List providers, buckets', stdout) | |
56 | |
57 def test_subcommand_help_arg(self): | |
58 stdout = self.RunCommand('web', ['set', '--help'], return_stdout=True) | |
59 self.assertIn('gsutil web set', stdout) | |
60 self.assertNotIn('gsutil web get', stdout) | |
61 | |
62 def test_command_args_with_help(self): | |
63 stdout = self.RunCommand('cp', ['foo', 'bar', '--help'], return_stdout=True) | |
64 self.assertIn('cp - Copy files and objects', stdout) | |
65 | |
66 | |
67 class HelpIntegrationTests(testcase.GsUtilIntegrationTestCase): | |
68 """Help command integration test suite.""" | |
69 | |
70 def test_help_wrong_num_args(self): | |
71 stderr = self.RunGsUtil(['cp'], return_stderr=True, expected_status=1) | |
72 self.assertIn('Usage:', stderr) | |
OLD | NEW |