def test_create_connection(self, mock_conn, mock_profile): x_profile = mock.Mock() mock_profile.return_value = x_profile x_conn = mock.Mock() mock_conn.return_value = x_conn res = sdk.create_connection({'foo': 'bar'}) self.assertEqual(x_conn, res) mock_profile.assert_called_once_with() mock_conn.assert_called_once_with(profile=x_profile, user_agent=sdk.USER_AGENT, foo='bar')
def test_create_connection_with_region(self, mock_conn, mock_profile): x_profile = mock.Mock() mock_profile.return_value = x_profile x_conn = mock.Mock() mock_conn.return_value = x_conn res = sdk.create_connection({'region_name': 'REGION_ONE'}) self.assertEqual(x_conn, res) mock_profile.assert_called_once_with() x_profile.set_region.assert_called_once_with(x_profile.ALL, 'REGION_ONE') mock_conn.assert_called_once_with(profile=x_profile, user_agent=sdk.USER_AGENT)
def test_create_connection_token(self, mock_conn, mock_profile): x_profile = mock.Mock() mock_profile.return_value = x_profile x_conn = mock.Mock() mock_conn.return_value = x_conn res = sdk.create_connection({'token': 'TOKEN', 'foo': 'bar'}) self.assertEqual(x_conn, res) mock_profile.assert_called_once_with() x_profile.set_version.assert_called_once_with('identity', 'v3') mock_conn.assert_called_once_with(profile=x_profile, user_agent=sdk.USER_AGENT, auth_plugin='token', token='TOKEN', foo='bar')
def test_create_connection_password(self, mock_conn, mock_profile): x_profile = mock.Mock() mock_profile.return_value = x_profile x_conn = mock.Mock() mock_conn.return_value = x_conn res = sdk.create_connection({'user_id': '123', 'password': '******', 'foo': 'bar'}) self.assertEqual(x_conn, res) mock_profile.assert_called_once_with() x_profile.set_version.assert_called_once_with('identity', 'v3') mock_conn.assert_called_once_with(profile=x_profile, user_agent=sdk.USER_AGENT, auth_plugin='password', user_id='123', password='******', foo='bar')
def __init__(self, params): super(NovaClient, self).__init__(params) self.conn = sdk.create_connection(params) self.session = self.conn.session
def __init__(self, params): super(NeutronClient, self).__init__(params) self.conn = sdk.create_connection(params)
def __init__(self, params): super(CeilometerClient, self).__init__(params) self.conn = sdk.create_connection(params)