feat: store and search product name pinyin initials.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e056dfaac1
commit
ba3f2c19bb
4 files changed
+83
-6
No files matched your search
@@ -0,0 +1,26 @@
|
||||
"""产品列表 keyword:名称/编号/拼音首字母 OR 匹配。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from app.crud.crm.product import list_products
|
||||
|
||||
|
||||
def test_list_products_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_products(db, "shanxia2.0", keyword="gyls")
|
||||
|
||||
assert q.filter.call_count >= 2
|
||||
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
|
||||
@@ -1,4 +1,4 @@
|
||||
"""产品下拉 options:keyword 仅按产品名称模糊匹配,不匹配产品编号。"""
|
||||
"""产品下拉 options:keyword 按产品名称/拼音首字母模糊匹配,不匹配产品编号。"""
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
@@ -20,4 +20,5 @@ def test_list_product_options_keyword_only_filters_product_name():
|
||||
assert q.filter.call_count >= 2
|
||||
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
|
||||
assert "product_no" not in keyword_expr
|
||||
Reference in new issue
Block a user