Merge "Add ceilometer api and the tests for it"

This commit is contained in:
Jenkins 2013-08-29 01:49:00 +00:00 committed by Gerrit Code Review
commit 6e058c1d74
2 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,7 @@ shouldn't need to understand the finer details of APIs for
Keystone/Nova/Glance/Swift et. al.
"""
from openstack_dashboard.api import base
from openstack_dashboard.api import ceilometer
from openstack_dashboard.api import cinder
from openstack_dashboard.api import glance
from openstack_dashboard.api import heat
@ -54,3 +55,4 @@ assert nova
assert neutron
assert lbaas
assert swift
assert ceilometer

View File

@ -30,6 +30,7 @@ from django.test.client import RequestFactory # noqa
from django.utils.importlib import import_module # noqa
from django.utils import unittest
from ceilometerclient.v2 import client as ceilometer_client
from cinderclient import client as cinder_client
import glanceclient
from heatclient import client as heat_client
@ -262,6 +263,7 @@ class APITestCase(TestCase):
self._original_neutronclient = api.neutron.neutronclient
self._original_cinderclient = api.cinder.cinderclient
self._original_heatclient = api.heat.heatclient
self._original_ceilometerclient = api.ceilometer.ceilometerclient
# Replace the clients with our stubs.
api.glance.glanceclient = lambda request: self.stub_glanceclient()
@ -270,6 +272,8 @@ class APITestCase(TestCase):
api.neutron.neutronclient = lambda request: self.stub_neutronclient()
api.cinder.cinderclient = lambda request: self.stub_cinderclient()
api.heat.heatclient = lambda request: self.stub_heatclient()
api.ceilometer.ceilometerclient = lambda request: \
self.stub_ceilometerclient()
def tearDown(self):
super(APITestCase, self).tearDown()
@ -279,6 +283,7 @@ class APITestCase(TestCase):
api.neutron.neutronclient = self._original_neutronclient
api.cinder.cinderclient = self._original_cinderclient
api.heat.heatclient = self._original_heatclient
api.ceilometer.ceilometerclient = self._original_ceilometerclient
def stub_novaclient(self):
if not hasattr(self, "novaclient"):
@ -336,6 +341,13 @@ class APITestCase(TestCase):
self.heatclient = self.mox.CreateMock(heat_client.Client)
return self.heatclient
def stub_ceilometerclient(self):
if not hasattr(self, "ceilometerclient"):
self.mox.StubOutWithMock(ceilometer_client, 'Client')
self.ceilometerclient = self.mox.\
CreateMock(ceilometer_client.Client)
return self.ceilometerclient
@unittest.skipUnless(os.environ.get('WITH_SELENIUM', False),
"The WITH_SELENIUM env variable is not set.")