Skip to content

Commit

Permalink
Make unit tests inherit from test.NoDBTestCase
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mike Durnosvistov and yuntongjin committed Mar 6, 2015
1 parent d8c2e74 commit 92074e0
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion nova/tests/unit/api/ec2/test_ec2utils.py
Expand Up @@ -18,7 +18,7 @@
from nova import test


class EC2UtilsTestCase(test.TestCase):
class EC2UtilsTestCase(test.NoDBTestCase):
def setUp(self):
self.ctxt = context.get_admin_context()
ec2utils.reset_cache()
Expand Down
Expand Up @@ -36,7 +36,7 @@
CONF = cfg.CONF


class BlockDeviceMappingTestV21(test.TestCase):
class BlockDeviceMappingTestV21(test.NoDBTestCase):
validation_error = exception.ValidationError

def _setup_controller(self):
Expand Down
Expand Up @@ -34,7 +34,7 @@
CONF = cfg.CONF


class BlockDeviceMappingTestV21(test.TestCase):
class BlockDeviceMappingTestV21(test.NoDBTestCase):
validation_error = exception.ValidationError

def _setup_controller(self):
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/api/openstack/compute/test_extensions.py
Expand Up @@ -616,7 +616,7 @@ def test_controller_action_extension_late(self):
self.assertEqual(extension_body, response.body)


class ExtensionControllerIdFormatTest(test.TestCase):
class ExtensionControllerIdFormatTest(test.NoDBTestCase):

def _bounce_id(self, test_id):

