fix DBResourceExtendFixture fixture

Commit e5afd0b9cb rehomed the
resource_extend db module into neutron-lib and included a testing
fixture. However the fixture submitted in that commit incorrectly
backed-up/restored the _DECORATED_EXTEND_METHODS rather than the
_resource_extend_functions as it should've. This patch fixes that
issue.

Change-Id: I6f313d8b03cbe985a2f231e99c4b6c0d1af7a8c4
This commit is contained in:
Boden R 2018-11-08 09:58:57 -07:00
parent b5f3bc7f01
commit 70612663ef
2 changed files with 9 additions and 9 deletions

View File

@ -275,14 +275,14 @@ class RPCFixture(fixtures.Fixture):
class DBResourceExtendFixture(fixtures.Fixture):
def __init__(self, extended_methods=None):
self.extended_methods = extended_methods or {}
def __init__(self, extended_functions=None):
self.extended_functions = extended_functions or {}
def _setUp(self):
self._backup = copy.deepcopy(
resource_extend._DECORATED_EXTEND_METHODS)
resource_extend._DECORATED_EXTEND_METHODS = self.extended_methods
resource_extend._resource_extend_functions)
resource_extend._resource_extend_functions = self.extended_functions
self.addCleanup(self._restore)
def _restore(self):
resource_extend._DECORATED_EXTEND_METHODS = self._backup
resource_extend._resource_extend_functions = self._backup

View File

@ -164,17 +164,17 @@ class DBResourceExtendFixtureTestCase(base.BaseTestCase):
'a': 'A',
'b': 'B'
}
orig_methods = resource_extend._DECORATED_EXTEND_METHODS
orig_methods = resource_extend._resource_extend_functions
self.assertNotEqual(fake_methods, orig_methods)
db_fixture = fixture.DBResourceExtendFixture(
extended_methods=fake_methods)
extended_functions=fake_methods)
db_fixture.setUp()
resource_extend.register_funcs('C', (lambda x: x,))
self.assertNotEqual(
orig_methods, resource_extend._DECORATED_EXTEND_METHODS)
orig_methods, resource_extend._resource_extend_functions)
db_fixture.cleanUp()
self.assertEqual(
orig_methods, resource_extend._DECORATED_EXTEND_METHODS)
orig_methods, resource_extend._resource_extend_functions)