openstacksdk/shade/tests/unit/test_operator_noauth.py
Davide Guerri 08f330d98c Rename get_endpoint() to get_session_endpoint()
In a subsequent change, we will add Keystone endpoint methods.
In that change, get_endpoint() would return an endpoint by id, as done
by other get_<resource>() methods.
This change renames get_endpoint() in OpenStackCloud with a more
appropriate name, as it returns the current session endpoints.

Change-Id: Ie91f97457fb164255d2adf4e84c1b1f729e797b0
2015-05-02 23:20:15 +01:00

50 lines
1.8 KiB
Python

# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
import ironicclient
import shade
from shade.tests import base
class TestShadeOperatorNoAuth(base.TestCase):
def setUp(self):
"""Setup Noauth OperatorCloud tests
Setup the test to utilize no authentication and an endpoint
URL in the auth data. This is permits testing of the basic
mechanism that enables Ironic noauth mode to be utilized with
Shade.
"""
super(TestShadeOperatorNoAuth, self).setUp()
self.cloud_noauth = shade.operator_cloud(
auth_type='None',
auth=dict(endpoint="http://localhost:6385")
)
@mock.patch.object(shade.OperatorCloud, 'get_session_endpoint')
@mock.patch.object(ironicclient.client, 'Client')
def test_ironic_noauth_selection_using_a_task(
self, mock_client, mock_endpoint):
"""Test noauth selection for Ironic in OperatorCloud
Utilize a task to trigger the client connection attempt
and evaluate if get_session_endpoint was called while the client
was still called.
"""
self.cloud_noauth.patch_machine('name', {})
self.assertFalse(mock_endpoint.called)
self.assertTrue(mock_client.called)