Add help commands withouth auth in functional

A special scenairo is that users want to check the commands
help message, but don't set authentication info at all. Add
a related functional test case to cover it.

Change-Id: I7b09701df24d6f6dfcf369f89212f72e753be6e4
This commit is contained in:
Rui Chen 2017-04-01 14:52:21 +08:00 committed by Dean Troyer
parent 6591154488
commit 341f07582e

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
from openstackclient.tests.functional import base
@ -71,3 +73,48 @@ class HelpTests(base.TestCase):
self.assertIn('List networks', raw_output)
raw_output = self.openstack('network create --help')
self.assertIn('Create new network', raw_output)
def test_commands_help_no_auth(self):
"""Check help commands without auth info."""
# Pop all auth info
auth_info = {key: os.environ.pop(key)
for key in os.environ.keys()
if key.startswith('OS_')}
raw_output = self.openstack('help')
self.assertIn('usage: openstack', raw_output)
raw_output = self.openstack('--help')
self.assertIn('usage: openstack', raw_output)
raw_output = self.openstack('help network list')
self.assertIn('List networks', raw_output)
raw_output = self.openstack('network list --help')
self.assertIn('List networks', raw_output)
raw_output = self.openstack('help volume list')
self.assertIn('List volumes', raw_output)
raw_output = self.openstack('volume list --help')
self.assertIn('List volumes', raw_output)
raw_output = self.openstack('help server list')
self.assertIn('List servers', raw_output)
raw_output = self.openstack('server list --help')
self.assertIn('List servers', raw_output)
raw_output = self.openstack('help user list')
self.assertIn('List users', raw_output)
raw_output = self.openstack('user list --help')
self.assertIn('List users', raw_output)
raw_output = self.openstack('help image list')
self.assertIn('List available images', raw_output)
raw_output = self.openstack('image list --help')
self.assertIn('List available images', raw_output)
raw_output = self.openstack('help container list')
self.assertIn('List containers', raw_output)
raw_output = self.openstack('container list --help')
self.assertIn('List containers', raw_output)
# Restore auth info
os.environ.update(auth_info)