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:
parent
d8c2e74f69
commit
92074e0fde
|
@ -18,7 +18,7 @@ from nova import objects
|
|||
from nova import test
|
||||
|
||||
|
||||
class EC2UtilsTestCase(test.TestCase):
|
||||
class EC2UtilsTestCase(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
self.ctxt = context.get_admin_context()
|
||||
ec2utils.reset_cache()
|
||||
|
|
|
@ -36,7 +36,7 @@ from nova.tests.unit import matchers
|
|||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class BlockDeviceMappingTestV21(test.TestCase):
|
||||
class BlockDeviceMappingTestV21(test.NoDBTestCase):
|
||||
validation_error = exception.ValidationError
|
||||
|
||||
def _setup_controller(self):
|
||||
|
|
|
@ -34,7 +34,7 @@ from nova.tests.unit.image import fake
|
|||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class BlockDeviceMappingTestV21(test.TestCase):
|
||||
class BlockDeviceMappingTestV21(test.NoDBTestCase):
|
||||
validation_error = exception.ValidationError
|
||||
|
||||
def _setup_controller(self):
|
||||
|
|
|
@ -616,7 +616,7 @@ class ControllerExtensionTest(ExtensionTestCase):
|
|||
self.assertEqual(extension_body, response.body)
|
||||
|
||||
|
||||
class ExtensionControllerIdFormatTest(test.TestCase):
|
||||
class ExtensionControllerIdFormatTest(test.NoDBTestCase):
|
||||
|
||||
def _bounce_id(self, test_id):
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ NS = "{http://docs.openstack.org/compute/api/v1.1}"
|
|||
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
|
||||
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.
|
||||
|
@ -159,7 +159,7 @@ class LimiterTest(test.TestCase):
|
|||
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
|
||||
|
||||
|
||||
class SortParamUtilsTest(test.TestCase):
|
||||
class SortParamUtilsTest(test.NoDBTestCase):
|
||||
|
||||
def test_get_sort_params_defaults(self):
|
||||
'''Verifies the default sort key and direction.'''
|
||||
|
@ -228,7 +228,7 @@ class SortParamUtilsTest(test.TestCase):
|
|||
self.assertEqual(0, len(params))
|
||||
|
||||
|
||||
class PaginationParamsTest(test.TestCase):
|
||||
class PaginationParamsTest(test.NoDBTestCase):
|
||||
"""Unit tests for the `nova.api.openstack.common.get_pagination_params`
|
||||
method which takes in a request object and returns 'marker' and 'limit'
|
||||
GET params.
|
||||
|
|
|
@ -23,7 +23,7 @@ from nova.api import compute_req_id
|
|||
from nova import test
|
||||
|
||||
|
||||
class RequestIdTest(test.TestCase):
|
||||
class RequestIdTest(test.NoDBTestCase):
|
||||
def test_generate_request_id(self):
|
||||
@webob.dec.wsgify
|
||||
def application(req):
|
||||
|
|
|
@ -24,7 +24,7 @@ from nova import exception
|
|||
from nova import test
|
||||
|
||||
|
||||
class SerialTestCase(test.TestCase):
|
||||
class SerialTestCase(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(SerialTestCase, self).setUp()
|
||||
serial.ALLOCATED_PORTS = set()
|
||||
|
|
|
@ -17,7 +17,7 @@ from nova.console import type as ctype
|
|||
from nova import test
|
||||
|
||||
|
||||
class TypeTestCase(test.TestCase):
|
||||
class TypeTestCase(test.NoDBTestCase):
|
||||
def test_console(self):
|
||||
c = ctype.Console(host='127.0.0.1', port=8945)
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ from nova import exception
|
|||
from nova import test
|
||||
|
||||
|
||||
class NovaProxyRequestHandlerBaseTestCase(test.TestCase):
|
||||
class NovaProxyRequestHandlerBaseTestCase(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NovaProxyRequestHandlerBaseTestCase, self).setUp()
|
||||
|
|
|
@ -45,7 +45,7 @@ from nova import utils
|
|||
FAKE_UUID = 'a47ae74e-ab08-547f-9eee-ffd23fc46c16'
|
||||
|
||||
|
||||
class NetworkPolicyTestCase(test.TestCase):
|
||||
class NetworkPolicyTestCase(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(NetworkPolicyTestCase, self).setUp()
|
||||
|
||||
|
@ -544,7 +544,7 @@ class ApiTestCase(test.TestCase):
|
|||
|
||||
@mock.patch('nova.network.api.API')
|
||||
@mock.patch('nova.db.instance_info_cache_update')
|
||||
class TestUpdateInstanceCache(test.TestCase):
|
||||
class TestUpdateInstanceCache(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(TestUpdateInstanceCache, self).setUp()
|
||||
self.context = context.get_admin_context()
|
||||
|
|
|
@ -2590,7 +2590,7 @@ class TestRPCFixedManager(network_manager.RPCAllocateFixedIP,
|
|||
"""Dummy manager that implements RPCAllocateFixedIP."""
|
||||
|
||||
|
||||
class RPCAllocateTestCase(test.TestCase):
|
||||
class RPCAllocateTestCase(test.NoDBTestCase):
|
||||
"""Tests nova.network.manager.RPCAllocateFixedIP."""
|
||||
def setUp(self):
|
||||
super(RPCAllocateTestCase, self).setUp()
|
||||
|
@ -3301,7 +3301,7 @@ class FloatingIPTestCase(test.TestCase):
|
|||
'public'))
|
||||
|
||||
|
||||
class InstanceDNSTestCase(test.TestCase):
|
||||
class InstanceDNSTestCase(test.NoDBTestCase):
|
||||
"""Tests nova.network.manager instance DNS."""
|
||||
def setUp(self):
|
||||
super(InstanceDNSTestCase, self).setUp()
|
||||
|
@ -3341,7 +3341,7 @@ domain1 = "example.org"
|
|||
domain2 = "example.com"
|
||||
|
||||
|
||||
class LdapDNSTestCase(test.TestCase):
|
||||
class LdapDNSTestCase(test.NoDBTestCase):
|
||||
"""Tests nova.network.ldapdns.LdapDNS."""
|
||||
def setUp(self):
|
||||
super(LdapDNSTestCase, self).setUp()
|
||||
|
|
|
@ -98,7 +98,7 @@ class MyComparator(mox.Comparator):
|
|||
return str(self.lhs)
|
||||
|
||||
|
||||
class TestNeutronClient(test.TestCase):
|
||||
class TestNeutronClient(test.NoDBTestCase):
|
||||
def test_withtoken(self):
|
||||
self.flags(url='http://anyhost/', 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)
|
||||
|
||||
|
||||
class TestNeutronv2Base(test.TestCase):
|
||||
class TestNeutronv2Base(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNeutronv2Base, self).setUp()
|
||||
|
@ -2744,7 +2744,7 @@ class TestNeutronv2(TestNeutronv2Base):
|
|||
self.assertEqual(expected_results, has_pci_request_id)
|
||||
|
||||
|
||||
class TestNeutronv2WithMock(test.TestCase):
|
||||
class TestNeutronv2WithMock(test.NoDBTestCase):
|
||||
"""Used to test Neutron V2 API with mock."""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -3102,7 +3102,7 @@ class TestNeutronv2WithMock(test.TestCase):
|
|||
(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):
|
||||
api = neutronapi.API()
|
||||
|
@ -3322,7 +3322,7 @@ class TestNeutronv2ExtraDhcpOpts(TestNeutronv2Base):
|
|||
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):
|
||||
|
||||
|
|
|
@ -1480,7 +1480,7 @@ class TestRemoteInstanceListObject(test_objects._RemoteTest,
|
|||
pass
|
||||
|
||||
|
||||
class TestInstanceObjectMisc(test.TestCase):
|
||||
class TestInstanceObjectMisc(test.NoDBTestCase):
|
||||
def test_expected_cols(self):
|
||||
self.stubs.Set(instance, '_INSTANCE_OPTIONAL_JOINED_FIELDS', ['bar'])
|
||||
self.assertEqual(['bar'], instance._expected_cols(['foo', 'bar']))
|
||||
|
|
|
@ -141,7 +141,7 @@ class TestSubclassedObject(RandomMixInWithNoFields, MyObj):
|
|||
fields = {'new_field': fields.Field(fields.String())}
|
||||
|
||||
|
||||
class TestMetaclass(test.TestCase):
|
||||
class TestMetaclass(test.NoDBTestCase):
|
||||
def test_obj_tracking(self):
|
||||
|
||||
@six.add_metaclass(base.NovaObjectMetaclass)
|
||||
|
@ -206,7 +206,7 @@ class TestMetaclass(test.TestCase):
|
|||
create_class, int)
|
||||
|
||||
|
||||
class TestObjToPrimitive(test.TestCase):
|
||||
class TestObjToPrimitive(test.NoDBTestCase):
|
||||
|
||||
def test_obj_to_primitive_list(self):
|
||||
class MyObjElement(base.NovaObject):
|
||||
|
@ -249,7 +249,7 @@ class TestObjToPrimitive(test.TestCase):
|
|||
base.obj_to_primitive(obj))
|
||||
|
||||
|
||||
class TestObjMakeList(test.TestCase):
|
||||
class TestObjMakeList(test.NoDBTestCase):
|
||||
|
||||
def test_obj_make_list(self):
|
||||
class MyList(base.ObjectListBase, base.NovaObject):
|
||||
|
@ -956,7 +956,7 @@ class TestRemoteObject(_RemoteTest, _TestObject):
|
|||
self.assertEqual('bar', obj.bar)
|
||||
|
||||
|
||||
class TestObjectListBase(test.TestCase):
|
||||
class TestObjectListBase(test.NoDBTestCase):
|
||||
def test_list_like_operations(self):
|
||||
class MyElement(base.NovaObject):
|
||||
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):
|
||||
"""Follow a chain of remotable things down to the original function."""
|
||||
if isinstance(thing, classmethod):
|
||||
|
|
|
@ -41,7 +41,7 @@ dev_dict = {
|
|||
}
|
||||
|
||||
|
||||
class PciDeviceTestCase(test.TestCase):
|
||||
class PciDeviceTestCase(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(PciDeviceTestCase, self).setUp()
|
||||
self.ctxt = context.get_admin_context()
|
||||
|
|
|
@ -78,7 +78,7 @@ fake_pci_requests = [
|
|||
'spec': [{'vendor_id': 'v1'}]}]
|
||||
|
||||
|
||||
class PciDevTrackerTestCase(test.TestCase):
|
||||
class PciDevTrackerTestCase(test.NoDBTestCase):
|
||||
def _create_fake_instance(self):
|
||||
self.inst = objects.Instance()
|
||||
self.inst.uuid = 'fake-inst-uuid'
|
||||
|
|
|
@ -27,7 +27,7 @@ from nova import test
|
|||
"""Tests for Scheduler Client."""
|
||||
|
||||
|
||||
class SchedulerReportClientTestCase(test.TestCase):
|
||||
class SchedulerReportClientTestCase(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SchedulerReportClientTestCase, self).setUp()
|
||||
|
@ -58,7 +58,7 @@ class SchedulerReportClientTestCase(test.TestCase):
|
|||
self.context, ('fakehost', 'fakenode'), stats)
|
||||
|
||||
|
||||
class SchedulerQueryClientTestCase(test.TestCase):
|
||||
class SchedulerQueryClientTestCase(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SchedulerQueryClientTestCase, self).setUp()
|
||||
|
@ -82,7 +82,7 @@ class SchedulerQueryClientTestCase(test.TestCase):
|
|||
'fake_prop')
|
||||
|
||||
|
||||
class SchedulerClientTestCase(test.TestCase):
|
||||
class SchedulerClientTestCase(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SchedulerClientTestCase, self).setUp()
|
||||
|
|
|
@ -57,7 +57,7 @@ class SchedulerManagerTestCase(test.NoDBTestCase):
|
|||
select_destinations.assert_called_once_with(None, None, {})
|
||||
|
||||
|
||||
class SchedulerV3PassthroughTestCase(test.TestCase):
|
||||
class SchedulerV3PassthroughTestCase(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(SchedulerV3PassthroughTestCase, self).setUp()
|
||||
self.manager = manager.SchedulerManager()
|
||||
|
@ -111,7 +111,7 @@ class SchedulerDriverBaseTestCase(SchedulerTestCase):
|
|||
self.driver.select_destinations, self.context, {}, {})
|
||||
|
||||
|
||||
class SchedulerInstanceGroupData(test.TestCase):
|
||||
class SchedulerInstanceGroupData(test.NoDBTestCase):
|
||||
|
||||
driver_cls = driver.Scheduler
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class FakeRequest(object):
|
|||
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):
|
||||
try:
|
||||
|
|
|
@ -27,7 +27,7 @@ from nova import test
|
|||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class BaseAPITestCase(test.TestCase):
|
||||
class BaseAPITestCase(test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(BaseAPITestCase, self).setUp()
|
||||
|
|
|
@ -24,7 +24,7 @@ from nova import utils
|
|||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class PipelibTest(test.TestCase):
|
||||
class PipelibTest(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(PipelibTest, self).setUp()
|
||||
self.cloudpipe = pipelib.CloudPipe()
|
||||
|
|
|
@ -23,7 +23,7 @@ from nova import utils
|
|||
from nova.virt import volumeutils
|
||||
|
||||
|
||||
class VolumeUtilsTestCase(test.TestCase):
|
||||
class VolumeUtilsTestCase(test.NoDBTestCase):
|
||||
def test_get_iscsi_initiator(self):
|
||||
self.mox.StubOutWithMock(utils, 'execute')
|
||||
initiator = 'fake.initiator.iqn'
|
||||
|
|
|
@ -24,7 +24,7 @@ from nova.volume.encryptors import luks
|
|||
from nova.volume.encryptors import nop
|
||||
|
||||
|
||||
class VolumeEncryptorTestCase(test.TestCase):
|
||||
class VolumeEncryptorTestCase(test.NoDBTestCase):
|
||||
def _create(self, device_path):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue