Merge "Use DbTestCase as test base when context needed"

This commit is contained in:
Jenkins 2014-10-01 11:29:03 +00:00 committed by Gerrit Code Review
commit 2dc0408569
22 changed files with 49 additions and 132 deletions

View File

@ -34,7 +34,6 @@ from ironic.conductor import utils as conductor_utils
from ironic.db import api as dbapi
from ironic.drivers import base as drivers_base
from ironic import objects
from ironic.openstack.common import context
from ironic.tests import base as tests_base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as tests_db_base
@ -1475,11 +1474,10 @@ class ManagerSpawnWorkerTestCase(tests_base.TestCase):
@mock.patch.object(conductor_utils, 'node_power_action')
class ManagerDoSyncPowerStateTestCase(tests_base.TestCase):
class ManagerDoSyncPowerStateTestCase(tests_db_base.DbTestCase):
def setUp(self):
super(ManagerDoSyncPowerStateTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic')
self.context = context.get_admin_context()
self.driver = mock.Mock(spec_set=drivers_base.BaseDriver)
self.power = self.driver.power
self.node = mock.Mock(spec_set=objects.Node)
@ -1673,13 +1671,12 @@ class ManagerDoSyncPowerStateTestCase(tests_base.TestCase):
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(objects.Node, 'get_by_id')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerSyncPowerStatesTestCase(_CommonMixIn, tests_base.TestCase):
class ManagerSyncPowerStatesTestCase(_CommonMixIn, tests_db_base.DbTestCase):
def setUp(self):
super(ManagerSyncPowerStatesTestCase, self).setUp()
self.service = manager.ConductorManager('hostname', 'test-topic')
self.dbapi = dbapi.get_instance()
self.service.dbapi = self.dbapi
self.context = context.get_admin_context()
self.node = self._create_node()
self.filters = {'reserved': False, 'maintenance': False}
self.columns = ['id', 'uuid', 'driver']
@ -1939,11 +1936,11 @@ class ManagerSyncPowerStatesTestCase(_CommonMixIn, tests_base.TestCase):
@mock.patch.object(task_manager, 'acquire')
@mock.patch.object(manager.ConductorManager, '_mapped_to_this_conductor')
@mock.patch.object(dbapi.IMPL, 'get_nodeinfo_list')
class ManagerCheckDeployTimeoutsTestCase(_CommonMixIn, tests_base.TestCase):
class ManagerCheckDeployTimeoutsTestCase(_CommonMixIn,
tests_db_base.DbTestCase):
def setUp(self):
super(ManagerCheckDeployTimeoutsTestCase, self).setUp()
self.config(deploy_callback_timeout=300, group='conductor')
self.context = context.get_admin_context()
self.service = manager.ConductorManager('hostname', 'test-topic')
self.dbapi = dbapi.get_instance()
self.service.dbapi = self.dbapi

View File

@ -19,7 +19,6 @@ from ironic.common import dhcp_factory
from ironic.common import exception
from ironic.dhcp import neutron
from ironic.dhcp import none
from ironic.openstack.common import context
from ironic.tests import base
@ -31,7 +30,6 @@ class TestDHCPFactory(base.TestCase):
self.config(url='test-url',
url_timeout=30,
group='neutron')
self.context = context.get_admin_context()
dhcp_factory.DHCPFactory._dhcp_provider = None
def test_default_dhcp(self):

View File

@ -24,13 +24,12 @@ from ironic.common import pxe_utils
from ironic.common import utils
from ironic.conductor import task_manager
from ironic.dhcp import neutron
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.objects import utils as object_utils
class TestNeutron(base.TestCase):
class TestNeutron(db_base.DbTestCase):
def setUp(self):
super(TestNeutron, self).setUp()
@ -48,7 +47,6 @@ class TestNeutron(base.TestCase):
admin_password='test-admin-password',
auth_uri='test-auth-uri',
group='keystone_authtoken')
self.context = context.get_admin_context()
self.node = object_utils.create_test_node(self.context)
dhcp_factory.DHCPFactory._dhcp_provider = None

View File

