From fd5a3db0ce9808bc5a43288b50e00dc22aae9b82 Mon Sep 17 00:00:00 2001 From: Vladislav Kuzmin Date: Wed, 9 Oct 2013 06:53:23 -0400 Subject: [PATCH] Replace tests.base part5 It is the fifth step to replace using ceilometer.tests.base with openstack.common.test. In this patch is changed for using openstack.common.test and added needed fixtures in test classes. Change-Id: Ic7bed465f499f8546b86899f3345001bd16a9193 --- tests/test_middleware.py | 14 +++++++++----- tests/test_notifier.py | 4 ++-- tests/test_novaclient.py | 6 ++++-- tests/test_pipeline.py | 8 +++++--- tests/test_plugin.py | 4 ++-- tests/test_utils.py | 4 ++-- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/tests/test_middleware.py b/tests/test_middleware.py index ceea5899c..1c4287e38 100644 --- a/tests/test_middleware.py +++ b/tests/test_middleware.py @@ -15,9 +15,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from oslo.config import cfg - -from ceilometer.tests import base +from ceilometer.openstack.common import test +from ceilometer.openstack.common.fixture import config 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): sample = list(middleware.HTTPRequest().process_notification( HTTP_REQUEST @@ -97,5 +101,5 @@ class TestNotifications(base.TestCase): self.assertEqual(sample.volume, 1) 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) diff --git a/tests/test_notifier.py b/tests/test_notifier.py index 814dca11c..820932f41 100644 --- a/tests/test_notifier.py +++ b/tests/test_notifier.py @@ -21,7 +21,7 @@ from ceilometer import notifier from ceilometer import pipeline from ceilometer import transformer -from ceilometer.tests import base as tests_base +from ceilometer.openstack.common import test MESSAGE = { @@ -64,7 +64,7 @@ MESSAGE = { } -class TestNotifier(tests_base.TestCase): +class TestNotifier(test.BaseTestCase): def test_process_notification(self): transformer_manager = transformer.TransformerExtensionManager( diff --git a/tests/test_novaclient.py b/tests/test_novaclient.py index 2b563694e..72fbe32a4 100644 --- a/tests/test_novaclient.py +++ b/tests/test_novaclient.py @@ -20,15 +20,17 @@ import mock import novaclient -from ceilometer.tests import base 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): super(TestNovaClient, self).setUp() self.nv = nova_client.Client() + self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs self.stubs.Set(self.nv.nova_client.flavors, 'get', self.fake_flavors_get) self.stubs.Set(self.nv.nova_client.images, 'get', self.fake_images_get) diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index e00c60a09..5cfd965c6 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -27,12 +27,13 @@ from ceilometer.publisher import test as test_publisher from ceilometer import transformer from ceilometer.transformer import accumulator from ceilometer.transformer import conversions +from ceilometer.openstack.common import test from ceilometer.openstack.common import timeutils +from ceilometer.openstack.common.fixture import moxstubout from ceilometer import pipeline -from ceilometer.tests import base -class TestTransformerAccumulator(base.TestCase): +class TestTransformerAccumulator(test.BaseTestCase): def test_handle_sample(self): test_sample = sample.Sample( @@ -57,7 +58,7 @@ class TestTransformerAccumulator(base.TestCase): self.assertEqual(len(tf.samples), 1) -class TestPipeline(base.TestCase): +class TestPipeline(test.BaseTestCase): def fake_tem_init(self): """Fake a transformerManager for pipeline The faked entry point setting is below: @@ -148,6 +149,7 @@ class TestPipeline(base.TestCase): resource_metadata={} ) + self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs self.stubs.Set(transformer.TransformerExtensionManager, "__init__", self.fake_tem_init) diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 7cd9fc095..fd1ce45db 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -17,7 +17,7 @@ # under the License. from ceilometer import plugin -from ceilometer.tests import base +from ceilometer.openstack.common import test TEST_NOTIFICATION = { @@ -70,7 +70,7 @@ TEST_NOTIFICATION = { } -class NotificationBaseTestCase(base.TestCase): +class NotificationBaseTestCase(test.BaseTestCase): def test_handle_event_type(self): self.assertFalse(plugin.NotificationBase._handle_event_type( 'compute.instance.start', ['compute'])) diff --git a/tests/test_utils.py b/tests/test_utils.py index e5185abb1..7545648e0 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -22,11 +22,11 @@ import decimal import datetime -from ceilometer.tests import base as tests_base +from ceilometer.openstack.common import test from ceilometer import utils -class TestUtils(tests_base.TestCase): +class TestUtils(test.BaseTestCase): def test_datetime_to_decimal(self): expected = 1356093296.12