Merge "fix DBResourceExtendFixture fixture"

This commit is contained in:
Zuul 2018-11-19 23:40:46 +00:00 committed by Gerrit Code Review
commit 53bc87c198
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)