@ -21,19 +21,14 @@ from testtools.matchers import HasLength
from ironic.common import exception
from ironic.drivers.modules.drac import common as drac_common
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
from ironic.tests.objects import utils as obj_utils
INFO_DICT = db_utils.get_test_drac_info()
class DracCommonMethodsTestCase(base.TestCase):
def setUp(self):
super(DracCommonMethodsTestCase, self).setUp()
self.context = context.get_admin_context()
class DracCommonMethodsTestCase(db_base.DbTestCase):
def test_parse_driver_info(self):
node = obj_utils.create_test_node(self.context,

View File

@ -27,9 +27,8 @@ from ironic.drivers.modules.drac import client as drac_client
from ironic.drivers.modules.drac import common as drac_common
from ironic.drivers.modules.drac import management as drac_mgmt
from ironic.drivers.modules.drac import resource_uris
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
from ironic.tests.drivers.drac import utils as test_utils
from ironic.tests.objects import utils as obj_utils
@ -38,12 +37,11 @@ INFO_DICT = db_utils.get_test_drac_info()
@mock.patch.object(drac_client, 'pywsman')
class DracManagementInternalMethodsTestCase(base.TestCase):
class DracManagementInternalMethodsTestCase(db_base.DbTestCase):
def setUp(self):
super(DracManagementInternalMethodsTestCase, self).setUp()
mgr_utils.mock_the_extension_manager(driver='fake_drac')
self.context = context.get_admin_context()
self.node = obj_utils.create_test_node(self.context,
driver='fake_drac',
driver_info=INFO_DICT)
@ -152,12 +150,11 @@ class DracManagementInternalMethodsTestCase(base.TestCase):
@mock.patch.object(drac_client, 'pywsman')
class DracManagementTestCase(base.TestCase):
class DracManagementTestCase(db_base.DbTestCase):
def setUp(self):
super(DracManagementTestCase, self).setUp()
mgr_utils.mock_the_extension_manager(driver='fake_drac')
self.context = context.get_admin_context()
self.node = obj_utils.create_test_node(self.context,
driver='fake_drac',
driver_info=INFO_DICT)

View File

@ -24,7 +24,6 @@ from ironic.drivers.modules.drac import client as drac_client
from ironic.drivers.modules.drac import common as drac_common
from ironic.drivers.modules.drac import power as drac_power
from ironic.drivers.modules.drac import resource_uris
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.db import utils as db_utils
from ironic.tests.drivers.drac import utils as test_utils
@ -118,7 +117,6 @@ class DracPowerTestCase(base.TestCase):
instance_uuid='instance_uuid_123')
self.dbapi = dbapi.get_instance()
self.node = self.dbapi.create_node(db_node)
self.context = context.get_admin_context()
def test_get_properties(self):
expected = drac_common.COMMON_PROPERTIES

View File

