Add local 1C runtime adapter execution for CF files
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-22 08:10:49 +03:00
parent aa36d58a73
commit 5a4e3c6d9d
2 changed files with 160 additions and 1 deletions
@@ -111,3 +111,47 @@ def test_runtime_platform_reports_capabilities(monkeypatch, tmp_path):
payload = response.json()
assert payload["platform_found"] is True
assert "cf_dump_plan" in payload["capabilities"]
def test_runtime_adapter_local_1c_executes_cf_dump(monkeypatch, tmp_path):
designer = tmp_path / "fake_designer.py"
designer.write_text(
"""
import sys
from pathlib import Path
args = sys.argv[1:]
if args and args[0] == "CREATEINFOBASE":
target = next(item for item in args[1:] if item.startswith("File="))[5:].rstrip(";")
Path(target).mkdir(parents=True, exist_ok=True)
raise SystemExit(0)
if "/DumpConfigToFiles" in args:
target = Path(args[args.index("/DumpConfigToFiles") + 1])
target.mkdir(parents=True, exist_ok=True)
(target / "metadata.xml").write_text(
"<Configuration><Catalog name='Контрагенты' qualifiedName='Справочник.Контрагенты' /></Configuration>",
encoding="utf-8",
)
raise SystemExit(0)
raise SystemExit(0)
""",
encoding="utf-8",
)
cf_file = tmp_path / "demo.cf"
cf_file.write_text("binary-placeholder", encoding="utf-8")
monkeypatch.setenv("RUNTIME_ADAPTER_MODE", "local_1c")
monkeypatch.setenv("ONEC_DESIGNER_PATH", str(designer))
monkeypatch.setenv("ONEC_ENABLE_DESIGNER_EXECUTION", "true")
client = TestClient(app)
response = client.post(
"/runtime/import",
json={"source_kind": "CF_FILE", "project_id": "cf-exec", "path": str(cf_file)},
)
assert response.status_code == 200
payload = response.json()
assert payload["status"] == "normalized"
assert payload["platform_found"] is True
assert payload["normalized_project"]["project_id"] == "cf-exec"
assert "Local .cf converted to metadata export" in "\n".join(payload["diagnostics"])