From 06093adfafa330a0087cb834ada16fd33510e11b Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Thu, 9 May 2013 14:46:36 +1000 Subject: [PATCH] Get all tests to use tests.base.TestCase part of bug 1177924 Change-Id: If8124e2ca21bf9766adf770e30a630437c6fcd95 --- tests/api/v1/test_app.py | 5 +++-- tests/api/v2/test_app.py | 5 +++-- tests/api/v2/test_statistics.py | 5 +++-- tests/compute/test_instance.py | 5 ++--- tests/compute/test_notifications.py | 5 ++--- tests/image/test_notifications.py | 4 ++-- tests/network/test_notifications.py | 7 +++---- tests/storage/test_base.py | 4 ++-- tests/storage/test_models.py | 5 ++--- tests/test_bin.py | 15 +++++++++++---- tests/test_policy.py | 1 + tests/test_service.py | 5 ++--- tests/volume/test_notifications.py | 5 ++--- 13 files changed, 38 insertions(+), 33 deletions(-) diff --git a/tests/api/v1/test_app.py b/tests/api/v1/test_app.py index c38356ac1..f72b678a0 100644 --- a/tests/api/v1/test_app.py +++ b/tests/api/v1/test_app.py @@ -19,18 +19,19 @@ """ import os import tempfile -import unittest from oslo.config import cfg from ceilometer.api.v1 import app from ceilometer.api import acl from ceilometer import service +from ceilometer.tests import base -class TestApp(unittest.TestCase): +class TestApp(base.TestCase): def tearDown(self): + super(TestApp, self).tearDown() cfg.CONF.reset() def test_keystone_middleware_conf(self): diff --git a/tests/api/v2/test_app.py b/tests/api/v2/test_app.py index c7554c990..908e84016 100644 --- a/tests/api/v2/test_app.py +++ b/tests/api/v2/test_app.py @@ -19,19 +19,20 @@ """ import os import tempfile -import unittest from oslo.config import cfg from ceilometer.api import app from ceilometer.api import acl from ceilometer import service +from ceilometer.tests import base from .base import FunctionalTest -class TestApp(unittest.TestCase): +class TestApp(base.TestCase): def tearDown(self): + super(TestApp, self).tearDown() cfg.CONF.reset() def test_keystone_middleware_conf(self): diff --git a/tests/api/v2/test_statistics.py b/tests/api/v2/test_statistics.py index 9ac8ec433..7f82a3bdc 100644 --- a/tests/api/v2/test_statistics.py +++ b/tests/api/v2/test_statistics.py @@ -20,14 +20,15 @@ import datetime import logging -import unittest from ceilometer.api.controllers import v2 +from ceilometer.tests import base + LOG = logging.getLogger(__name__) -class TestStatisticsDuration(unittest.TestCase): +class TestStatisticsDuration(base.TestCase): def setUp(self): super(TestStatisticsDuration, self).setUp() diff --git a/tests/compute/test_instance.py b/tests/compute/test_instance.py index 09cc0afa5..e5bb06148 100644 --- a/tests/compute/test_instance.py +++ b/tests/compute/test_instance.py @@ -18,12 +18,11 @@ """Tests for ceilometer.compute.instance """ -import unittest - import mock from ceilometer.compute import instance from ceilometer.compute import manager +from ceilometer.tests import base class FauxInstance(object): @@ -42,7 +41,7 @@ class FauxInstance(object): return default -class TestLocationMetadata(unittest.TestCase): +class TestLocationMetadata(base.TestCase): @mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock()) def setUp(self): diff --git a/tests/compute/test_notifications.py b/tests/compute/test_notifications.py index 0e541b0a3..ba5d59d3e 100644 --- a/tests/compute/test_notifications.py +++ b/tests/compute/test_notifications.py @@ -19,8 +19,7 @@ notification events. """ -import unittest - +from ceilometer.tests import base from ceilometer.compute import notifications from ceilometer import counter @@ -352,7 +351,7 @@ INSTANCE_DELETE_SAMPLES = { } -class TestNotifications(unittest.TestCase): +class TestNotifications(base.TestCase): def test_process_notification(self): info = notifications.Instance().process_notification( diff --git a/tests/image/test_notifications.py b/tests/image/test_notifications.py index 0aba1aabe..625f03dee 100644 --- a/tests/image/test_notifications.py +++ b/tests/image/test_notifications.py @@ -18,10 +18,10 @@ # under the License. from datetime import datetime -import unittest from ceilometer.image import notifications from ceilometer import counter +from ceilometer.tests import base def fake_uuid(x): @@ -89,7 +89,7 @@ NOTIFICATION_DELETE = {"message_id": "0c65cb9c-018c-11e2-bc91-5453ed1bbb5f", "timestamp": NOW} -class TestNotification(unittest.TestCase): +class TestNotification(base.TestCase): def _verify_common_counter(self, c, name, volume): self.assertFalse(c is None) diff --git a/tests/network/test_notifications.py b/tests/network/test_notifications.py index 642653276..694565e18 100644 --- a/tests/network/test_notifications.py +++ b/tests/network/test_notifications.py @@ -18,9 +18,8 @@ """Tests for ceilometer.network.notifications """ -import unittest - from ceilometer.network import notifications +from ceilometer.tests import base NOTIFICATION_NETWORK_CREATE = { u'_context_roles': [u'anotherrole', @@ -204,7 +203,7 @@ NOTIFICATION_FLOATINGIP_EXISTS = { u'message_id': u'9e839576-cc47-4c60-a7d8-5743681213b1'} -class TestNotifications(unittest.TestCase): +class TestNotifications(base.TestCase): def test_network_create(self): v = notifications.Network() counters = list(v.process_notification(NOTIFICATION_NETWORK_CREATE)) @@ -246,7 +245,7 @@ class TestNotifications(unittest.TestCase): self.assertEqual(counters[0].name, "ip.floating") -class TestEventTypes(unittest.TestCase): +class TestEventTypes(base.TestCase): def test_network(self): v = notifications.Network() diff --git a/tests/storage/test_base.py b/tests/storage/test_base.py index 187e2b78c..76a3693e9 100644 --- a/tests/storage/test_base.py +++ b/tests/storage/test_base.py @@ -17,12 +17,12 @@ # under the License. import datetime import math -import unittest from ceilometer.storage import base +from ceilometer.tests import base as test_base -class BaseTest(unittest.TestCase): +class BaseTest(test_base.TestCase): def test_iter_period(self): times = list(base.iter_period( diff --git a/tests/storage/test_models.py b/tests/storage/test_models.py index a3e73d14d..752c1141e 100644 --- a/tests/storage/test_models.py +++ b/tests/storage/test_models.py @@ -16,9 +16,8 @@ # License for the specific language governing permissions and limitations # under the License. -import unittest - from ceilometer.storage import models +from ceilometer.tests import base class FakeModel(models.Model): @@ -26,7 +25,7 @@ class FakeModel(models.Model): models.Model.__init__(self, arg1=arg1, arg2=arg2) -class ModelTest(unittest.TestCase): +class ModelTest(base.TestCase): def test_create_attributes(self): m = FakeModel(1, 2) diff --git a/tests/test_bin.py b/tests/test_bin.py index 2725f5b3d..8e5ae2e27 100644 --- a/tests/test_bin.py +++ b/tests/test_bin.py @@ -25,11 +25,13 @@ import socket import subprocess import tempfile import time -import unittest + +from ceilometer.tests import base -class BinDbsyncTestCase(unittest.TestCase): +class BinDbsyncTestCase(base.TestCase): def setUp(self): + super(BinDbsyncTestCase, self).setUp() self.tempfile = tempfile.mktemp() with open(self.tempfile, 'w') as tmp: tmp.write("[DEFAULT]\n") @@ -41,11 +43,13 @@ class BinDbsyncTestCase(unittest.TestCase): self.assertEqual(subp.wait(), 0) def tearDown(self): + super(BinDbsyncTestCase, self).tearDown() os.unlink(self.tempfile) -class BinSendCounterTestCase(unittest.TestCase): +class BinSendCounterTestCase(base.TestCase): def setUp(self): + super(BinSendCounterTestCase, self).setUp() self.tempfile = tempfile.mktemp() with open(self.tempfile, 'w') as tmp: tmp.write("[DEFAULT]\n") @@ -62,12 +66,14 @@ class BinSendCounterTestCase(unittest.TestCase): self.assertEqual(subp.wait(), 0) def tearDown(self): + super(BinSendCounterTestCase, self).tearDown() os.unlink(self.tempfile) -class BinApiTestCase(unittest.TestCase): +class BinApiTestCase(base.TestCase): def setUp(self): + super(BinApiTestCase, self).setUp() self.api_port = random.randint(10000, 11000) self.http = httplib2.Http() self.tempfile = tempfile.mktemp() @@ -88,6 +94,7 @@ class BinApiTestCase(unittest.TestCase): "--config-file=%s" % self.tempfile]) def tearDown(self): + super(BinApiTestCase, self).tearDown() os.unlink(self.tempfile) self.subp.kill() self.subp.wait() diff --git a/tests/test_policy.py b/tests/test_policy.py index 0b36727dc..c6f804886 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -34,6 +34,7 @@ class TestPolicy(base.TestCase): policy._POLICY_CACHE = {} def tearDown(self): + super(TestPolicy, self).tearDown() try: os.unlink(cfg.CONF.policy_file) except OSError: diff --git a/tests/test_service.py b/tests/test_service.py index 91bfe12d1..9c481747e 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -17,11 +17,10 @@ # License for the specific language governing permissions and limitations # under the License. -import unittest - from ceilometer import service +from ceilometer.tests import base -class ServiceTestCase(unittest.TestCase): +class ServiceTestCase(base.TestCase): def test_prepare_service(self): service.prepare_service() diff --git a/tests/volume/test_notifications.py b/tests/volume/test_notifications.py index 31489e714..c76313e7c 100644 --- a/tests/volume/test_notifications.py +++ b/tests/volume/test_notifications.py @@ -1,6 +1,5 @@ -import unittest - from ceilometer.volume import notifications +from ceilometer.tests import base NOTIFICATION_VOLUME_EXISTS = { u'_context_roles': [u'admin'], @@ -61,7 +60,7 @@ NOTIFICATION_VOLUME_DELETE = { u'priority': u'INFO'} -class TestNotifications(unittest.TestCase): +class TestNotifications(base.TestCase): def _verify_common_counter(self, c, name, notification): self.assertFalse(c is None)