Test helper_db

g1itch/refactoring-sql
Dmitri Bogomolov 4 years ago
parent d4180b7ead
commit d719002206
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

@ -366,6 +366,10 @@ def run():
qt_tests = loader.loadTestsFromModule(bitmessageqt.tests)
suite.addTests(qt_tests)
import sql
sql_tests = loader.loadTestsFromModule(sql)
suite.addTest(sql_tests)
def keep_exc(ex_cls, exc, tb): # pylint: disable=unused-argument
"""Own exception hook for test cases"""
excQueue.put(('tests', exc))

@ -0,0 +1,33 @@
"""
SQL related core tests
"""
import unittest
import helper_db
class TestSQL(unittest.TestCase):
"""A test case for common SQL-related functions"""
test_address_1 = 'BM-2cVRo3WuKL5vDCKq2XJi1yR366nkHgHfcL'
test_address_2 = 'BM-2cVJn1BusL1j4UezuYkvpqNPCr7kCebeLw'
def test_subscriptions(self):
"""Put address into subscriptions and check that it was added"""
self.assertTrue(
helper_db.put_subscriptions('pass_1', self.test_address_1))
self.assertFalse(
helper_db.put_subscriptions('pass_2', self.test_address_1))
helper_db.put_subscriptions('pass_3', self.test_address_2, False)
for label, addr in helper_db.get_subscriptions():
if addr == self.test_address_1:
self.assertEqual(label, 'pass_1')
break
else:
self.fail('Could not find added address in subscriptions')
for label, addr in helper_db.get_subscriptions():
if addr == self.test_address_2:
self.fail('Got disabled subscription')
Loading…
Cancel
Save