From af0b0fa1361b2218a21872fdd93a6e8020737fd3 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Wed, 14 Oct 2026 10:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=A4=B9=E5=85=B7=EF=BC=9A?= =?UTF-8?q?=E8=A1=A8=E5=8A=A9=E6=89=8B=E5=92=8C=E5=AF=BC=E5=85=A5=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=B5=8B=E8=AF=95=E9=87=8C=E8=99=9A=E6=9E=84=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E8=A1=A8=E7=9A=84=E5=8F=B7=E7=A0=81=E5=88=97=E6=94=B9?= =?UTF-8?q?=E5=8F=AB=20buyer=5Fphone=EF=BC=88=E5=92=8C=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E9=87=8C=E5=85=B6=E4=BB=96=E8=99=9A=E6=9E=84=E5=A4=B9=E5=85=B7?= =?UTF-8?q?=E4=B8=80=E8=87=B4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/tests/test_catalog_assistant.py | 12 ++++++------ backend/tests/test_catalog_transfer.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/tests/test_catalog_assistant.py b/backend/tests/test_catalog_assistant.py index 8c4b4470..2e143421 100644 --- a/backend/tests/test_catalog_assistant.py +++ b/backend/tests/test_catalog_assistant.py @@ -101,7 +101,7 @@ def _shop_db(path) -> str: conn.executescript(""" CREATE TABLE members (id INTEGER PRIMARY KEY, nick TEXT); CREATE TABLE orders (id INTEGER PRIMARY KEY, order_no TEXT NOT NULL, status INTEGER NOT NULL, - amount REAL, contact_phone TEXT, created_at TEXT, + amount REAL, buyer_phone TEXT, created_at TEXT, member_id INTEGER REFERENCES members(id)); """) conn.executemany("INSERT INTO members VALUES (?, ?)", [(i, f"会员{i}") for i in range(1, 6)]) @@ -119,7 +119,7 @@ ORDERS_NOTES = { "kind": make_item("fact", "llm", "rejected"), "columns": { "status": {"codes": make_item({"1": "已支付"}, "profile", note="数据剖析:全表 30 行,2 个取值")}, - "contact_phone": {"label": make_item("联系电话", "llm"), + "buyer_phone": {"label": make_item("联系电话", "llm"), "codes": make_item({PHONES[0]: "测试号"}, "human", "confirmed")}, }, } @@ -142,7 +142,7 @@ async def client(): async def _source(client, tmp_path, *, profile: bool = True, guidance: str | None = "金额一律按元", notes: dict | None = None) -> str: - options: dict[str, Any] = {"mask_columns": "contact_phone"} + options: dict[str, Any] = {"mask_columns": "buyer_phone"} if profile: options["catalog_profile"] = {"enabled": True} if guidance: @@ -346,7 +346,7 @@ async def test_background_has_structure_catalog_and_hides_masked_values(client, # 界面上还没保存的修改 assert "columns.amount.unit" in system and "用户说:金额是元" in system # 遮罩列只给列名:码值、取值一个都不给 - assert "contact_phone" in system + assert "buyer_phone" in system assert not any(p in system for p in PHONES) and "测试号" not in system # 没开剖析的源才写不能查数据;这里开了,给了查询工具 assert model.tool_names() == ["run_query", "propose_changes"] @@ -422,7 +422,7 @@ async def test_proposals_are_checked_and_never_written(client, tmp_path, monkeyp {"path": "valid_filter", "value": "status <> 9", "reason": "用户说:统计时排除作废"}, {"path": "columns.amount.meaning", "value": "实收=单价*数量", "reason": "x"}, # 公式:不收 {"path": "columns.ghost.label", "value": "幽灵", "reason": "x"}, # 列不存在:不收 - {"path": "columns.contact_phone.codes", "value": {PHONES[1]: "客服"}, "reason": "x"}, # 遮罩列:不给码值 + {"path": "columns.buyer_phone.codes", "value": {PHONES[1]: "客服"}, "reason": "x"}, # 遮罩列:不给码值 {"path": "grain", "value": "每笔订单一行", "reason": "x"}, # 已经是这个值:不用提 ] model = Scripted([Turn(text=["好的,"], calls=[("propose_changes", {"changes": changes})]), @@ -562,7 +562,7 @@ async def test_queries_are_read_only_masked_and_capped(client, tmp_path, monkeyp sid = await _source(client, tmp_path) queries = [ ("run_query", {"sql": "SELECT status, COUNT(*) AS n FROM orders GROUP BY status ORDER BY status"}), - ("run_query", {"sql": "SELECT id, contact_phone AS phone, amount FROM orders ORDER BY id"}), + ("run_query", {"sql": "SELECT id, buyer_phone AS phone, amount FROM orders ORDER BY id"}), ("run_query", {"sql": "DELETE FROM orders"}), ] model = Scripted([Turn(text=["我查一下。"], calls=queries), diff --git a/backend/tests/test_catalog_transfer.py b/backend/tests/test_catalog_transfer.py index 61822085..b0556247 100644 --- a/backend/tests/test_catalog_transfer.py +++ b/backend/tests/test_catalog_transfer.py @@ -49,7 +49,7 @@ def _tables(*, upper: bool = False) -> dict: n("orders"): {"qualified": n("orders"), "primary_key": [n("id")], "comment": None, "is_view": False, "foreign_keys": [], "unique": [], "columns": [_col(n("id")), _col(n("status")), _col(n("amount"), "REAL"), _col(n("member_id")), - _col(n("contact_phone"), "TEXT")]}, + _col(n("buyer_phone"), "TEXT")]}, n("members"): {"qualified": n("members"), "primary_key": [n("id")], "comment": None, "is_view": False, "foreign_keys": [], "unique": [], "columns": members_cols}, n("refunds"): {"qualified": n("refunds"), "primary_key": [n("id")], "comment": None, "is_view": False, @@ -75,7 +75,7 @@ SOURCE_ORDERS = { "status": {"codes": make_item({"1": "已支付", "9": "作废"}, "human", "confirmed", complete=True), "label": make_item("状态", "llm")}, "amount": {"unit": make_item("元", "human", "confirmed"), "measure": make_item("flow", "llm")}, - "contact_phone": {"codes": make_item({"13900000001": "测试号"}, "human", "confirmed"), + "buyer_phone": {"codes": make_item({"13900000001": "测试号"}, "human", "confirmed"), "label": make_item("联系电话", "human", "confirmed")}, # 目标表结构里没有这一列 "gift_flag": {"label": make_item("赠品标记", "human", "confirmed")}, @@ -139,7 +139,7 @@ async def _pair() -> tuple[str, str]: {"orders": SOURCE_ORDERS, "members": SOURCE_MEMBERS, "ghost_table": SOURCE_GHOST}, options={CATALOG_DRAFT_GUIDANCE_OPTION: "金额一律按元"}) remote = await _source(f"deploy_{uuid.uuid4().hex[:6]}", _tables(upper=True), {"ORDERS": TARGET_ORDERS}, - options={"mask_columns": "contact_phone"}) + options={"mask_columns": "buyer_phone"}) return local, remote @@ -212,7 +212,7 @@ async def test_preview_reports_and_writes_nothing(client): assert "保留" in label["why"] skipped = {s["path"]: s["why"] for s in orders["skipped"]} assert "columns.gift_flag.label" in skipped and "表结构里没有列 gift_flag" in skipped["columns.gift_flag.label"] - assert "遮罩" in skipped["columns.contact_phone.codes"] + assert "遮罩" in skipped["columns.buyer_phone.codes"] stores = next(p for p in skipped if p.startswith("relations.")) assert "stores" in skipped[stores] # 新增:dedup(驳回的照带)、status 码值、amount 两项、联系电话的中文名、关联关系;更新:有效记录条件 @@ -257,7 +257,7 @@ async def test_import_writes_by_the_rules_and_reports_versions(client): assert notes["columns"]["STATUS"]["label"]["value"] == "状态码" assert notes["columns"]["AMOUNT"]["measure"] == SOURCE_ORDERS["columns"]["amount"]["measure"] # 遮罩列:中文名照带,码值不导入 - assert notes["columns"]["CONTACT_PHONE"] == {"label": SOURCE_ORDERS["columns"]["contact_phone"]["label"]} + assert notes["columns"]["BUYER_PHONE"] == {"label": SOURCE_ORDERS["columns"]["buyer_phone"]["label"]} assert "GIFT_FLAG" not in notes["columns"] and "gift_flag" not in notes["columns"] [rel] = notes["relations"] assert rel["id"] == catalog.relation_id("ORDERS", ["MEMBER_ID"], "MEMBERS", ["ID"]) @@ -380,7 +380,7 @@ async def test_valid_filter_columns_must_be_in_the_target_table(client): assert why and "子查询" in why why, _ = await outcome("status <> 9; DELETE FROM orders") assert why and "条件" in why - for fine in ("orders.status <> 9", "ORDERS.STATUS <> 9 AND ABS(amount) > 0", "contact_phone IS NOT NULL"): + for fine in ("orders.status <> 9", "ORDERS.STATUS <> 9 AND ABS(amount) > 0", "buyer_phone IS NOT NULL"): why, update = await outcome(fine) assert why is None and update == 1, fine