@ -29,9 +29,8 @@ from ironic.conductor import task_manager
from ironic.db import api as dbapi
from ironic.drivers.modules.ilo import common as ilo_common
from ironic.drivers import utils as driver_utils
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
from ironic.tests.objects import utils as obj_utils
@ -42,12 +41,11 @@ INFO_DICT = db_utils.get_test_ilo_info()
CONF = cfg.CONF
class IloValidateParametersTestCase(base.TestCase):
class IloValidateParametersTestCase(db_base.DbTestCase):
def setUp(self):
super(IloValidateParametersTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
def test_parse_driver_info(self):
node = obj_utils.create_test_node(self.context,
@ -115,12 +113,11 @@ class IloValidateParametersTestCase(base.TestCase):
self.assertIn('ilo_address', str(e))
class IloCommonMethodsTestCase(base.TestCase):
class IloCommonMethodsTestCase(db_base.DbTestCase):
def setUp(self):
super(IloCommonMethodsTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager(driver="fake_ilo")
self.node = obj_utils.create_test_node(self.context,
driver='fake_ilo', driver_info=INFO_DICT)

View File

@ -35,10 +35,9 @@ from ironic.drivers.modules.ilo import deploy as ilo_deploy
from ironic.drivers.modules import iscsi_deploy
from ironic.drivers.modules import pxe
from ironic.drivers import utils as driver_utils
from ironic.openstack.common import context
from ironic.openstack.common import importutils
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
from ironic.tests.objects import utils as obj_utils
@ -49,12 +48,11 @@ INFO_DICT = db_utils.get_test_ilo_info()
CONF = cfg.CONF
class IloDeployPrivateMethodsTestCase(base.TestCase):
class IloDeployPrivateMethodsTestCase(db_base.DbTestCase):
def setUp(self):
super(IloDeployPrivateMethodsTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager(driver="iscsi_ilo")
self.node = obj_utils.create_test_node(self.context,
driver='iscsi_ilo', driver_info=INFO_DICT)
@ -196,12 +194,11 @@ class IloDeployPrivateMethodsTestCase(base.TestCase):
node_power_action_mock.assert_called_once_with(task, states.REBOOT)
class IloVirtualMediaIscsiDeployTestCase(base.TestCase):
class IloVirtualMediaIscsiDeployTestCase(db_base.DbTestCase):
def setUp(self):
super(IloVirtualMediaIscsiDeployTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager(driver="iscsi_ilo")
self.node = obj_utils.create_test_node(self.context,
driver='iscsi_ilo', driver_info=INFO_DICT)
@ -273,12 +270,11 @@ class IloVirtualMediaIscsiDeployTestCase(base.TestCase):
clean_up_boot_mock.assert_called_once_with(task.node)
class IloVirtualMediaAgentDeployTestCase(base.TestCase):
class IloVirtualMediaAgentDeployTestCase(db_base.DbTestCase):
def setUp(self):
super(IloVirtualMediaAgentDeployTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager(driver="agent_ilo")
self.node = obj_utils.create_test_node(self.context,
driver='agent_ilo', driver_info=INFO_DICT)
@ -326,12 +322,11 @@ class IloVirtualMediaAgentDeployTestCase(base.TestCase):
self.assertEqual(deploy_opts, task.node.instance_info)
class VendorPassthruTestCase(base.TestCase):
class VendorPassthruTestCase(db_base.DbTestCase):
def setUp(self):
super(VendorPassthruTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager(driver="iscsi_ilo")
self.node = obj_utils.create_test_node(self.context,
driver='iscsi_ilo', driver_info=INFO_DICT)
@ -394,12 +389,11 @@ class VendorPassthruTestCase(base.TestCase):
continue_deploy_mock.assert_called_once_with(task, **kwargs)
class IloPXEDeployTestCase(base.TestCase):
class IloPXEDeployTestCase(db_base.DbTestCase):
def setUp(self):
super(IloPXEDeployTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager(driver="pxe_ilo")
self.node = obj_utils.create_test_node(self.context,
driver='pxe_ilo', driver_info=INFO_DICT)
@ -451,12 +445,11 @@ class IloPXEDeployTestCase(base.TestCase):
pxe_deploy_mock.assert_called_once_with(task)
class IloManagementTestCase(base.TestCase):
class IloManagementTestCase(db_base.DbTestCase):
def setUp(self):
super(IloManagementTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager(driver="pxe_ilo")
self.node = obj_utils.create_test_node(self.context,
driver='pxe_ilo', driver_info=INFO_DICT)
@ -478,12 +471,11 @@ class IloManagementTestCase(base.TestCase):
task, 'fake-device')
class IloPXEVendorPassthruTestCase(base.TestCase):
class IloPXEVendorPassthruTestCase(db_base.DbTestCase):
def setUp(self):
super(IloPXEVendorPassthruTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager(driver="pxe_ilo")
self.node = obj_utils.create_test_node(self.context,
driver='pxe_ilo', driver_info=INFO_DICT)

View File

@ -26,9 +26,8 @@ from ironic.db import api as dbapi
from ironic.drivers.modules.ilo import common as ilo_common
from ironic.drivers.modules.ilo import deploy as ilo_deploy
from ironic.drivers.modules.ilo import power as ilo_power
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
from ironic.tests.objects import utils as obj_utils
@ -40,7 +39,7 @@ CONF = cfg.CONF
@mock.patch.object(ilo_common, 'ilo_client')
@mock.patch.object(ilo_power, 'ilo_client')
class IloPowerInternalMethodsTestCase(base.TestCase):
class IloPowerInternalMethodsTestCase(db_base.DbTestCase):
def setUp(self):
super(IloPowerInternalMethodsTestCase, self).setUp()
@ -52,7 +51,6 @@ class IloPowerInternalMethodsTestCase(base.TestCase):
instance_uuid='instance_uuid_123')
self.dbapi = dbapi.get_instance()
self.node = self.dbapi.create_node(n)
self.context = context.get_admin_context()
CONF.set_override('power_retry', 2, 'ilo')
CONF.set_override('power_wait', 0, 'ilo')
@ -159,10 +157,9 @@ class IloPowerInternalMethodsTestCase(base.TestCase):
set_boot_device_mock.assert_called_once_with(task.node, 'CDROM')
class IloPowerTestCase(base.TestCase):
class IloPowerTestCase(db_base.DbTestCase):
def setUp(self):
self.context = context.get_admin_context()
super(IloPowerTestCase, self).setUp()
driver_info = INFO_DICT
mgr_utils.mock_the_extension_manager(driver="fake_ilo")

View File

@ -30,9 +30,8 @@ from ironic.common import exception
from ironic.common import utils
from ironic.drivers.modules import console_utils
from ironic.drivers.modules import ipmitool as ipmi
from ironic.openstack.common import context
from ironic.openstack.common import processutils
from ironic.tests import base
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
from ironic.tests.objects import utils as obj_utils
@ -42,11 +41,10 @@ CONF = cfg.CONF
INFO_DICT = db_utils.get_test_ipmi_info()
class ConsoleUtilsTestCase(base.TestCase):
class ConsoleUtilsTestCase(db_base.DbTestCase):
def setUp(self):
super(ConsoleUtilsTestCase, self).setUp()
self.context = context.get_admin_context()
self.node = obj_utils.get_test_node(
self.context,
driver='fake_ipmitool',

View File

@ -25,17 +25,15 @@ from ironic.common import exception
from ironic.common import states
from ironic.conductor import task_manager
from ironic.drivers import base as driver_base
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.objects import utils as obj_utils
class FakeDriverTestCase(base.TestCase):
class FakeDriverTestCase(db_base.DbTestCase):
def setUp(self):
super(FakeDriverTestCase, self).setUp()
self.context = context.get_admin_context()
mgr_utils.mock_the_extension_manager()
self.driver = driver_factory.get_driver("fake")
self.node = obj_utils.get_test_node(self.context)

View File

@ -25,8 +25,6 @@ from ironic.common import states
from ironic.conductor import task_manager
from ironic.db import api as dbapi
from ironic.drivers.modules import iboot
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
@ -36,12 +34,11 @@ from ironic.tests.objects import utils as obj_utils
INFO_DICT = db_utils.get_test_iboot_info()
class IBootPrivateMethodTestCase(base.TestCase):
class IBootPrivateMethodTestCase(db_base.DbTestCase):
def setUp(self):
super(IBootPrivateMethodTestCase, self).setUp()
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
def test__parse_driver_info_good(self):
node = obj_utils.create_test_node(

View File

@ -33,8 +33,6 @@ from ironic.conductor import task_manager
from ironic.db import api as db_api
from ironic.drivers.modules import console_utils
from ironic.drivers.modules import ipminative
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
@ -45,12 +43,11 @@ CONF = cfg.CONF
INFO_DICT = db_utils.get_test_ipmi_info()
class IPMINativePrivateMethodTestCase(base.TestCase):
class IPMINativePrivateMethodTestCase(db_base.DbTestCase):
"""Test cases for ipminative private methods."""
def setUp(self):
super(IPMINativePrivateMethodTestCase, self).setUp()
self.context = context.get_admin_context()
self.node = obj_utils.create_test_node(self.context,
driver='fake_ipminative',
driver_info=INFO_DICT)

View File

@ -36,7 +36,6 @@ from ironic.conductor import task_manager
from ironic.db import api as db_api
from ironic.drivers.modules import console_utils
from ironic.drivers.modules import ipmitool as ipmi
from ironic.openstack.common import context
from ironic.openstack.common import processutils
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
@ -213,11 +212,10 @@ class IPMIToolCheckOptionSupportedTestCase(base.TestCase):
@mock.patch.object(time, 'sleep')
class IPMIToolPrivateMethodTestCase(base.TestCase):
class IPMIToolPrivateMethodTestCase(db_base.DbTestCase):
def setUp(self):
super(IPMIToolPrivateMethodTestCase, self).setUp()
self.context = context.get_admin_context()
self.node = obj_utils.get_test_node(
self.context,
driver='fake_ipmitool',

View File

@ -26,9 +26,7 @@ from ironic.common import utils
from ironic.db import api as dbapi
from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules import iscsi_deploy
from ironic.openstack.common import context
from ironic.openstack.common import fileutils
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
@ -40,11 +38,10 @@ INST_INFO_DICT = db_utils.get_test_pxe_instance_info()
DRV_INFO_DICT = db_utils.get_test_pxe_driver_info()
class IscsiDeployValidateParametersTestCase(base.TestCase):
class IscsiDeployValidateParametersTestCase(db_base.DbTestCase):
def setUp(self):
super(IscsiDeployValidateParametersTestCase, self).setUp()
self.context = context.get_admin_context()
self.dbapi = dbapi.get_instance()
def test_parse_instance_info_good(self):

View File

@ -37,10 +37,8 @@ from ironic.db import api as dbapi
from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules import iscsi_deploy
from ironic.drivers.modules import pxe
from ironic.openstack.common import context
from ironic.openstack.common import fileutils
from ironic.openstack.common import jsonutils as json
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
@ -52,11 +50,10 @@ INST_INFO_DICT = db_utils.get_test_pxe_instance_info()
DRV_INFO_DICT = db_utils.get_test_pxe_driver_info()
class PXEValidateParametersTestCase(base.TestCase):
class PXEValidateParametersTestCase(db_base.DbTestCase):
def setUp(self):
super(PXEValidateParametersTestCase, self).setUp()
self.context = context.get_admin_context()
self.dbapi = dbapi.get_instance()
def test__parse_deploy_info(self):

View File

@ -26,8 +26,6 @@ from ironic.common import utils
from ironic.conductor import task_manager
from ironic.db import api as dbapi
from ironic.drivers.modules import seamicro
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
@ -79,10 +77,7 @@ class Fake_Pool():
self.freeSize = freeSize
class SeaMicroValidateParametersTestCase(base.TestCase):
def setUp(self):
super(SeaMicroValidateParametersTestCase, self).setUp()
self.context = context.get_admin_context()
class SeaMicroValidateParametersTestCase(db_base.DbTestCase):
def test__parse_driver_info_good(self):
# make sure we get back the expected things
@ -134,7 +129,7 @@ class SeaMicroValidateParametersTestCase(base.TestCase):
node)
class SeaMicroPrivateMethodsTestCase(base.TestCase):
class SeaMicroPrivateMethodsTestCase(db_base.DbTestCase):
def setUp(self):
super(SeaMicroPrivateMethodsTestCase, self).setUp()
@ -142,7 +137,6 @@ class SeaMicroPrivateMethodsTestCase(base.TestCase):
'driver': 'fake_seamicro',
'driver_info': INFO_DICT
}
self.context = context.get_admin_context()
self.dbapi = dbapi.get_instance()
self.node = obj_utils.create_test_node(self.context, **n)
self.Server = Fake_Server

View File

@ -31,7 +31,6 @@ from ironic.common import states
from ironic.conductor import task_manager
from ironic.db import api as db_api
from ironic.drivers.modules import snmp as snmp
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
@ -164,11 +163,7 @@ class SNMPClientTestCase(base.TestCase):
var_bind)
class SNMPValidateParametersTestCase(base.TestCase):
def setUp(self):
super(SNMPValidateParametersTestCase, self).setUp()
self.context = context.get_admin_context()
class SNMPValidateParametersTestCase(db_base.DbTestCase):
def _get_test_node(self, driver_info):
return obj_utils.get_test_node(
@ -352,7 +347,7 @@ class SNMPValidateParametersTestCase(base.TestCase):
@mock.patch.object(snmp, '_get_client')
class SNMPDeviceDriverTestCase(base.TestCase):
class SNMPDeviceDriverTestCase(db_base.DbTestCase):
"""Tests for the SNMP device-specific driver classes.
The SNMP client object is mocked to allow various error cases to be tested.
@ -360,7 +355,6 @@ class SNMPDeviceDriverTestCase(base.TestCase):
def setUp(self):
super(SNMPDeviceDriverTestCase, self).setUp()
self.context = context.get_admin_context()
self.node = obj_utils.get_test_node(
self.context,
driver='fake_snmp',

View File

@ -28,9 +28,7 @@ from ironic.conductor import task_manager
from ironic.db import api as dbapi
from ironic.drivers.modules import ssh
from ironic.drivers import utils as driver_utils
from ironic.openstack.common import context
from ironic.openstack.common import processutils
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
@ -41,10 +39,7 @@ from oslo.config import cfg
CONF = cfg.CONF
class SSHValidateParametersTestCase(base.TestCase):
def setUp(self):
super(SSHValidateParametersTestCase, self).setUp()
self.context = context.get_admin_context()
class SSHValidateParametersTestCase(db_base.DbTestCase):
def test__parse_driver_info_good_password(self):
# make sure we get back the expected things
@ -195,11 +190,10 @@ class SSHValidateParametersTestCase(base.TestCase):
'this_doesn_t_exist')
class SSHPrivateMethodsTestCase(base.TestCase):
class SSHPrivateMethodsTestCase(db_base.DbTestCase):
def setUp(self):
super(SSHPrivateMethodsTestCase, self).setUp()
self.context = context.get_admin_context()
self.node = obj_utils.get_test_node(
self.context,
driver='fake_ssh',

View File

@ -21,17 +21,15 @@ from ironic.conductor import task_manager
from ironic.db import api as db_api
from ironic.drivers.modules import fake
from ironic.drivers import utils as driver_utils
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.objects import utils as obj_utils
class UtilsTestCase(base.TestCase):
class UtilsTestCase(db_base.DbTestCase):
def setUp(self):
super(UtilsTestCase, self).setUp()
self.context = context.get_admin_context()
self.dbapi = db_api.get_instance()
mgr_utils.mock_the_extension_manager()
self.driver = driver_factory.get_driver("fake")

View File

@ -26,6 +26,7 @@ from ironic.objects import base
from ironic.objects import utils
from ironic.openstack.common import context
from ironic.tests import base as test_base
from ironic.tests.db import base as db_base
gettext.install('ironic')
@ -123,11 +124,7 @@ class TestMetaclass(test_base.TestCase):
self.assertEqual(expected, Test2._obj_classes)
class TestUtils(test_base.TestCase):
def setUp(self):
super(TestUtils, self).setUp()
self.context = context.get_admin_context()
class TestUtils(db_base.DbTestCase):
def test_datetime_or_none(self):
naive_dt = datetime.datetime.now()
@ -215,11 +212,10 @@ class TestUtils(test_base.TestCase):
base.obj_to_primitive(mylist))
class _BaseTestCase(test_base.TestCase):
class _BaseTestCase(db_base.DbTestCase):
def setUp(self):
super(_BaseTestCase, self).setUp()
self.remote_object_calls = list()
self.context = context.get_admin_context()
class _LocalTest(_BaseTestCase):
@ -517,11 +513,7 @@ class TestObject(_LocalTest, _TestObject):
pass
class TestObjectListBase(test_base.TestCase):
def setUp(self):
super(TestObjectListBase, self).setUp()
self.context = context.get_admin_context()
class TestObjectListBase(db_base.DbTestCase):
def test_list_like_operations(self):
class Foo(base.ObjectListBase, base.IronicObject):
@ -598,11 +590,7 @@ class TestObjectListBase(test_base.TestCase):
self.assertEqual(set(), obj.obj_what_changed())
class TestObjectSerializer(test_base.TestCase):
def setUp(self):
super(TestObjectSerializer, self).setUp()
self.context = context.get_admin_context()
class TestObjectSerializer(db_base.DbTestCase):
def test_serialize_entity_primitive(self):
ser = base.IronicObjectSerializer()

View File

@ -17,20 +17,18 @@ from ironic.common import network
from ironic.common import utils
from ironic.conductor import task_manager
from ironic.db import api as dbapi
from ironic.openstack.common import context
from ironic.tests import base
from ironic.tests.conductor import utils as mgr_utils
from ironic.tests.db import base as db_base
from ironic.tests.db import utils as db_utils
from ironic.tests.objects import utils as object_utils
class TestNetwork(base.TestCase):
class TestNetwork(db_base.DbTestCase):
def setUp(self):
super(TestNetwork, self).setUp()
mgr_utils.mock_the_extension_manager(driver='fake')
self.dbapi = dbapi.get_instance()
self.context = context.get_admin_context()
self.node = object_utils.create_test_node(self.context)
def _create_test_port(self, **kwargs):