Merge "Update Neutron with temporary registry pattern from VersionedObjectRegistry"
This commit is contained in:
commit
1e3f3fb266
@ -13,11 +13,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
|
||||
import mock
|
||||
from oslo_versionedobjects import base as obj_base
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
from oslo_versionedobjects import fixture
|
||||
import testtools
|
||||
|
||||
from neutron.api.rpc.callbacks import resources
|
||||
@ -60,21 +58,11 @@ class ResourcesRpcBaseTestCase(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(ResourcesRpcBaseTestCase, self).setUp()
|
||||
|
||||
# TODO(mhickey) This is using temp registry pattern. The
|
||||
# pattern solution is to backup the object registry, register
|
||||
# a class locally, and then restore the original registry.
|
||||
# Refer to https://review.openstack.org/#/c/263800/ for more
|
||||
# details. This code should be updated when the patch is merged.
|
||||
self._base_test_backup = copy.copy(
|
||||
obj_base.VersionedObjectRegistry._registry._obj_classes)
|
||||
self.addCleanup(self._restore_obj_registry)
|
||||
self.obj_registry = self.useFixture(
|
||||
fixture.VersionedObjectRegistryFixture())
|
||||
|
||||
self.context = context.get_admin_context()
|
||||
|
||||
def _restore_obj_registry(self):
|
||||
obj_base.VersionedObjectRegistry._registry._obj_classes = (
|
||||
self._base_test_backup)
|
||||
|
||||
|
||||
class _ValidateResourceTypeTestCase(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
@ -121,7 +109,7 @@ class ResourcesPullRpcApiTestCase(ResourcesRpcBaseTestCase):
|
||||
self.assertIs(self.rpc, resources_rpc.ResourcesPullRpcApi())
|
||||
|
||||
def test_pull(self):
|
||||
obj_base.VersionedObjectRegistry.register(FakeResource)
|
||||
self.obj_registry.register(FakeResource)
|
||||
expected_obj = _create_test_resource(self.context)
|
||||
resource_id = expected_obj.id
|
||||
self.cctxt_mock.call.return_value = expected_obj.obj_to_primitive()
|
||||
@ -162,7 +150,7 @@ class ResourcesPullRpcCallbackTestCase(ResourcesRpcBaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ResourcesPullRpcCallbackTestCase, self).setUp()
|
||||
obj_base.VersionedObjectRegistry.register(FakeResource)
|
||||
self.obj_registry.register(FakeResource)
|
||||
self.callbacks = resources_rpc.ResourcesPullRpcCallback()
|
||||
self.resource_obj = _create_test_resource(self.context)
|
||||
|
||||
@ -244,7 +232,7 @@ class ResourcesPushRpcCallbackTestCase(ResourcesRpcBaseTestCase):
|
||||
|
||||
@mock.patch.object(resources_rpc.cons_registry, 'push')
|
||||
def test_push(self, reg_push_mock):
|
||||
obj_base.VersionedObjectRegistry.register(FakeResource)
|
||||
self.obj_registry.register(FakeResource)
|
||||
self.callbacks.push(self.context, self.resource_prim, 'TYPE')
|
||||
reg_push_mock.assert_called_once_with(self.resource_obj.obj_name(),
|
||||
self.resource_obj, 'TYPE')
|
||||
|
Loading…
Reference in New Issue
Block a user