Merge "Replace tests.base part5"

This commit is contained in:
Jenkins 2013-10-29 07:28:44 +00:00 committed by Gerrit Code Review
commit a1c39e26cd
6 changed files with 24 additions and 16 deletions

View File

@ -15,9 +15,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo.config import cfg from ceilometer.openstack.common import test
from ceilometer.openstack.common.fixture import config
from ceilometer.tests import base
from ceilometer import middleware from ceilometer import middleware
@ -67,7 +66,12 @@ HTTP_RESPONSE = {
} }
class TestNotifications(base.TestCase): class TestNotifications(test.BaseTestCase):
def setUp(self):
super(TestNotifications, self).setUp()
self.CONF = self.useFixture(config.Config()).conf
def test_process_request_notification(self): def test_process_request_notification(self):
sample = list(middleware.HTTPRequest().process_notification( sample = list(middleware.HTTPRequest().process_notification(
HTTP_REQUEST HTTP_REQUEST
@ -97,5 +101,5 @@ class TestNotifications(base.TestCase):
self.assertEqual(sample.volume, 1) self.assertEqual(sample.volume, 1)
def test_exchanges(self): def test_exchanges(self):
topics = middleware.HTTPRequest().get_exchange_topics(cfg.CONF) topics = middleware.HTTPRequest().get_exchange_topics(self.CONF)
self.assertEqual(len(topics), 4) self.assertEqual(len(topics), 4)

View File

@ -21,7 +21,7 @@
from ceilometer import notifier from ceilometer import notifier
from ceilometer import pipeline from ceilometer import pipeline
from ceilometer import transformer from ceilometer import transformer
from ceilometer.tests import base as tests_base from ceilometer.openstack.common import test
MESSAGE = { MESSAGE = {
@ -64,7 +64,7 @@ MESSAGE = {
} }
class TestNotifier(tests_base.TestCase): class TestNotifier(test.BaseTestCase):
def test_process_notification(self): def test_process_notification(self):
transformer_manager = transformer.TransformerExtensionManager( transformer_manager = transformer.TransformerExtensionManager(

View File

@ -20,15 +20,17 @@
import mock import mock
import novaclient import novaclient
from ceilometer.tests import base
from ceilometer import nova_client from ceilometer import nova_client
from ceilometer.openstack.common import test
from ceilometer.openstack.common.fixture import moxstubout
class TestNovaClient(base.TestCase): class TestNovaClient(test.BaseTestCase):
def setUp(self): def setUp(self):
super(TestNovaClient, self).setUp() super(TestNovaClient, self).setUp()
self.nv = nova_client.Client() self.nv = nova_client.Client()
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
self.stubs.Set(self.nv.nova_client.flavors, 'get', self.stubs.Set(self.nv.nova_client.flavors, 'get',
self.fake_flavors_get) self.fake_flavors_get)
self.stubs.Set(self.nv.nova_client.images, 'get', self.fake_images_get) self.stubs.Set(self.nv.nova_client.images, 'get', self.fake_images_get)

View File

@ -27,12 +27,13 @@ from ceilometer.publisher import test as test_publisher
from ceilometer import transformer from ceilometer import transformer
from ceilometer.transformer import accumulator from ceilometer.transformer import accumulator
from ceilometer.transformer import conversions from ceilometer.transformer import conversions
from ceilometer.openstack.common import test
from ceilometer.openstack.common import timeutils from ceilometer.openstack.common import timeutils
from ceilometer.openstack.common.fixture import moxstubout
from ceilometer import pipeline from ceilometer import pipeline
from ceilometer.tests import base
class TestTransformerAccumulator(base.TestCase): class TestTransformerAccumulator(test.BaseTestCase):
def test_handle_sample(self): def test_handle_sample(self):
test_sample = sample.Sample( test_sample = sample.Sample(
@ -57,7 +58,7 @@ class TestTransformerAccumulator(base.TestCase):
self.assertEqual(len(tf.samples), 1) self.assertEqual(len(tf.samples), 1)
class TestPipeline(base.TestCase): class TestPipeline(test.BaseTestCase):
def fake_tem_init(self): def fake_tem_init(self):
"""Fake a transformerManager for pipeline """Fake a transformerManager for pipeline
The faked entry point setting is below: The faked entry point setting is below:
@ -148,6 +149,7 @@ class TestPipeline(base.TestCase):
resource_metadata={} resource_metadata={}
) )
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
self.stubs.Set(transformer.TransformerExtensionManager, self.stubs.Set(transformer.TransformerExtensionManager,
"__init__", "__init__",
self.fake_tem_init) self.fake_tem_init)

View File

@ -17,7 +17,7 @@
# under the License. # under the License.
from ceilometer import plugin from ceilometer import plugin
from ceilometer.tests import base from ceilometer.openstack.common import test
TEST_NOTIFICATION = { TEST_NOTIFICATION = {
@ -70,7 +70,7 @@ TEST_NOTIFICATION = {
} }
class NotificationBaseTestCase(base.TestCase): class NotificationBaseTestCase(test.BaseTestCase):
def test_handle_event_type(self): def test_handle_event_type(self):
self.assertFalse(plugin.NotificationBase._handle_event_type( self.assertFalse(plugin.NotificationBase._handle_event_type(
'compute.instance.start', ['compute'])) 'compute.instance.start', ['compute']))

View File

@ -22,11 +22,11 @@
import decimal import decimal
import datetime import datetime
from ceilometer.tests import base as tests_base from ceilometer.openstack.common import test
from ceilometer import utils from ceilometer import utils
class TestUtils(tests_base.TestCase): class TestUtils(test.BaseTestCase):
def test_datetime_to_decimal(self): def test_datetime_to_decimal(self):
expected = 1356093296.12 expected = 1356093296.12