Adding Cue client to osclients
Including Cue client unit tests Change-Id: I957fb50f496f6dd2be2c0499f67eb86b983e5d20
This commit is contained in:
parent
004b91b364
commit
d3a2263ec9
@ -2,3 +2,4 @@ python-mistralclient
|
||||
python-fuelclient==6.1.0
|
||||
python-muranoclient>=0.5.5
|
||||
python-monascaclient>=1.0.22
|
||||
python-cueclient>=1.0.0
|
||||
|
@ -619,6 +619,22 @@ class Monasca(OSClient):
|
||||
return client
|
||||
|
||||
|
||||
@configure("cue", default_version="1", default_service_type="message-broker")
|
||||
class Cue(OSClient):
|
||||
def create_client(self, service_type=None):
|
||||
"""Return cue client."""
|
||||
from cueclient.v1 import client as cue
|
||||
|
||||
version = self.choose_version()
|
||||
api_url = self._get_endpoint(service_type)
|
||||
api_url += "v%s" % version
|
||||
|
||||
session = self._get_session(endpoint=api_url)
|
||||
endpoint_type = self.credential.endpoint_type,
|
||||
|
||||
return cue.Client(session=session, interface=endpoint_type[0])
|
||||
|
||||
|
||||
class Clients(object):
|
||||
"""This class simplify and unify work with OpenStack python clients."""
|
||||
|
||||
|
@ -1449,6 +1449,12 @@ class FakeEC2Client(object):
|
||||
pass
|
||||
|
||||
|
||||
class FakeCueClient(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
class FakeClients(object):
|
||||
|
||||
def __init__(self, endpoint_=None):
|
||||
|
@ -680,3 +680,21 @@ class OSClientsTestCase(test.TestCase):
|
||||
if version is not None:
|
||||
key += "%s" % {"version": version}
|
||||
self.assertEqual(fake_designate, self.clients.cache[key])
|
||||
|
||||
@mock.patch("rally.osclients.Cue._get_session")
|
||||
def test_cue(self, mock_cue__get_session):
|
||||
fake_cue = fakes.FakeCueClient()
|
||||
mock_cue = mock.MagicMock()
|
||||
mock_cue.client.Client = mock.MagicMock(return_value=fake_cue)
|
||||
|
||||
mock_cue__get_session.return_value = self.fake_keystone.session
|
||||
|
||||
self.assertNotIn("cue", self.clients.cache)
|
||||
with mock.patch.dict("sys.modules", {"cueclient": mock_cue,
|
||||
"cueclient.v1": mock_cue}):
|
||||
client = self.clients.cue()
|
||||
self.assertEqual(fake_cue, client)
|
||||
mock_cue.client.Client.assert_called_once_with(
|
||||
interface=consts.EndpointType.PUBLIC,
|
||||
session=self.fake_keystone.session)
|
||||
self.assertEqual(fake_cue, self.clients.cache["cue"])
|
||||
|
Loading…
Reference in New Issue
Block a user