removed create function from test
This commit is contained in:
parent
4954e6dba7
commit
63d1a8d318
|
@ -69,8 +69,6 @@ class UpgradeDB(object):
|
||||||
Execute SQL files and queries
|
Execute SQL files and queries
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
print("=======================")
|
|
||||||
print(file_name)
|
|
||||||
if int(file_name) == 8:
|
if int(file_name) == 8:
|
||||||
res = self.cur.execute('''PRAGMA table_info('inbox');''')
|
res = self.cur.execute('''PRAGMA table_info('inbox');''')
|
||||||
print("""""""""""""""-----------res""""""""""""""")
|
print("""""""""""""""-----------res""""""""""""""")
|
||||||
|
@ -139,6 +137,19 @@ class sqlThread(threading.Thread, UpgradeDB):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(sqlThread, self).__init__()
|
super(sqlThread, self).__init__()
|
||||||
threading.Thread.__init__(self, name="SQL")
|
threading.Thread.__init__(self, name="SQL")
|
||||||
|
self.__flag = threading.Event()
|
||||||
|
|
||||||
|
# Adding for pause/resume thread
|
||||||
|
self.__flag = threading.Event()
|
||||||
|
self.__flag.set() # Set to True
|
||||||
|
self.__running = threading.Event() # Used to stop the thread identification
|
||||||
|
self.__running.set() # Set running to True
|
||||||
|
|
||||||
|
def pause(self):
|
||||||
|
self.__flag.clear() # Set to False to block the thread
|
||||||
|
|
||||||
|
def resume(self):
|
||||||
|
self.__flag.set() # Set to True, let the thread stop blocking
|
||||||
|
|
||||||
def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements,
|
def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements,
|
||||||
# Redefinition-of-parameters-type-from-tuple-to-str, R0204, line-too-long, E501
|
# Redefinition-of-parameters-type-from-tuple-to-str, R0204, line-too-long, E501
|
||||||
|
|
|
@ -17,11 +17,13 @@ CREATE TABLE IF NOT EXISTS `sent` (
|
||||||
UNIQUE(msgid) ON CONFLICT REPLACE
|
UNIQUE(msgid) ON CONFLICT REPLACE
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `pubkeys`;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `pubkeys` (
|
CREATE TABLE IF NOT EXISTS `pubkeys` (
|
||||||
`hash` text,
|
`hash` text DEFAULT NULL,
|
||||||
`addressversion` int,
|
`addressversion` int DEFAULT NULL,
|
||||||
`transmitdata` blob,
|
`transmitdata` blob DEFAULT NULL,
|
||||||
`time` int,
|
`time` int DEFAULT NULL,
|
||||||
`usedpersonally` text,
|
`usedpersonally` text DEFAULT NULL
|
||||||
UNIQUE(hash) ON CONFLICT REPLACE
|
UNIQUE(hash) ON CONFLICT REPLACE
|
||||||
) ;
|
) ;
|
||||||
|
|
|
@ -110,20 +110,20 @@ class TestSqlThread(unittest.TestCase):
|
||||||
func_name = func.__name__
|
func_name = func.__name__
|
||||||
version = func_name.rsplit('_', 1)[-1]
|
version = func_name.rsplit('_', 1)[-1]
|
||||||
|
|
||||||
print("-------------=========")
|
|
||||||
print(version)
|
|
||||||
print("-------------=========")
|
|
||||||
|
|
||||||
if int(version) == 8:
|
if int(version) == 8:
|
||||||
res = sqlQuery('''PRAGMA table_info('inbox');''')
|
res = sqlQuery('''PRAGMA table_info('inbox');''')
|
||||||
print("""""""""""""""res""""""""""""""")
|
print("""""""""""""""res""""""""""""""")
|
||||||
print(res)
|
print(res)
|
||||||
|
|
||||||
|
# sqlThread().pause()
|
||||||
|
|
||||||
# Update versions DB mocking
|
# Update versions DB mocking
|
||||||
self.initialise_database("init_version_{}".format(version))
|
self.initialise_database("init_version_{}".format(version))
|
||||||
|
|
||||||
|
print("-------------=========")
|
||||||
|
print(version)
|
||||||
|
print("-------------=========")
|
||||||
|
|
||||||
if int(version) == 9:
|
if int(version) == 9:
|
||||||
sqlThread().create_function()
|
sqlThread().create_function()
|
||||||
|
@ -133,12 +133,12 @@ class TestSqlThread(unittest.TestCase):
|
||||||
print("""""""""""""""-----------res""""""""""""""")
|
print("""""""""""""""-----------res""""""""""""""")
|
||||||
print(res)
|
print(res)
|
||||||
|
|
||||||
|
|
||||||
# Test versions
|
# Test versions
|
||||||
upgrade_db = UpgradeDB()
|
upgrade_db = UpgradeDB()
|
||||||
upgrade_db._upgrade_one_level_sql_statement(int(version)) # pylint: disable= W0212, protected-access
|
upgrade_db._upgrade_one_level_sql_statement(int(version)) # pylint: disable= W0212, protected-access
|
||||||
# upgrade_db.upgrade_to_latest(upgrade_db.cur, upgrade_db.conn)
|
# upgrade_db.upgrade_to_latest(upgrade_db.cur, upgrade_db.conn)
|
||||||
# upgrade_db.upgrade_to_latest(upgrade_db.cur, upgrade_db.conn, int(version))
|
# upgrade_db.upgrade_to_latest(upgrade_db.cur, upgrade_db.conn, int(version))
|
||||||
|
# sqlThread().resume()
|
||||||
return func(*args) # <-- use (self, ...)
|
return func(*args) # <-- use (self, ...)
|
||||||
func = self
|
func = self
|
||||||
return wrapper
|
return wrapper
|
||||||
|
@ -255,20 +255,20 @@ class TestSqlThread(unittest.TestCase):
|
||||||
result = list(filter_table_column(res, "sighash"))
|
result = list(filter_table_column(res, "sighash"))
|
||||||
self.assertEqual(result, ['sighash'], "Data not migrated for version 8")
|
self.assertEqual(result, ['sighash'], "Data not migrated for version 8")
|
||||||
|
|
||||||
# @version
|
@version
|
||||||
# def test_sql_thread_version_9(self):
|
def test_sql_thread_version_9(self):
|
||||||
# """
|
"""
|
||||||
# Test with version 9
|
Test with version 9
|
||||||
# """
|
"""
|
||||||
#
|
|
||||||
# # Assertion
|
# Assertion
|
||||||
# res = sqlQuery(''' SELECT count(name) FROM sqlite_master WHERE type='table' AND name='pubkeys_backup' ''')
|
res = sqlQuery(''' SELECT count(name) FROM sqlite_master WHERE type='table' AND name='pubkeys_backup' ''')
|
||||||
# self.assertNotEqual(res[0][0], 1, "Table pubkeys_backup not deleted")
|
self.assertNotEqual(res[0][0], 1, "Table pubkeys_backup not deleted")
|
||||||
#
|
|
||||||
# res = sqlQuery('''PRAGMA table_info('pubkeys');''')
|
res = sqlQuery('''PRAGMA table_info('pubkeys');''')
|
||||||
# # res = res.fetchall()
|
# res = res.fetchall()
|
||||||
# result = list(filter_table_column(res, "address"))
|
result = list(filter_table_column(res, "address"))
|
||||||
# self.assertEqual(result, ['address'], "Data not migrated for version 9")
|
self.assertEqual(result, ['address'], "Data not migrated for version 9")
|
||||||
|
|
||||||
# @version
|
# @version
|
||||||
# def test_sql_thread_version_10(self):
|
# def test_sql_thread_version_10(self):
|
||||||
|
|
Reference in New Issue
Block a user