Ensure options are registered for unit testing
As part of commit [1] we moved the register options to a function,
that means unit tests need to be updated to register those option
in the setup if they are needed, otherwise we can get errors like:
Captured traceback:
~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/builddir/build/BUILD/ovn-bgp-agent-0.3.1.dev112/ovn_bgp_agent/tests/unit/drivers/openstack/watchers/test_bgp_watcher.py", line 878, in test_run_no_subnets_datapath
CONF.set_override('expose_tenant_networks', False)
File "/usr/lib/python3.9/site-packages/oslo_config/cfg.py", line 2059, in __inner
result = f(self, *args, **kwargs)
File "/usr/lib/python3.9/site-packages/oslo_config/cfg.py", line 2442, in set_override
opt_info = self._get_opt_info(name, group)
File "/usr/lib/python3.9/site-packages/oslo_config/cfg.py", line 2858, in _get_opt_info
raise NoSuchOptError(opt_name, group)
oslo_config.cfg.NoSuchOptError: no such option expose_tenant_networks in group [DEFAULT]
[1] 90b6940b21
Change-Id: I138ab9a4ed6f7b1d0138129c00362f603fc4320a
This commit is contained in:
parent
2d29afc58f
commit
a1ff266565
@ -17,6 +17,7 @@ from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from ovn_bgp_agent import config
|
||||
from ovn_bgp_agent import constants
|
||||
from ovn_bgp_agent.drivers.openstack.watchers import bgp_watcher
|
||||
from ovn_bgp_agent.tests import base as test_base
|
||||
@ -839,6 +840,7 @@ class TestOVNLBMemberCreateEvent(test_base.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOVNLBMemberCreateEvent, self).setUp()
|
||||
config.register_opts()
|
||||
self.chassis = '935f91fa-b8f8-47b9-8b1b-3a7a90ef7c26'
|
||||
self.agent = mock.Mock(chassis=self.chassis)
|
||||
self.agent.ovn_local_cr_lrps = {
|
||||
|
@ -16,15 +16,11 @@
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from ovn_bgp_agent import constants
|
||||
from ovn_bgp_agent.drivers.openstack.watchers import nb_bgp_watcher
|
||||
from ovn_bgp_agent.tests import base as test_base
|
||||
from ovn_bgp_agent.tests import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestLogicalSwitchPortProviderCreateEvent(test_base.TestCase):
|
||||
|
||||
|
@ -21,16 +21,18 @@ from ovn_bgp_agent.tests import base as test_base
|
||||
class TestAgent(test_base.TestCase):
|
||||
|
||||
@mock.patch('oslo_service.service.launch')
|
||||
@mock.patch('ovn_bgp_agent.config.register_opts')
|
||||
@mock.patch('ovn_bgp_agent.config.init')
|
||||
@mock.patch('ovn_bgp_agent.config.setup_logging')
|
||||
@mock.patch('ovn_bgp_agent.agent.BGPAgent')
|
||||
def test_start(self, m_agent, m_setup_logging,
|
||||
m_config_init, m_oslo_launch):
|
||||
def test_start(self, m_agent, m_setup_logging, m_config_init,
|
||||
m_register_opts, m_oslo_launch):
|
||||
m_launcher = mock.Mock()
|
||||
m_oslo_launch.return_value = m_launcher
|
||||
|
||||
agent.start()
|
||||
|
||||
m_register_opts.assert_called()
|
||||
m_config_init.assert_called()
|
||||
m_setup_logging.assert_called()
|
||||
m_agent.assert_called()
|
||||
|
Loading…
Reference in New Issue
Block a user