40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import os
|
|
import mock
|
|
import httplib2
|
|
|
|
from keystoneclient import shell as openstack_shell
|
|
from keystoneclient import exceptions
|
|
from tests import utils
|
|
|
|
|
|
class ShellTest(utils.TestCase):
|
|
|
|
# Patch os.environ to avoid required auth info.
|
|
def setUp(self):
|
|
global _old_env
|
|
fake_env = {
|
|
'OS_USERNAME': 'username',
|
|
'OS_PASSWORD': 'password',
|
|
'OS_TENANT_ID': 'tenant_id',
|
|
'OS_AUTH_URL': 'http://127.0.0.1:5000/v2.0',
|
|
}
|
|
_old_env, os.environ = os.environ, fake_env.copy()
|
|
|
|
# Make a fake shell object, a helping wrapper to call it, and a quick
|
|
# way of asserting that certain API calls were made.
|
|
global shell, _shell, assert_called, assert_called_anytime
|
|
_shell = openstack_shell.OpenStackIdentityShell()
|
|
shell = lambda cmd: _shell.main(cmd.split())
|
|
|
|
def tearDown(self):
|
|
global _old_env
|
|
os.environ = _old_env
|
|
|
|
def test_help_unknown_command(self):
|
|
self.assertRaises(exceptions.CommandError, shell, 'help foofoo')
|
|
|
|
def test_debug(self):
|
|
httplib2.debuglevel = 0
|
|
shell('--debug help')
|
|
assert httplib2.debuglevel == 1
|