Add various initializations and imports so that unit tests can be run
independently.
This change fixes the following test cases which could not be run
independently, that is running any individual unit test case by going
in to the py27 venv and running
"unit2 neutron.tests.unit.module.Class.test_case":
neutron.tests.unit.plugins.ml2.drivers.arista.test_mechanism_arista.*
neutron.tests.unit.plugins.ml2.drivers.cisco.apic.*
neutron.tests.unit.plugins.ml2.test_rpc.RpcCallbacksTestCase.*
neutron.tests.unit.services.l3_router.test_l3_apic.*
neutron.tests.unit.agent.dhcp.test_agent.TestDhcpAgentEventHandler.*
(Note that these issues are not seen when running tox because the
initializations occur when all test modules are imported for test
discovery.)
Closes-bug:
1438463
Closes-bug:
1454640
Change-Id: I681caa66b51ce9a7bfbee5dfc43d534ba0d51947
config.register_interface_driver_opts_helper(cfg.CONF)
cfg.CONF.set_override('interface_driver',
'neutron.agent.linux.interface.NullDriver')
- cfg.CONF.register_opts(dhcp_config.DHCP_AGENT_OPTS)
- cfg.CONF.register_opts(dhcp_config.DHCP_OPTS)
+ entry.register_options() # register all dhcp cfg options
self.plugin_p = mock.patch(DHCP_PLUGIN)
plugin_cls = self.plugin_p.start()
import mock
from neutron.extensions import portbindings
+from neutron.tests.unit import testlib_api
+
with mock.patch.dict(sys.modules,
{'networking_arista': mock.Mock(),
'networking_arista.ml2': mock.Mock(),
'networking_arista.common': mock.Mock()}):
from neutron.plugins.ml2.drivers.arista import mechanism_arista
-from neutron.tests.unit import testlib_api
class AristaDriverTestCase(testlib_api.SqlTestCase):
(APIC_EXT_SWITCH, SERVICE_PEER_PORT_LOCAL.lower()))
+cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config')
+
+
class ControllerMixin(object):
"""Mock the controller for APIC driver and service unit tests."""
import contextlib
import mock
+from oslo_config import cfg
from oslo_context import context as oslo_context
from sqlalchemy.orm import exc
from neutron.tests import base
+cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config')
+
+
class RpcCallbacksTestCase(base.BaseTestCase):
def setUp(self):