Dean Troyer 3a3f2b4ff8 Blueprint cli-auth: common cli args
Depricate --apikey, --projectid, --url (though still present for
compatibility).  Fully support OS_* env vars per
http://wiki.openstack.org/CLIAuth Password Flow.

Fixes lp897304

Change-Id: I655631194ed62133c24f30c9114e6fdc0fa77636
2012-02-02 16:40:49 -06:00

39 lines
1.1 KiB
Python

import os
import httplib2
from novaclient import exceptions
import novaclient.shell
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_NAME': 'tenant_name',
'OS_AUTH_URL': 'http://no.where',
}
_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 = novaclient.shell.OpenStackComputeShell()
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