Merge "Add support for SQLAlchemy 1.4 to NFV"
This commit is contained in:
commit
7753ea0dc7
|
@ -26,6 +26,20 @@ class TestNFVDatabaseUpgrade(testcase.NFVTestCase):
|
|||
super(TestNFVDatabaseUpgrade, self).tearDown()
|
||||
shutil.rmtree(self.db_dir)
|
||||
|
||||
def test_nfv_vim_database_load_and_dump(self):
|
||||
"""
|
||||
Test VIM database load
|
||||
"""
|
||||
root_dir = os.environ['VIRTUAL_ENV']
|
||||
config = dict()
|
||||
config['database_dir'] = self.db_dir
|
||||
database.database_initialize(config)
|
||||
data_input = "%s/nfv_vim_db_stx_19.12" % root_dir
|
||||
data_output = "%s/nfv_vim_db_stx_19.12.dump" % root_dir
|
||||
database.database_load_data(data_input)
|
||||
database.database_dump_data(data_output)
|
||||
database.database_finalize()
|
||||
|
||||
def test_nfv_vim_database_upgrade_from_19_12(self):
|
||||
"""
|
||||
Test VIM database upgrades from stx 19_12
|
||||
|
|
|
@ -23,8 +23,19 @@ class AsDictMixin(object):
|
|||
setattr(self, column, data[column])
|
||||
|
||||
|
||||
def get_Base_registry():
|
||||
try:
|
||||
# SQLAlchemy 1.4 got rid of _decl_class_registry
|
||||
# so we need to use the new way if it exists
|
||||
# otherwise fail over to the old attribute
|
||||
return Base.registry._class_registry
|
||||
except AttributeError: # SQLAlchemy <1.4
|
||||
return Base._decl_class_registry
|
||||
|
||||
|
||||
def lookup_class_by_table(table_name):
|
||||
for c in list(Base._decl_class_registry.values()):
|
||||
for c in list(get_Base_registry().values()):
|
||||
if hasattr(c, '__table__'):
|
||||
if table_name == str(c.__table__):
|
||||
return c
|
||||
# TODO(abailey): add an explicit return None
|
||||
|
|
Loading…
Reference in New Issue