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