Merge "Add test cases for Invalid exception type"

This commit is contained in:
Jenkins 2016-08-29 17:02:37 +00:00 committed by Gerrit Code Review
commit 79927038bc
2 changed files with 27 additions and 1 deletions

View File

@ -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

View File

@ -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()