refactor(shipping-notice): 更新环境变量以及接口增强

This commit is contained in:
hugo committed 2026-06-10 10:27:23 +08:00
1 parent ff7c227cc2
commit d9b414b07b
8 files changed
+92 -14

No files matched your search

@@ -14,9 +14,8 @@ from app.services.shipping_notice.openapi_spec import build_dify_openapi_spec
def main() -> None:
base = (
os.getenv("SHIPPING_NOTICE_TOOL_API_BASE")
os.getenv("HXOPS_TOOLS_API_BASE")
or os.getenv("PUBLIC_BASE_URL")
or os.getenv("HXOPS_PUBLIC_BASE_URL")
or "http://127.0.0.1:5052"
).rstrip("/")
spec = build_dify_openapi_spec(base)
@@ -30,3 +29,4 @@ def main() -> None:
if __name__ == "__main__":
main()
+67 -1
View File
@@ -132,7 +132,7 @@ def test_shipping_notice_match_shortage_needs_human(app, client):
def test_openapi_spec_public(app, client):
app.config["SHIPPING_NOTICE_TOOL_API_BASE"] = "http://tool-api.example.com"
app.config["HXOPS_TOOLS_API_BASE"] = "http://tool-api.example.com"
res = client.get("/api/shipping-notice/tools/openapi.json")
assert res.status_code == 200
spec = res.get_json()
@@ -804,6 +804,71 @@ def test_confirm_parse_does_not_skip_inventory_match(app, client):
assert task.match_status is None
def test_parse_notice_auto_continue_hides_parse_confirmation_hint(app, client):
headers = _tool_headers(app)
create_res = client.post(
"/api/shipping-notice/tools/create_task",
headers=headers,
json={"source_type": "manual"},
)
task_id = create_res.get_json()["task_id"]
parse_res = client.post(
"/api/shipping-notice/tools/parse_notice",
headers=headers,
json={
"task_id": task_id,
"structured": {
"customer_name": "ACME",
"lines": [{"sku": "A001", "reservation_id": "R-1", "qty": 10, "uom": "EA"}],
"confidence": 0.95,
},
},
)
parse_data = parse_res.get_json()
assert "【发货通知解析确认】" in parse_data["message"]
assert "回复「确认」进入库存检查" not in parse_data["message"]
assert parse_data.get("checkpoint") != "parse_review"
def test_submit_decision_confirm_during_waiting_inventory_is_not_failed(app, client, tmp_path):
headers = _tool_headers(app)
trigger = tmp_path / "inventory_triggers"
trigger.mkdir()
app.config["FREIGHT_RPA_INVENTORY_TRIGGER_DIR"] = str(trigger)
create_res = client.post(
"/api/shipping-notice/tools/create_task",
headers=headers,
json={"source_type": "manual"},
)
task_id = create_res.get_json()["task_id"]
parse_res = client.post(
"/api/shipping-notice/tools/parse_notice",
headers=headers,
json={
"task_id": task_id,
"structured": {
"customer_name": "ACME",
"lines": [{"sku": "A001", "reservation_id": "R-1", "qty": 10, "uom": "EA"}],
"confidence": 0.95,
},
},
)
assert parse_res.get_json()["status"] == "running"
confirm_res = client.post(
"/api/shipping-notice/tools/submit_decision",
headers=headers,
json={"task_id": task_id, "decision": "confirm"},
)
confirm_data = confirm_res.get_json()
assert confirm_data["status"] == "running"
assert "RPA 库存导出" in confirm_data["message"]
def test_submit_decision_by_conversation_id(app, client):
headers = _tool_headers(app)
@@ -883,3 +948,4 @@ def test_chat_actions_empty_when_task_rejected(app):
payload = build_chat_actions_payload(task)
assert payload["checkpoint"] == "rejected"
assert payload["action_buttons"] == []