初始化测试通过
This commit is contained in:
@@ -19,6 +19,7 @@ class TestDisplayMetadata(unittest.TestCase):
|
||||
def test_init_db_metadata_idempotent(self) -> None:
|
||||
with IsolatedDataRoot():
|
||||
from db.connection import get_conn, init_db
|
||||
from util.constants import BUSINESS_TABLES
|
||||
|
||||
init_db()
|
||||
init_db()
|
||||
@@ -27,9 +28,9 @@ class TestDisplayMetadata(unittest.TestCase):
|
||||
try:
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT COUNT(*) FROM _jiangchang_tables")
|
||||
self.assertEqual(int(cur.fetchone()[0]), 0)
|
||||
self.assertEqual(int(cur.fetchone()[0]), len(BUSINESS_TABLES))
|
||||
cur.execute("SELECT COUNT(*) FROM _jiangchang_columns")
|
||||
self.assertEqual(int(cur.fetchone()[0]), 0)
|
||||
self.assertGreater(int(cur.fetchone()[0]), 0)
|
||||
cur.execute(
|
||||
"SELECT 1 FROM sqlite_master WHERE type='table' AND name='task_logs'"
|
||||
)
|
||||
@@ -203,12 +204,13 @@ class TestDisplayMetadata(unittest.TestCase):
|
||||
with IsolatedDataRoot():
|
||||
from db.connection import get_conn, init_db
|
||||
from db.display_metadata import iter_user_tables
|
||||
from util.constants import BUSINESS_TABLES
|
||||
|
||||
init_db()
|
||||
conn = get_conn()
|
||||
try:
|
||||
tables = list(iter_user_tables(conn.cursor()))
|
||||
self.assertEqual(tables, [])
|
||||
self.assertEqual(set(tables), set(BUSINESS_TABLES))
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user