Make unit tests inherit from test.NoDBTestCase

This patch changes, where it's posible, tests-package
to using test.NoDBTestCase saving test case running time.

Co-Authored-By: yuntongjin <yuntongjin@gmail.com>
Change-Id: I95945f0bf23c9ef963a4b8634ac4ed6236d97ac7
This commit is contained in:
Mike Durnosvistov 2015-02-26 17:03:19 +02:00
parent d8c2e74f69
commit 92074e0fde
23 changed files with 39 additions and 39 deletions

View File

@ -18,7 +18,7 @@ from nova import objects
from nova import test from nova import test
class EC2UtilsTestCase(test.TestCase): class EC2UtilsTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
self.ctxt = context.get_admin_context() self.ctxt = context.get_admin_context()
ec2utils.reset_cache() ec2utils.reset_cache()

View File

@ -36,7 +36,7 @@ from nova.tests.unit import matchers
CONF = cfg.CONF CONF = cfg.CONF
class BlockDeviceMappingTestV21(test.TestCase): class BlockDeviceMappingTestV21(test.NoDBTestCase):
validation_error = exception.ValidationError validation_error = exception.ValidationError
def _setup_controller(self): def _setup_controller(self):

View File

@ -34,7 +34,7 @@ from nova.tests.unit.image import fake
CONF = cfg.CONF CONF = cfg.CONF
class BlockDeviceMappingTestV21(test.TestCase): class BlockDeviceMappingTestV21(test.NoDBTestCase):
validation_error = exception.ValidationError validation_error = exception.ValidationError
def _setup_controller(self): def _setup_controller(self):

View File

@ -616,7 +616,7 @@ class ControllerExtensionTest(ExtensionTestCase):
self.assertEqual(extension_body, response.body) self.assertEqual(extension_body, response.body)
class ExtensionControllerIdFormatTest(test.TestCase): class ExtensionControllerIdFormatTest(test.NoDBTestCase):
def _bounce_id(self, test_id): def _bounce_id(self, test_id):

View File

@ -36,7 +36,7 @@ NS = "{http://docs.openstack.org/compute/api/v1.1}"
ATOMNS = "{http://www.w3.org/2005/Atom}" ATOMNS = "{http://www.w3.org/2005/Atom}"
class LimiterTest(test.TestCase): class LimiterTest(test.NoDBTestCase):
"""Unit tests for the `nova.api.openstack.common.limited` method which """Unit tests for the `nova.api.openstack.common.limited` method which
takes in a list of items and, depending on the 'offset' and 'limit' GET takes in a list of items and, depending on the 'offset' and 'limit' GET
params, returns a subset or complete set of the given items. params, returns a subset or complete set of the given items.
@ -159,7 +159,7 @@ class LimiterTest(test.TestCase):
webob.exc.HTTPBadRequest, common.limited, self.tiny, req) webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
class SortParamUtilsTest(test.TestCase): class SortParamUtilsTest(test.NoDBTestCase):
def test_get_sort_params_defaults(self): def test_get_sort_params_defaults(self):
'''Verifies the default sort key and direction.''' '''Verifies the default sort key and direction.'''
@ -228,7 +228,7 @@ class SortParamUtilsTest(test.TestCase):
self.assertEqual(0, len(params)) self.assertEqual(0, len(params))
class PaginationParamsTest(test.TestCase): class PaginationParamsTest(test.NoDBTestCase):
"""Unit tests for the `nova.api.openstack.common.get_pagination_params` """Unit tests for the `nova.api.openstack.common.get_pagination_params`
method which takes in a request object and returns 'marker' and 'limit' method which takes in a request object and returns 'marker' and 'limit'
GET params. GET params.

View File

@ -23,7 +23,7 @@ from nova.api import compute_req_id
from nova import test from nova import test
class RequestIdTest(test.TestCase): class RequestIdTest(test.NoDBTestCase):
def test_generate_request_id(self): def test_generate_request_id(self):
@webob.dec.wsgify @webob.dec.wsgify
def application(req): def application(req):

View File

@ -24,7 +24,7 @@ from nova import exception
from nova import test from nova import test
class SerialTestCase(test.TestCase): class SerialTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(SerialTestCase, self).setUp() super(SerialTestCase, self).setUp()
serial.ALLOCATED_PORTS = set() serial.ALLOCATED_PORTS = set()

View File

