袁聪的前端调修

This commit is contained in:
2026-09-14 01:07:43 +08:00
parent 680c2a0749
commit 7a49a1c2c8
23 changed files with 2150 additions and 51 deletions
+3 -2
View File
@@ -139,10 +139,11 @@ def test_offsite_recognized_mail_persists_workflow_and_notification() -> None:
recalc = client.post(
"/api/v1/offsite-fund/settlement-statistics/recalculate",
json={"fund_code": "000001", "application_date": "2026-09-10"},
json={"application_date": "2026-09-10"},
)
assert recalc.status_code == 200
assert recalc.json()["data"]["subscription_amount_yuan"] == "0"
assert recalc.json()["data"]["fund_count"] == 1
assert recalc.json()["data"]["items"][0]["subscription_amount_yuan"] == "0"
notice = client.post(
f"/api/v1/offsite-fund/documents/{task_id}/notifications",
@@ -126,7 +126,8 @@ def test_promotion_material_http_workflow_and_advisor_scope(tmp_path: Path) -> N
"file": (
"manager-photo.jpg",
_manager_photo_bytes(),
"image/jpeg",
# 模拟部分 Windows 浏览器/代理上传图片时给出的通用媒体类型。
"application/octet-stream",
)
},
)
@@ -36,6 +36,22 @@ async def test_default_recognition_uses_mock_without_external_call() -> None:
assert result.missing_fields == ()
@pytest.mark.asyncio
async def test_mock_recognition_separates_currency_from_subscription_amount() -> None:
source = RecognitionSourceFile(
filename="申购申请单.txt",
media_type="text/plain",
file_hash="hash-currency-mock",
payload="申购金额:人民币5000元 金额单位:元".encode(),
)
result = await OffsiteDocumentRecognitionAdapter(_settings()).recognize(source)
assert result.extracted_fields["申购金额"] == "5000"
assert result.extracted_fields["币种"] == "人民币"
assert result.extracted_fields["金额单位"] == "元"
@pytest.mark.asyncio
async def test_docx_text_fallback_maps_product_code_to_fund_code() -> None:
document_xml = """
@@ -99,7 +115,7 @@ async def test_enabled_recognition_calls_ocr_and_deepseek_with_masked_request_bo
200,
json={
"data": {
"ocr_text": "基金代码:000001 申请编号:SUB-001 申购金额:10000",
"ocr_text": "基金代码:000001 申请编号:SUB-001 申购金额:人民币10,000元",
"tables": [{"rows": 1}],
"page_evidence": {"基金代码": [{"page": 1}]},
}
@@ -123,7 +139,8 @@ async def test_enabled_recognition_calls_ocr_and_deepseek_with_masked_request_bo
"申请编号": "SUB-001",
"申请日期": "2026-09-10",
"代销机构": "测试代销",
"申购金额": "10000",
"申购金额": "人民币10,000元",
"币种": "人民币",
"金额单位": "元",
},
"field_confidence": {"基金代码": "0.99"},
@@ -170,6 +187,9 @@ async def test_enabled_recognition_calls_ocr_and_deepseek_with_masked_request_bo
assert result.ocr_status == "success"
assert result.llm_status == "success"
assert result.extracted_fields["基金代码"] == "000001"
assert result.extracted_fields["申购金额"] == "10000"
assert result.extracted_fields["币种"] == "人民币"
assert result.extracted_fields["金额单位"] == "元"
assert result.field_confidence["基金代码"].to_eng_string() == "0.99"
assert result.missing_fields == ()
assert requests[0].headers["x-acs-accesskey-id"] == "aliyun-id"
@@ -22,6 +22,9 @@ def test_subscription_minimum_amount_boundary() -> None:
assert below[0].result == "异常"
assert equal[0].result == "异常"
assert above[0].result == "正常"
assert above[0].calculation["实际值"] == "1.01"
assert above[0].calculation["规则值"] == "> 1 元"
assert above[0].calculation["比较"] == "1.01 > 1 元"
def test_subscription_ratio_and_share_limit_boundary() -> None:
@@ -37,6 +40,10 @@ def test_subscription_ratio_and_share_limit_boundary() -> None:
"subscription_holding_ratio"] == "异常"
assert {item.rule_code: item.result for item in abnormal}[
"subscription_single_share_limit"] == "异常"
holding = {item.rule_code: item for item in normal}["subscription_holding_ratio"]
assert holding.calculation["实际值"] == "20%"
assert holding.calculation["规则值"] == "≤ 20%"
assert holding.calculation["比较"] == "20% ≤ 20%"
def test_redemption_ratio_and_available_quantity_boundary() -> None: