主要变更: 1. 移除废弃的发货通知字段抽取独立Workflow Agent相关代码 2. 重构Dify服务调用,新增inputs参数支持注入环境变量配置的工具API地址与密钥 3. 新增auto_progress工具API与checkpoint catalog接口,支持流程自动推进 4. 统一字段命名,将column_mapping_json改为map_json并兼容旧有调用 5. 重构库存匹配、解析结果的展示格式,改为标准化多语言Markdown表格 6. 新增ODM ID库存字段支持,优化库存解析与映射逻辑 7. 新增LibreOffice转换隔离Profile配置,避免多实例运行冲突 8. 新增完整环境变量配置、数据库迁移脚本与测试用例 9. 适配前端代码,更新字段命名与聊天跳转逻辑 10. 更新OpenAPI规范适配Dify工具调用,删除已归档的旧部署文档
79 lines
2.2 KiB
Python
79 lines
2.2 KiB
Python
from pathlib import Path
|
|
import subprocess
|
|
|
|
from edkb_system.skills import soffice_util
|
|
|
|
|
|
def test_convert_with_soffice_uses_isolated_profile_and_cleans(monkeypatch, tmp_path):
|
|
profile_dir = tmp_path / "lo-profile-fixed"
|
|
|
|
def fake_mkdtemp(prefix=""):
|
|
profile_dir.mkdir(parents=True, exist_ok=True)
|
|
return str(profile_dir)
|
|
|
|
monkeypatch.setenv("EDKB_SOFFICE_ISOLATED_PROFILE", "1")
|
|
monkeypatch.setattr(soffice_util.tempfile, "mkdtemp", fake_mkdtemp)
|
|
|
|
captured = {}
|
|
|
|
def fake_run(cmd):
|
|
captured["cmd"] = cmd
|
|
assert profile_dir.exists()
|
|
return subprocess.CompletedProcess(cmd, 0, stdout="", stderr="")
|
|
|
|
monkeypatch.setattr(soffice_util, "run_soffice", fake_run)
|
|
|
|
source_path = tmp_path / "sample.doc"
|
|
source_path.write_text("dummy", encoding="utf-8")
|
|
out_dir = tmp_path / "out"
|
|
|
|
proc = soffice_util.convert_with_soffice(
|
|
"soffice",
|
|
convert_to="docx",
|
|
source_path=source_path,
|
|
out_dir=out_dir,
|
|
)
|
|
|
|
assert proc.returncode == 0
|
|
assert any(
|
|
str(item).startswith("-env:UserInstallation=") for item in captured["cmd"]
|
|
)
|
|
assert not profile_dir.exists()
|
|
|
|
|
|
def test_convert_with_soffice_can_use_shared_profile(monkeypatch, tmp_path):
|
|
called = {"mkdtemp": 0}
|
|
|
|
def fake_mkdtemp(prefix=""):
|
|
called["mkdtemp"] += 1
|
|
return str(tmp_path / "unused-profile")
|
|
|
|
monkeypatch.setenv("EDKB_SOFFICE_ISOLATED_PROFILE", "0")
|
|
monkeypatch.setattr(soffice_util.tempfile, "mkdtemp", fake_mkdtemp)
|
|
|
|
captured = {}
|
|
|
|
def fake_run(cmd):
|
|
captured["cmd"] = cmd
|
|
return subprocess.CompletedProcess(cmd, 0, stdout="", stderr="")
|
|
|
|
monkeypatch.setattr(soffice_util, "run_soffice", fake_run)
|
|
|
|
source_path = tmp_path / "sample.doc"
|
|
source_path.write_text("dummy", encoding="utf-8")
|
|
out_dir = tmp_path / "out"
|
|
|
|
proc = soffice_util.convert_with_soffice(
|
|
"soffice",
|
|
convert_to="docx",
|
|
source_path=source_path,
|
|
out_dir=out_dir,
|
|
)
|
|
|
|
assert proc.returncode == 0
|
|
assert called["mkdtemp"] == 0
|
|
assert not any(
|
|
str(item).startswith("-env:UserInstallation=") for item in captured["cmd"]
|
|
)
|
|
|