From 96871b975b0edbabe08e6171f8f24b789656322a Mon Sep 17 00:00:00 2001 From: Louis Taylor Date: Mon, 2 Mar 2015 13:14:19 +0000 Subject: [PATCH] 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 --- tests/test_shell.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_shell.py b/tests/test_shell.py index 27216552..6eb21d2c 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -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.