All checks were successful
技能自动化发布 / release (push) Successful in 15s
基于 skill-template 脚手架开发,包含: - 5 张业务表(教职工、请假政策、考勤日历、请假记录、假期余额) - 请假核算引擎(扣薪计算、审批层级判定、年假抵扣) - CLI 入口(import-employees / calculate-leave / render-html) - HTML 审批与扣薪报告生成 - 示例数据与完整测试套件(295 tests passed)
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""init_db:幂等创建请假考勤业务表与元数据。"""
|
||
from __future__ import annotations
|
||
|
||
import unittest
|
||
|
||
from _support import IsolatedDataRoot
|
||
|
||
|
||
class TestDbSmoke(unittest.TestCase):
|
||
def test_init_db_idempotent_with_business_tables(self) -> None:
|
||
with IsolatedDataRoot():
|
||
from db.connection import get_conn, init_db
|
||
from db.display_metadata import METADATA_TABLES, iter_user_tables
|
||
from db.schema import BUSINESS_TABLES
|
||
|
||
init_db()
|
||
init_db()
|
||
|
||
conn = get_conn()
|
||
try:
|
||
cur = conn.cursor()
|
||
cur.execute(
|
||
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"
|
||
)
|
||
tables = {str(row[0]) for row in cur.fetchall()}
|
||
self.assertIn("_jiangchang_tables", tables)
|
||
self.assertIn("_jiangchang_columns", tables)
|
||
for name in BUSINESS_TABLES:
|
||
self.assertIn(name, tables)
|
||
self.assertNotIn("task_logs", tables)
|
||
user_tables = list(iter_user_tables(cur))
|
||
self.assertEqual(len(user_tables), len(BUSINESS_TABLES))
|
||
leftover = tables - METADATA_TABLES - set(user_tables)
|
||
self.assertEqual(leftover, set())
|
||
finally:
|
||
conn.close()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
unittest.main()
|