@ -17,7 +17,7 @@ from nova.console import type as ctype
from nova import test from nova import test
class TypeTestCase(test.TestCase): class TypeTestCase(test.NoDBTestCase):
def test_console(self): def test_console(self):
c = ctype.Console(host='127.0.0.1', port=8945) c = ctype.Console(host='127.0.0.1', port=8945)

View File

@ -22,7 +22,7 @@ from nova import exception
from nova import test from nova import test
class NovaProxyRequestHandlerBaseTestCase(test.TestCase): class NovaProxyRequestHandlerBaseTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(NovaProxyRequestHandlerBaseTestCase, self).setUp() super(NovaProxyRequestHandlerBaseTestCase, self).setUp()

View File

@ -45,7 +45,7 @@ from nova import utils
FAKE_UUID = 'a47ae74e-ab08-547f-9eee-ffd23fc46c16' FAKE_UUID = 'a47ae74e-ab08-547f-9eee-ffd23fc46c16'
class NetworkPolicyTestCase(test.TestCase): class NetworkPolicyTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(NetworkPolicyTestCase, self).setUp() super(NetworkPolicyTestCase, self).setUp()
@ -544,7 +544,7 @@ class ApiTestCase(test.TestCase):
@mock.patch('nova.network.api.API') @mock.patch('nova.network.api.API')
@mock.patch('nova.db.instance_info_cache_update') @mock.patch('nova.db.instance_info_cache_update')
class TestUpdateInstanceCache(test.TestCase): class TestUpdateInstanceCache(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(TestUpdateInstanceCache, self).setUp() super(TestUpdateInstanceCache, self).setUp()
self.context = context.get_admin_context() self.context = context.get_admin_context()

View File

@ -2590,7 +2590,7 @@ class TestRPCFixedManager(network_manager.RPCAllocateFixedIP,
"""Dummy manager that implements RPCAllocateFixedIP.""" """Dummy manager that implements RPCAllocateFixedIP."""
class RPCAllocateTestCase(test.TestCase): class RPCAllocateTestCase(test.NoDBTestCase):
"""Tests nova.network.manager.RPCAllocateFixedIP.""" """Tests nova.network.manager.RPCAllocateFixedIP."""
def setUp(self): def setUp(self):
super(RPCAllocateTestCase, self).setUp() super(RPCAllocateTestCase, self).setUp()
@ -3301,7 +3301,7 @@ class FloatingIPTestCase(test.TestCase):
'public')) 'public'))
class InstanceDNSTestCase(test.TestCase): class InstanceDNSTestCase(test.NoDBTestCase):
"""Tests nova.network.manager instance DNS.""" """Tests nova.network.manager instance DNS."""
def setUp(self): def setUp(self):
super(InstanceDNSTestCase, self).setUp() super(InstanceDNSTestCase, self).setUp()
@ -3341,7 +3341,7 @@ domain1 = "example.org"
domain2 = "example.com" domain2 = "example.com"
class LdapDNSTestCase(test.TestCase): class LdapDNSTestCase(test.NoDBTestCase):
"""Tests nova.network.ldapdns.LdapDNS.""" """Tests nova.network.ldapdns.LdapDNS."""
def setUp(self): def setUp(self):
super(LdapDNSTestCase, self).setUp() super(LdapDNSTestCase, self).setUp()

View File

@ -98,7 +98,7 @@ class MyComparator(mox.Comparator):
return str(self.lhs) return str(self.lhs)
class TestNeutronClient(test.TestCase): class TestNeutronClient(test.NoDBTestCase):
def test_withtoken(self): def test_withtoken(self):
self.flags(url='http://anyhost/', group='neutron') self.flags(url='http://anyhost/', group='neutron')
self.flags(url_timeout=30, group='neutron') self.flags(url_timeout=30, group='neutron')
@ -193,7 +193,7 @@ class TestNeutronClient(test.TestCase):
self.assertEqual('new_token1', token_store.admin_auth_token) self.assertEqual('new_token1', token_store.admin_auth_token)
class TestNeutronv2Base(test.TestCase): class TestNeutronv2Base(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(TestNeutronv2Base, self).setUp() super(TestNeutronv2Base, self).setUp()
@ -2744,7 +2744,7 @@ class TestNeutronv2(TestNeutronv2Base):
self.assertEqual(expected_results, has_pci_request_id) self.assertEqual(expected_results, has_pci_request_id)
class TestNeutronv2WithMock(test.TestCase): class TestNeutronv2WithMock(test.NoDBTestCase):
"""Used to test Neutron V2 API with mock.""" """Used to test Neutron V2 API with mock."""
def setUp(self): def setUp(self):
@ -3102,7 +3102,7 @@ class TestNeutronv2WithMock(test.TestCase):
(net_objs[1].uuid, net_objs[1].name)) (net_objs[1].uuid, net_objs[1].name))
class TestNeutronv2ModuleMethods(test.TestCase): class TestNeutronv2ModuleMethods(test.NoDBTestCase):
def test_gather_port_ids_and_networks_wrong_params(self): def test_gather_port_ids_and_networks_wrong_params(self):
api = neutronapi.API() api = neutronapi.API()
@ -3322,7 +3322,7 @@ class TestNeutronv2ExtraDhcpOpts(TestNeutronv2Base):
self._allocate_for_instance(1, dhcp_options=dhcp_opts) self._allocate_for_instance(1, dhcp_options=dhcp_opts)
class TestNeutronClientForAdminScenarios(test.TestCase): class TestNeutronClientForAdminScenarios(test.NoDBTestCase):
def _test_get_client_for_admin(self, use_id=False, admin_context=False): def _test_get_client_for_admin(self, use_id=False, admin_context=False):