Expand Down
6 changes: 3 additions & 3 deletions nova/tests/unit/api/openstack/test_common.py
Expand Up @@ -36,7 +36,7 @@
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.
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_limiter_negative_offset(self):
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.'''
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_get_sort_params_multiple_values(self):
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.
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/api/test_compute_req_id.py
Expand Up @@ -23,7 +23,7 @@
from nova import test


class RequestIdTest(test.TestCase):
class RequestIdTest(test.NoDBTestCase):
def test_generate_request_id(self):
@webob.dec.wsgify
def application(req):
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/console/test_serial.py
Expand Up @@ -24,7 +24,7 @@
from nova import test


class SerialTestCase(test.TestCase):
class SerialTestCase(test.NoDBTestCase):
def setUp(self):
super(SerialTestCase, self).setUp()
serial.ALLOCATED_PORTS = set()
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/console/test_type.py
Expand Up @@ -17,7 +17,7 @@
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)

Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/console/test_websocketproxy.py
Expand Up @@ -22,7 +22,7 @@
from nova import test


class NovaProxyRequestHandlerBaseTestCase(test.TestCase):
class NovaProxyRequestHandlerBaseTestCase(test.NoDBTestCase):

def setUp(self):
super(NovaProxyRequestHandlerBaseTestCase, self).setUp()
Expand Down
4 changes: 2 additions & 2 deletions nova/tests/unit/network/test_api.py
Expand Up @@ -45,7 +45,7 @@
FAKE_UUID = 'a47ae74e-ab08-547f-9eee-ffd23fc46c16'


class NetworkPolicyTestCase(test.TestCase):
class NetworkPolicyTestCase(test.NoDBTestCase):
def setUp(self):
super(NetworkPolicyTestCase, self).setUp()

Expand Down Expand Up @@ -544,7 +544,7 @@ def test_setup_instance_network_on_host(self, fake_migrate_finish):

@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()
Expand Down
6 changes: 3 additions & 3 deletions nova/tests/unit/network/test_manager.py
Expand Up @@ -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()
Expand Down Expand Up @@ -3301,7 +3301,7 @@ def test_floating_ip_pool_does_not_exist(self, floating_ip_get_pools):
'public'))


class InstanceDNSTestCase(test.TestCase):
class InstanceDNSTestCase(test.NoDBTestCase):
"""Tests nova.network.manager instance DNS."""
def setUp(self):
super(InstanceDNSTestCase, self).setUp()
Expand Down Expand Up @@ -3341,7 +3341,7 @@ def test_dns_domains_private(self):
domain2 = "example.com"


class LdapDNSTestCase(test.TestCase):
class LdapDNSTestCase(test.NoDBTestCase):
"""Tests nova.network.ldapdns.LdapDNS."""
def setUp(self):
super(LdapDNSTestCase, self).setUp()
Expand Down
10 changes: 5 additions & 5 deletions nova/tests/unit/network/test_neutronv2.py
Expand Up @@ -98,7 +98,7 @@ def __repr__(self):
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')
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_admin_token_updated(self):
self.assertEqual('new_token1', token_store.admin_auth_token)


class TestNeutronv2Base(test.TestCase):
class TestNeutronv2Base(test.NoDBTestCase):

def setUp(self):
super(TestNeutronv2Base, self).setUp()
Expand Down Expand Up @@ -2744,7 +2744,7 @@ def test_create_pci_requests_for_sriov_ports(self, mock_get_client,
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):
Expand Down Expand Up @@ -3102,7 +3102,7 @@ def test_get_all_networks(self):
(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()
Expand Down Expand Up @@ -3322,7 +3322,7 @@ def test_allocate_for_instance_extradhcpopts(self):
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):

Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/objects/test_instance.py
Expand Up @@ -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']))
Expand Down
10 changes: 5 additions & 5 deletions nova/tests/unit/objects/test_objects.py
Expand Up @@ -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)
Expand Down Expand Up @@ -206,7 +206,7 @@ class TestField(base.NovaObject):
create_class, int)


class TestObjToPrimitive(test.TestCase):
class TestObjToPrimitive(test.NoDBTestCase):

def test_obj_to_primitive_list(self):
class MyObjElement(base.NovaObject):
Expand Down Expand Up @@ -249,7 +249,7 @@ class TestObject(base.NovaObject):
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):
Expand Down Expand Up @@ -956,7 +956,7 @@ def test_revision_ignored(self):
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()}
Expand Down Expand Up @@ -1278,7 +1278,7 @@ def test_object_serialization_iterables(self):
}


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):
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/pci/test_device.py
Expand Up @@ -41,7 +41,7 @@
}


class PciDeviceTestCase(test.TestCase):
class PciDeviceTestCase(test.NoDBTestCase):
def setUp(self):
super(PciDeviceTestCase, self).setUp()
self.ctxt = context.get_admin_context()
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/pci/test_manager.py
Expand Up @@ -78,7 +78,7 @@
'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'
Expand Down
6 changes: 3 additions & 3 deletions nova/tests/unit/scheduler/test_client.py
Expand Up @@ -27,7 +27,7 @@
"""Tests for Scheduler Client."""


class SchedulerReportClientTestCase(test.TestCase):
class SchedulerReportClientTestCase(test.NoDBTestCase):

def setUp(self):
super(SchedulerReportClientTestCase, self).setUp()
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_update_compute_node_raises(self):
self.context, ('fakehost', 'fakenode'), stats)


class SchedulerQueryClientTestCase(test.TestCase):
class SchedulerQueryClientTestCase(test.NoDBTestCase):

def setUp(self):
super(SchedulerQueryClientTestCase, self).setUp()
Expand All @@ -82,7 +82,7 @@ def test_select_destinations(self, mock_select_destinations):
'fake_prop')


class SchedulerClientTestCase(test.TestCase):
class SchedulerClientTestCase(test.NoDBTestCase):

def setUp(self):
super(SchedulerClientTestCase, self).setUp()
Expand Down
4 changes: 2 additions & 2 deletions nova/tests/unit/scheduler/test_scheduler.py
Expand Up @@ -57,7 +57,7 @@ def test_select_destination(self):
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()
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_unimplemented_select_destinations(self):
self.driver.select_destinations, self.context, {}, {})


class SchedulerInstanceGroupData(test.TestCase):
class SchedulerInstanceGroupData(test.NoDBTestCase):

driver_cls = driver.Scheduler

Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/test_api_validation.py
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/test_baserpc.py
Expand Up @@ -27,7 +27,7 @@
CONF = cfg.CONF


class BaseAPITestCase(test.TestCase):
class BaseAPITestCase(test.NoDBTestCase):

def setUp(self):
super(BaseAPITestCase, self).setUp()
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/test_pipelib.py
Expand Up @@ -24,7 +24,7 @@
CONF = cfg.CONF


class PipelibTest(test.TestCase):
class PipelibTest(test.NoDBTestCase):
def setUp(self):
super(PipelibTest, self).setUp()
self.cloudpipe = pipelib.CloudPipe()
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/virt/test_volumeutils.py
Expand Up @@ -23,7 +23,7 @@
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'
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/volume/encryptors/test_base.py
Expand Up @@ -24,7 +24,7 @@
from nova.volume.encryptors import nop


class VolumeEncryptorTestCase(test.TestCase):
class VolumeEncryptorTestCase(test.NoDBTestCase):
def _create(self, device_path):
pass

Expand Down

0 comments on commit 92074e0

Please sign in to comment.