Merge "Replace tests.base part3"

This commit is contained in:
Jenkins 2013-10-23 07:51:27 +00:00 committed by Gerrit Code Review
commit 4e5ad43cee
10 changed files with 38 additions and 26 deletions

View File

@ -20,14 +20,16 @@
import mock
from ceilometer.tests import base as test_base
from ceilometer.openstack.common import test
from ceilometer.openstack.common.fixture import moxstubout
from ceilometer.compute.virt import inspector as virt_inspector
class TestPollsterBase(test_base.TestCase):
class TestPollsterBase(test.BaseTestCase):
def setUp(self):
super(TestPollsterBase, self).setUp()
self.mox = self.useFixture(moxstubout.MoxStubout()).mox
self.mox.StubOutWithMock(virt_inspector, 'get_hypervisor_inspector')
self.inspector = self.mox.CreateMock(virt_inspector.Inspector)
virt_inspector.get_hypervisor_inspector().AndReturn(self.inspector)

View File

@ -22,9 +22,9 @@
import mock
from ceilometer.openstack.common import test
from ceilometer.compute import manager
from ceilometer.compute.pollsters import util
from ceilometer.tests import base as test_base
class FauxInstance(object):
@ -43,7 +43,7 @@ class FauxInstance(object):
return default
class TestLocationMetadata(test_base.TestCase):
class TestLocationMetadata(test.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def setUp(self):

View File

@ -21,11 +21,12 @@ import mock
from ceilometer import nova_client
from ceilometer.compute import manager
from ceilometer.tests import base
from ceilometer.openstack.common import test
from ceilometer.openstack.common.fixture import moxstubout
from tests import agentbase
class TestManager(base.TestCase):
class TestManager(test.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_load_plugins(self):
@ -56,6 +57,7 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase):
# of instances to poll we can control the results.
self.instance = self._fake_instance('faux', 'active')
stillborn_instance = self._fake_instance('stillborn', 'error')
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
self.stubs.Set(nova_client.Client, 'instance_get_all_by_host',
lambda *x: [self.instance, stillborn_instance])

View File

@ -21,8 +21,8 @@
notification events.
"""
from ceilometer.tests import base
from ceilometer.compute import notifications
from ceilometer.openstack.common import test
from ceilometer import sample
@ -398,7 +398,7 @@ INSTANCE_SCHEDULED = {
}
class TestNotifications(base.TestCase):
class TestNotifications(test.BaseTestCase):
def test_process_notification(self):
info = list(notifications.Instance().process_notification(

View File

@ -20,10 +20,10 @@ Tests for Hyper-V inspector.
import mock
from ceilometer.compute.virt.hyperv import inspector as hyperv_inspector
from ceilometer.tests import base as test_base
from ceilometer.openstack.common import test
class TestHyperVInspection(test_base.TestCase):
class TestHyperVInspection(test.BaseTestCase):
def setUp(self):
self._inspector = hyperv_inspector.HyperVInspector()

View File

@ -21,10 +21,10 @@ import mock
from ceilometer.compute.virt import inspector
from ceilometer.compute.virt.hyperv import utilsv2 as utilsv2
from ceilometer.tests import base as test_base
from ceilometer.openstack.common import test
class TestUtilsV2(test_base.TestCase):
class TestUtilsV2(test.BaseTestCase):
def setUp(self):
self._utils = utilsv2.UtilsV2()

View File

@ -21,16 +21,18 @@
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.compute.virt.libvirt import inspector as libvirt_inspector
from ceilometer.tests import base as test_base
import fixtures
from ceilometer.openstack.common import test
from ceilometer.openstack.common.fixture import moxstubout
class TestLibvirtInspection(test_base.TestCase):
class TestLibvirtInspection(test.BaseTestCase):
def setUp(self):
super(TestLibvirtInspection, self).setUp()
self.instance_name = 'instance-00000001'
self.inspector = libvirt_inspector.LibvirtInspector()
self.mox = self.useFixture(moxstubout.MoxStubout()).mox
self.inspector.connection = self.mox.CreateMockAnything()
self.inspector.connection.getCapabilities()
self.domain = self.mox.CreateMockAnything()
@ -185,7 +187,7 @@ class TestLibvirtInspection(test_base.TestCase):
self.assertEqual(info0.write_bytes, 4L)
class TestLibvirtInspectionWithError(test_base.TestCase):
class TestLibvirtInspectionWithError(test.BaseTestCase):
def setUp(self):
super(TestLibvirtInspectionWithError, self).setUp()

View File

@ -17,10 +17,11 @@
import datetime
import mock
from ceilometer.tests import base
from ceilometer.energy import kwapi
from ceilometer.central import manager
from ceilometer.openstack.common import context
from ceilometer.openstack.common import test
from ceilometer.openstack.common.fixture import moxstubout
from keystoneclient import exceptions
@ -52,11 +53,12 @@ class TestManager(manager.AgentManager):
self.keystone = None
class TestKwapi(base.TestCase):
class TestKwapi(test.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def setUp(self):
super(TestKwapi, self).setUp()
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
self.context = context.get_admin_context()
self.manager = TestManager()
@ -72,11 +74,12 @@ class TestKwapi(base.TestCase):
self.assertEqual(len(samples), 0)
class TestEnergyPollster(base.TestCase):
class TestEnergyPollster(test.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def setUp(self):
super(TestEnergyPollster, self).setUp()
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
self.context = context.get_admin_context()
self.manager = TestManager()
self.stubs.Set(kwapi._Base, '_iter_probes',
@ -110,7 +113,7 @@ class TestEnergyPollster(base.TestCase):
# power_samples)))
class TestEnergyPollsterCache(base.TestCase):
class TestEnergyPollsterCache(test.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def setUp(self):
@ -132,11 +135,12 @@ class TestEnergyPollsterCache(base.TestCase):
self.assertEqual(len(samples), 1)
class TestPowerPollster(base.TestCase):
class TestPowerPollster(test.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def setUp(self):
super(TestPowerPollster, self).setUp()
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
self.context = context.get_admin_context()
self.manager = TestManager()
self.stubs.Set(kwapi._Base, '_iter_probes',
@ -167,7 +171,7 @@ class TestPowerPollster(base.TestCase):
self.assertEqual(sample.volume, probe['w'])
class TestPowerPollsterCache(base.TestCase):
class TestPowerPollsterCache(test.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def setUp(self):

View File

@ -26,14 +26,16 @@ from ceilometer.central import manager
from ceilometer.network import floatingip
from ceilometer import nova_client
from ceilometer.openstack.common import context
from ceilometer.tests import base
from ceilometer.openstack.common import test
from ceilometer.openstack.common.fixture import moxstubout
class TestFloatingIPPollster(base.TestCase):
class TestFloatingIPPollster(test.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def setUp(self):
super(TestFloatingIPPollster, self).setUp()
self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
self.context = context.get_admin_context()
self.manager = manager.AgentManager()
self.pollster = floatingip.FloatingIPPollster()

View File

@ -19,7 +19,7 @@
"""
from ceilometer.network import notifications
from ceilometer.tests import base
from ceilometer.openstack.common import test
NOTIFICATION_NETWORK_CREATE = {
u'_context_roles': [u'anotherrole',
@ -226,7 +226,7 @@ NOTIFICATION_L3_METER = {
u'_context_project_id': None}
class TestNotifications(base.TestCase):
class TestNotifications(test.BaseTestCase):
def test_network_create(self):
v = notifications.Network()
samples = list(v.process_notification(NOTIFICATION_NETWORK_CREATE))
@ -274,7 +274,7 @@ class TestNotifications(base.TestCase):
self.assertEqual(samples[0].name, "bandwidth")
class TestEventTypes(base.TestCase):
class TestEventTypes(test.BaseTestCase):
def test_network(self):
v = notifications.Network()