Use StableObjectJsonFixture from o.vo
StableObjectJsonFixture has been in o.vo since the 1.9.0 release and we require >=1.13.0 in g-r now, so we should use the fixture from the library rather than keep a duplicate in nova. This is also needed to use o.vo 1.17.0 which has change 39a057becc10d1cfb5a5d5024bfcbbe6db1b56be that breaks the fixture's erroneous unit test. Change-Id: Idd0e02a1c19300c3ab7a57cbacb78d1f07037843 Closes-Bug: #1618115
This commit is contained in:
parent
2d31c335e8
commit
2440270f7e
@ -40,6 +40,7 @@ from oslo_log.fixture import logging_error as log_fixture
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
from oslo_versionedobjects import fixture as ovo_fixture
|
||||||
from oslotest import moxstubout
|
from oslotest import moxstubout
|
||||||
import six
|
import six
|
||||||
import testtools
|
import testtools
|
||||||
@ -229,7 +230,7 @@ class TestCase(testtools.TestCase):
|
|||||||
objects_base.NovaObjectRegistry._registry._obj_classes)
|
objects_base.NovaObjectRegistry._registry._obj_classes)
|
||||||
self.addCleanup(self._restore_obj_registry)
|
self.addCleanup(self._restore_obj_registry)
|
||||||
|
|
||||||
self.useFixture(nova_fixtures.StableObjectJsonFixture())
|
self.useFixture(ovo_fixture.StableObjectJsonFixture())
|
||||||
|
|
||||||
# NOTE(mnaser): All calls to utils.is_neutron() are cached in
|
# NOTE(mnaser): All calls to utils.is_neutron() are cached in
|
||||||
# nova.utils._IS_NEUTRON. We set it to None to avoid any
|
# nova.utils._IS_NEUTRON. We set it to None to avoid any
|
||||||
|
@ -605,34 +605,6 @@ class BannedDBSchemaOperations(fixtures.Fixture):
|
|||||||
lambda *a, **k: self._explode(thing, 'alter')))
|
lambda *a, **k: self._explode(thing, 'alter')))
|
||||||
|
|
||||||
|
|
||||||
class StableObjectJsonFixture(fixtures.Fixture):
|
|
||||||
"""Fixture that makes sure we get stable JSON object representations.
|
|
||||||
|
|
||||||
Since objects contain things like set(), which can't be converted to
|
|
||||||
JSON, we have some situations where the representation isn't fully
|
|
||||||
deterministic. This doesn't matter at all at runtime, but does to
|
|
||||||
unit tests that try to assert things at a low level.
|
|
||||||
|
|
||||||
This fixture mocks the obj_to_primitive() call and makes sure to
|
|
||||||
sort the list of changed fields (which came from a set) before
|
|
||||||
returning it to the caller.
|
|
||||||
"""
|
|
||||||
def __init__(self):
|
|
||||||
self._original_otp = obj_base.NovaObject.obj_to_primitive
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(StableObjectJsonFixture, self).setUp()
|
|
||||||
|
|
||||||
def _doit(obj, *args, **kwargs):
|
|
||||||
result = self._original_otp(obj, *args, **kwargs)
|
|
||||||
if 'nova_object.changes' in result:
|
|
||||||
result['nova_object.changes'].sort()
|
|
||||||
return result
|
|
||||||
|
|
||||||
self.useFixture(fixtures.MonkeyPatch(
|
|
||||||
'nova.objects.base.NovaObject.obj_to_primitive', _doit))
|
|
||||||
|
|
||||||
|
|
||||||
class EngineFacadeFixture(fixtures.Fixture):
|
class EngineFacadeFixture(fixtures.Fixture):
|
||||||
"""Fixture to isolation EngineFacade during tests.
|
"""Fixture to isolation EngineFacade during tests.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user