diff --git a/neutron/services/l3_router/service_providers/base.py b/neutron/services/l3_router/service_providers/base.py index d264300648f..b2a414ed469 100644 --- a/neutron/services/l3_router/service_providers/base.py +++ b/neutron/services/l3_router/service_providers/base.py @@ -37,7 +37,7 @@ MANDATORY = _FeatureFlag(supports=True, requires=True) class L3ServiceProvider(object): - """Base class for L3 service providers. + """Base class for L3 service provider drivers. On __init__ this will be given a handle to the l3 plugin. It is then the responsibility of the driver to subscribe to the events it is interested diff --git a/neutron/tests/unit/services/l3_router/service_providers/test_driver_controller.py b/neutron/tests/unit/services/l3_router/service_providers/test_driver_controller.py index 93f07ae0553..9068f3d78b6 100644 --- a/neutron/tests/unit/services/l3_router/service_providers/test_driver_controller.py +++ b/neutron/tests/unit/services/l3_router/service_providers/test_driver_controller.py @@ -15,12 +15,15 @@ import mock from mock import patch from neutron_lib import constants +from neutron_lib import exceptions as lib_exc import testtools from neutron import context from neutron import manager from neutron.plugins.common import constants as p_cons from neutron.services.l3_router.service_providers import driver_controller +from neutron.services import provider_configuration +from neutron.tests import base from neutron.tests.unit import testlib_api @@ -50,6 +53,20 @@ class TestDriverController(testlib_api.SqlTestCase): self.dc._get_provider_for_router(self.ctx, 'router_id')) + def test__update_router_provider_invalid(self): + test_dc = driver_controller.DriverController(self.fake_l3) + with mock.patch.object(test_dc, "_get_provider_for_router"): + with mock.patch.object( + driver_controller, + "_ensure_driver_supports_request") as _ensure: + _ensure.side_effect = lib_exc.Invalid(message='message') + self.assertRaises( + lib_exc.Invalid, + test_dc._update_router_provider, + None, None, None, None, + None, {'name': 'testname'}, + {'flavor_id': 'old_fid'}, None) + def test__set_router_provider_attr_lookups(self): # ensure correct drivers are looked up based on attrs cases = [ @@ -100,3 +117,12 @@ class TestDriverController(testlib_api.SqlTestCase): _fake_flavor_plugin} _dc = driver_controller.DriverController(self.fake_l3) self.assertEqual(_fake_flavor_plugin, _dc._flavor_plugin) + + +class Test_LegacyPlusProviderConfiguration(base.BaseTestCase): + + @mock.patch.object(provider_configuration.ProviderConfiguration, + "add_provider") + def test__update_router_provider_invalid(self, mock_method): + mock_method.side_effect = lib_exc.Invalid(message='message') + driver_controller._LegacyPlusProviderConfiguration()