View File

@ -1480,7 +1480,7 @@ class TestRemoteInstanceListObject(test_objects._RemoteTest,
pass pass
class TestInstanceObjectMisc(test.TestCase): class TestInstanceObjectMisc(test.NoDBTestCase):
def test_expected_cols(self): def test_expected_cols(self):
self.stubs.Set(instance, '_INSTANCE_OPTIONAL_JOINED_FIELDS', ['bar']) self.stubs.Set(instance, '_INSTANCE_OPTIONAL_JOINED_FIELDS', ['bar'])
self.assertEqual(['bar'], instance._expected_cols(['foo', 'bar'])) self.assertEqual(['bar'], instance._expected_cols(['foo', 'bar']))

View File

@ -141,7 +141,7 @@ class TestSubclassedObject(RandomMixInWithNoFields, MyObj):
fields = {'new_field': fields.Field(fields.String())} fields = {'new_field': fields.Field(fields.String())}
class TestMetaclass(test.TestCase): class TestMetaclass(test.NoDBTestCase):
def test_obj_tracking(self): def test_obj_tracking(self):
@six.add_metaclass(base.NovaObjectMetaclass) @six.add_metaclass(base.NovaObjectMetaclass)
@ -206,7 +206,7 @@ class TestMetaclass(test.TestCase):
create_class, int) create_class, int)
class TestObjToPrimitive(test.TestCase): class TestObjToPrimitive(test.NoDBTestCase):
def test_obj_to_primitive_list(self): def test_obj_to_primitive_list(self):
class MyObjElement(base.NovaObject): class MyObjElement(base.NovaObject):
@ -249,7 +249,7 @@ class TestObjToPrimitive(test.TestCase):
base.obj_to_primitive(obj)) base.obj_to_primitive(obj))
class TestObjMakeList(test.TestCase): class TestObjMakeList(test.NoDBTestCase):
def test_obj_make_list(self): def test_obj_make_list(self):
class MyList(base.ObjectListBase, base.NovaObject): class MyList(base.ObjectListBase, base.NovaObject):
@ -956,7 +956,7 @@ class TestRemoteObject(_RemoteTest, _TestObject):
self.assertEqual('bar', obj.bar) self.assertEqual('bar', obj.bar)
class TestObjectListBase(test.TestCase): class TestObjectListBase(test.NoDBTestCase):
def test_list_like_operations(self): def test_list_like_operations(self):
class MyElement(base.NovaObject): class MyElement(base.NovaObject):
fields = {'foo': fields.IntegerField()} fields = {'foo': fields.IntegerField()}
@ -1278,7 +1278,7 @@ object_relationships = {
} }
class TestObjectVersions(test.TestCase): class TestObjectVersions(test.NoDBTestCase):
def _find_remotable_method(self, cls, thing, parent_was_remotable=False): def _find_remotable_method(self, cls, thing, parent_was_remotable=False):
"""Follow a chain of remotable things down to the original function.""" """Follow a chain of remotable things down to the original function."""
if isinstance(thing, classmethod): if isinstance(thing, classmethod):

View File

@ -41,7 +41,7 @@ dev_dict = {
} }
class PciDeviceTestCase(test.TestCase): class PciDeviceTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(PciDeviceTestCase, self).setUp() super(PciDeviceTestCase, self).setUp()
self.ctxt = context.get_admin_context() self.ctxt = context.get_admin_context()

