Fix tests failing if keystone is running locally
This mocks out the call to python-keystoneclient's Session.get_token(), preventing any actual calls being made to a keystone service, running or not. Change-Id: I24b0874d8e67b46b7c2294d4ac54efa861561dff Closes-bug: 1423170
This commit is contained in:
@@ -254,10 +254,12 @@ class ShellTest(utils.TestCase):
|
||||
|
||||
@mock.patch('sys.stdin', side_effect=mock.MagicMock)
|
||||
@mock.patch('getpass.getpass', return_value='password')
|
||||
def test_password_prompted_with_v2(self, mock_getpass, mock_stdin):
|
||||
@mock.patch('keystoneclient.session.Session.get_token',
|
||||
side_effect=ks_exc.ConnectionRefused)
|
||||
def test_password_prompted_with_v2(self, mock_session, mock_getpass,
|
||||
mock_stdin):
|
||||
glance_shell = openstack_shell.OpenStackImagesShell()
|
||||
self.make_env(exclude='OS_PASSWORD')
|
||||
# We will get a Connection Refused because there is no keystone.
|
||||
self.assertRaises(ks_exc.ConnectionRefused,
|
||||
glance_shell.main, ['image-list'])
|
||||
# Make sure we are actually prompted.
|
||||
|
||||
Reference in New Issue
Block a user