From 5cf6663b9fd8f84f6e13bf8a71fe87ec0a7ba3c0 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 12 Apr 2018 15:56:06 -0700 Subject: [PATCH] tests: don't configure plugin for tests that don't need it Except test_subnet, there are no more object tests that would require the plugin configured, so let's not go through the hassle of setting it up. (For the record, this setup was not needed since If1252c42c49cd59dba7ec7c02c9b887fdc169f51). Change-Id: Iafb886c17dbf9a91a3514b0caa1bcd14093a796c --- neutron/tests/unit/objects/db/test_api.py | 9 --------- neutron/tests/unit/objects/test_base.py | 5 ----- neutron/tests/unit/objects/test_subnet.py | 5 +++++ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/neutron/tests/unit/objects/db/test_api.py b/neutron/tests/unit/objects/db/test_api.py index beef8bc1f1f..da91546b30e 100644 --- a/neutron/tests/unit/objects/db/test_api.py +++ b/neutron/tests/unit/objects/db/test_api.py @@ -25,9 +25,6 @@ from neutron.tests import base as test_base from neutron.tests.unit import testlib_api -PLUGIN_NAME = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2' - - class FakeModel(object): def __init__(self, *args, **kwargs): pass @@ -39,12 +36,6 @@ class FakeObj(base.NeutronDbObject): class GetObjectsTestCase(test_base.BaseTestCase): - def setUp(self): - super(GetObjectsTestCase, self).setUp() - # TODO(ihrachys): revisit plugin setup once we decouple - # objects.db.objects.api from core plugin instance - self.setup_coreplugin(PLUGIN_NAME) - def test_get_objects_pass_marker_obj_when_limit_and_marker_passed(self): ctxt = context.get_admin_context() marker = mock.sentinel.marker diff --git a/neutron/tests/unit/objects/test_base.py b/neutron/tests/unit/objects/test_base.py index 821b7f3d839..68498161a87 100644 --- a/neutron/tests/unit/objects/test_base.py +++ b/neutron/tests/unit/objects/test_base.py @@ -559,13 +559,8 @@ class _BaseObjectTestCase(object): _test_class = FakeNeutronDbObject - CORE_PLUGIN = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2' - def setUp(self): super(_BaseObjectTestCase, self).setUp() - # TODO(ihrachys): revisit plugin setup once we decouple - # neutron.objects.db.api from core plugin instance - self.setup_coreplugin(self.CORE_PLUGIN) # make sure all objects are loaded and registered in the registry objects.register_objects() self.context = context.get_admin_context() diff --git a/neutron/tests/unit/objects/test_subnet.py b/neutron/tests/unit/objects/test_subnet.py index 2ace9cd6293..f3561705e53 100644 --- a/neutron/tests/unit/objects/test_subnet.py +++ b/neutron/tests/unit/objects/test_subnet.py @@ -148,8 +148,13 @@ class SubnetDbObjectTestCase(obj_test_base.BaseDbObjectTestCase, _test_class = subnet.Subnet + CORE_PLUGIN = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2' + def setUp(self): super(SubnetDbObjectTestCase, self).setUp() + # set up plugin because some models used here require a plugin + # (specifically, rbac models and their get_valid_actions validators) + self.setup_coreplugin(self.CORE_PLUGIN) network_id = self._create_test_network_id() self.update_obj_fields( {'network_id': network_id,