View File

@ -78,7 +78,7 @@ fake_pci_requests = [
'spec': [{'vendor_id': 'v1'}]}] 'spec': [{'vendor_id': 'v1'}]}]
class PciDevTrackerTestCase(test.TestCase): class PciDevTrackerTestCase(test.NoDBTestCase):
def _create_fake_instance(self): def _create_fake_instance(self):
self.inst = objects.Instance() self.inst = objects.Instance()
self.inst.uuid = 'fake-inst-uuid' self.inst.uuid = 'fake-inst-uuid'

View File

@ -27,7 +27,7 @@ from nova import test
"""Tests for Scheduler Client.""" """Tests for Scheduler Client."""
class SchedulerReportClientTestCase(test.TestCase): class SchedulerReportClientTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(SchedulerReportClientTestCase, self).setUp() super(SchedulerReportClientTestCase, self).setUp()
@ -58,7 +58,7 @@ class SchedulerReportClientTestCase(test.TestCase):
self.context, ('fakehost', 'fakenode'), stats) self.context, ('fakehost', 'fakenode'), stats)
class SchedulerQueryClientTestCase(test.TestCase): class SchedulerQueryClientTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(SchedulerQueryClientTestCase, self).setUp() super(SchedulerQueryClientTestCase, self).setUp()
@ -82,7 +82,7 @@ class SchedulerQueryClientTestCase(test.TestCase):
'fake_prop') 'fake_prop')
class SchedulerClientTestCase(test.TestCase): class SchedulerClientTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(SchedulerClientTestCase, self).setUp() super(SchedulerClientTestCase, self).setUp()

View File

@ -57,7 +57,7 @@ class SchedulerManagerTestCase(test.NoDBTestCase):
select_destinations.assert_called_once_with(None, None, {}) select_destinations.assert_called_once_with(None, None, {})
class SchedulerV3PassthroughTestCase(test.TestCase): class SchedulerV3PassthroughTestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(SchedulerV3PassthroughTestCase, self).setUp() super(SchedulerV3PassthroughTestCase, self).setUp()
self.manager = manager.SchedulerManager() self.manager = manager.SchedulerManager()
@ -111,7 +111,7 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase):
self.driver.select_destinations, self.context, {}, {}) self.driver.select_destinations, self.context, {}, {})
class SchedulerInstanceGroupData(test.TestCase): class SchedulerInstanceGroupData(test.NoDBTestCase):
driver_cls = driver.Scheduler driver_cls = driver.Scheduler

View File

@ -25,7 +25,7 @@ class FakeRequest(object):
api_version_request = api_version.APIVersionRequest("2.1") api_version_request = api_version.APIVersionRequest("2.1")
class APIValidationTestCase(test.TestCase): class APIValidationTestCase(test.NoDBTestCase):
def check_validation_error(self, method, body, expected_detail): def check_validation_error(self, method, body, expected_detail):
try: try:

View File

@ -27,7 +27,7 @@ from nova import test
CONF = cfg.CONF CONF = cfg.CONF
class BaseAPITestCase(test.TestCase): class BaseAPITestCase(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(BaseAPITestCase, self).setUp() super(BaseAPITestCase, self).setUp()

View File

@ -24,7 +24,7 @@ from nova import utils
CONF = cfg.CONF CONF = cfg.CONF
class PipelibTest(test.TestCase): class PipelibTest(test.NoDBTestCase):
def setUp(self): def setUp(self):
super(PipelibTest, self).setUp() super(PipelibTest, self).setUp()
self.cloudpipe = pipelib.CloudPipe() self.cloudpipe = pipelib.CloudPipe()

View File

@ -23,7 +23,7 @@ from nova import utils
from nova.virt import volumeutils from nova.virt import volumeutils
class VolumeUtilsTestCase(test.TestCase): class VolumeUtilsTestCase(test.NoDBTestCase):
def test_get_iscsi_initiator(self): def test_get_iscsi_initiator(self):
self.mox.StubOutWithMock(utils, 'execute') self.mox.StubOutWithMock(utils, 'execute')
initiator = 'fake.initiator.iqn' initiator = 'fake.initiator.iqn'

View File

@ -24,7 +24,7 @@ from nova.volume.encryptors import luks
from nova.volume.encryptors import nop from nova.volume.encryptors import nop
class VolumeEncryptorTestCase(test.TestCase): class VolumeEncryptorTestCase(test.NoDBTestCase):
def _create(self, device_path): def _create(self, device_path):
pass pass