feat: store and search customer name pinyin initials.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-08-07 17:24:28 +08:00
1 parent ba3f2c19bb
commit 659fc89179
3 files changed
+100 -3

No files matched your search

+39 -1
View File
@@ -1,8 +1,9 @@
"""产品列表 keyword:名称/编号/拼音首字母 OR 匹配。"""
"""产品/客户列表 keyword:名称/编号/拼音首字母 OR 匹配。"""
from __future__ import annotations
from unittest.mock import MagicMock
from app.crud.crm.customer import list_customer_options, list_customers
from app.crud.crm.product import list_products
@@ -24,3 +25,40 @@ def test_list_products_keyword_includes_name_and_pinyin():
keyword_expr = " ".join(str(a) for a in q.filter.call_args_list[1][0])
assert "product_name" in keyword_expr
assert "name_pinyin_abbr" in keyword_expr
def test_list_customers_keyword_includes_name_and_pinyin():
db = MagicMock()
q = MagicMock()
db.query.return_value = q
q.filter.return_value = q
q.order_by.return_value = q
q.with_entities.return_value = q
q.scalar.return_value = 0
q.offset.return_value = q
q.limit.return_value = q
q.all.return_value = []
list_customers(db, "shanxia2.0", keyword="sxhg")
assert q.filter.call_count >= 2
keyword_expr = " ".join(str(a) for a in q.filter.call_args_list[1][0])
assert "customer_name" in keyword_expr
assert "name_pinyin_abbr" in keyword_expr
def test_list_customer_options_keyword_includes_name_and_pinyin():
db = MagicMock()
q = MagicMock()
db.query.return_value = q
q.filter.return_value = q
q.order_by.return_value = q
q.limit.return_value = q
q.all.return_value = []
list_customer_options(db, "shanxia2.0", keyword="sxhg")
assert q.filter.call_count >= 2
keyword_expr = " ".join(str(a) for a in q.filter.call_args_list[1][0])
assert "customer_name" in keyword_expr
assert "name_pinyin_abbr" in keyword_expr