Fixed test_password_prompted

test_password_prompted no longer makes DNS lookups on the network.

Change-Id: If310f52e829b09b01c76d02deae4aec74f00870d
Closes-Bug: 1486647
This commit is contained in:
Derrick J. Wippler
2015-08-19 11:36:33 -05:00
parent 1d71a6d138
commit 50758ba475

View File

@@ -122,13 +122,17 @@ class ShellTest(utils.TestCase):
self.assertEqual(v3_url, os_auth_url, "Expected v3 url") self.assertEqual(v3_url, os_auth_url, "Expected v3 url")
self.assertIsNone(v2_url, "Expected no v2 url") self.assertIsNone(v2_url, "Expected no v2 url")
@mock.patch('keystoneclient.adapter.Adapter.get_token',
side_effect=ks_exc.ConnectionRefused())
@mock.patch('keystoneclient.discover.Discover',
side_effect=ks_exc.ConnectionRefused())
@mock.patch('sys.stdin', side_effect=mock.MagicMock) @mock.patch('sys.stdin', side_effect=mock.MagicMock)
@mock.patch('getpass.getpass', return_value='password') @mock.patch('getpass.getpass', return_value='password')
def test_password_prompted(self, mock_getpass, mock_stdin): def test_password_prompted(self, mock_getpass, mock_stdin, mock_discover,
mock_token):
self.make_env(exclude='OS_PASSWORD') self.make_env(exclude='OS_PASSWORD')
# We should get a Connection Refused because there is no keystone. _shell = shell.OpenStackCinderShell()
self.assertRaises(ks_exc.ConnectionRefused, self.shell, 'list') self.assertRaises(ks_exc.ConnectionRefused, _shell.main, ['list'])
# Make sure we are actually prompted.
mock_getpass.assert_called_with('OS Password: ') mock_getpass.assert_called_with('OS Password: ')
@mock.patch.object(requests, "request") @mock.patch.object(requests, "request")