rebase and merge conflicts
This commit is contained in:
parent
f6ffd6430a
commit
a00c898f46
|
@ -64,19 +64,6 @@ class UpgradeDB(object):
|
|||
self.cur.execute(item, parameters)
|
||||
return int(self.cur.fetchall()[0][0])
|
||||
|
||||
def _upgrade_one_level_method(self, level):
|
||||
"""
|
||||
Apply switcher to call methods accordingly
|
||||
"""
|
||||
|
||||
if level != self.__get_current_settings_version():
|
||||
return None
|
||||
|
||||
# Migrate Db with level
|
||||
method_name = 'upgrade_schema_data_' + str(level)
|
||||
method = getattr(self, method_name, lambda: "Invalid version")
|
||||
return method()
|
||||
|
||||
def _upgrade_one_level_sql_statement(self, file_name):
|
||||
"""
|
||||
Execute SQL files and queries
|
||||
|
@ -106,10 +93,10 @@ class UpgradeDB(object):
|
|||
|
||||
# call upgrading level in loop
|
||||
for l in range(self.current_level, self.max_level):
|
||||
if int(l) == 3:
|
||||
if int(l) == 1:
|
||||
continue
|
||||
self._upgrade_one_level_method(l)
|
||||
self._upgrade_one_level_sql_statement(l)
|
||||
self.increment_settings_version(l)
|
||||
|
||||
def increment_settings_version(self, level):
|
||||
"""
|
||||
|
|
|
@ -77,7 +77,7 @@ class TestSqlThread(unittest.TestCase):
|
|||
|
||||
sqlExecuteScript(sql_as_string)
|
||||
|
||||
def versioning(self):
|
||||
def version(self):
|
||||
"""
|
||||
Run SQL Scripts, Initialize DB with respect to versioning
|
||||
and Upgrade DB schema for all versions
|
||||
|
@ -125,8 +125,18 @@ class TestSqlThread(unittest.TestCase):
|
|||
self.assertEqual(query[0][-1], encoded_str, "test case fail for create_function")
|
||||
sqlExecute('''DROP TABLE testhash''')
|
||||
|
||||
@versioning
|
||||
def test_sql_thread_version_1(self):
|
||||
@version
|
||||
def test_sql_thread_version_2(self):
|
||||
"""
|
||||
Test with version 2
|
||||
"""
|
||||
|
||||
# Assertion
|
||||
res = sqlQuery(''' SELECT count(name) FROM sqlite_master WHERE type='table' AND name='inventory_backup' ''')
|
||||
self.assertNotEqual(res[0][0], 1, "Table inventory_backup not deleted in versioning 2")
|
||||
|
||||
@version
|
||||
def test_sql_thread_version_3(self):
|
||||
"""
|
||||
Test with version 1
|
||||
Version 1 and 3 are same so will skip 3
|
||||
|
@ -139,17 +149,7 @@ class TestSqlThread(unittest.TestCase):
|
|||
self.assertEqual(result, ['tag'], "Data not migrated for version 1")
|
||||
self.assertEqual(res, [(5, 'tag', 'blob', 0, "''", 0)], "Data not migrated for version 1")
|
||||
|
||||
@versioning
|
||||
def test_sql_thread_version_2(self):
|
||||
"""
|
||||
Test with version 2
|
||||
"""
|
||||
|
||||
# Assertion
|
||||
res = sqlQuery(''' SELECT count(name) FROM sqlite_master WHERE type='table' AND name='inventory_backup' ''')
|
||||
self.assertNotEqual(res[0][0], 1, "Table inventory_backup not deleted in versioning 2")
|
||||
|
||||
@versioning
|
||||
@version
|
||||
def test_sql_thread_version_4(self):
|
||||
"""
|
||||
Test with version 4
|
||||
|
@ -159,7 +159,7 @@ class TestSqlThread(unittest.TestCase):
|
|||
res = sqlQuery('''select * from inventory where objecttype = 'pubkey';''')
|
||||
self.assertNotEqual(len(res), 1, "Table inventory not deleted in versioning 4")
|
||||
|
||||
@versioning
|
||||
@version
|
||||
def test_sql_thread_version_5(self):
|
||||
"""
|
||||
Test with version 5
|
||||
|
@ -173,7 +173,7 @@ class TestSqlThread(unittest.TestCase):
|
|||
WHERE type='table' AND name='objectprocessorqueue'; ''')
|
||||
self.assertNotEqual(len(res), 0, "Table objectprocessorqueue not created in versioning 5")
|
||||
|
||||
@versioning
|
||||
@version
|
||||
def test_sql_thread_version_6(self):
|
||||
"""
|
||||
Test with version 6
|
||||
|
@ -189,7 +189,7 @@ class TestSqlThread(unittest.TestCase):
|
|||
objectprocessorqueue = list(filter_table_column(objectprocessorqueue, "objecttype"))
|
||||
self.assertEqual(objectprocessorqueue, ['objecttype'], "Data not migrated for version 6")
|
||||
|
||||
@versioning
|
||||
@version
|
||||
def test_sql_thread_version_7(self):
|
||||
"""
|
||||
Test with version 7
|
||||
|
@ -205,7 +205,7 @@ class TestSqlThread(unittest.TestCase):
|
|||
sent = sqlQuery('''SELECT status FROM sent ''')
|
||||
self.assertEqual(sent, [('msgqueued',), ('msgqueued',)], "Data not migrated for version 7")
|
||||
|
||||
@versioning
|
||||
@version
|
||||
def test_sql_thread_version_8(self):
|
||||
"""
|
||||
Test with version 8
|
||||
|
@ -216,7 +216,7 @@ class TestSqlThread(unittest.TestCase):
|
|||
result = list(filter_table_column(res, "sighash"))
|
||||
self.assertEqual(result, ['sighash'], "Data not migrated for version 8")
|
||||
|
||||
@versioning
|
||||
@version
|
||||
def test_sql_thread_version_9(self):
|
||||
"""
|
||||
Test with version 9
|
||||
|
@ -231,7 +231,7 @@ class TestSqlThread(unittest.TestCase):
|
|||
result = list(filter_table_column(res, "address"))
|
||||
self.assertEqual(result, ['address'], "Data not migrated for version 9")
|
||||
|
||||
@versioning
|
||||
@version
|
||||
def test_sql_thread_version_10(self):
|
||||
"""
|
||||
Test with version 10
|
||||
|
|
Reference in New Issue
Block a user