Prepare AI-ready 1C structure packages
This commit is contained in:
@@ -1672,6 +1672,71 @@ def test_import_supports_structure_only_indexing(monkeypatch, tmp_path: Path):
|
||||
assert {"HTTP-сервисы", "Подсистемы", "Последовательности", "Нумераторы документов"}.issubset(common_labels)
|
||||
|
||||
|
||||
def test_ai_structure_prepare_writes_ai_ready_package(tmp_path: Path):
|
||||
source = tmp_path / "source"
|
||||
output = tmp_path / "ai-out"
|
||||
source.mkdir()
|
||||
(source / "metadata.xml").write_text(
|
||||
"""
|
||||
<Configuration>
|
||||
<Catalog name="Контрагенты" qualifiedName="Справочник.Контрагенты">
|
||||
<Attribute name="ИНН" qualifiedName="Справочник.Контрагенты.ИНН" />
|
||||
</Catalog>
|
||||
<CommonModule name="Интеграция" qualifiedName="ОбщийМодуль.Интеграция" />
|
||||
</Configuration>
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(source / "Интеграция.bsl").write_text(
|
||||
"Процедура Выполнить() Экспорт\nКонецПроцедуры\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
client = TestClient(app)
|
||||
|
||||
response = client.post(
|
||||
"/ai-structure/prepare",
|
||||
json={"project_id": "ai-demo", "input_path": str(source), "output_path": str(output)},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
payload = response.json()
|
||||
assert payload["status"] == "ready"
|
||||
assert payload["snapshot"]["nodes"] >= 2
|
||||
assert (output / "manifest.json").exists()
|
||||
assert (output / "normalized_project.json").exists()
|
||||
assert (output / "sir_snapshot.json").exists()
|
||||
assert "Treat modules/forms/commands as parts" in (output / "ai_context.md").read_text(encoding="utf-8")
|
||||
|
||||
page = client.get("/html5/projects/ai-demo/ai-structure")
|
||||
assert_html5_response_contract(page, 'data-html5-page="ai-structure"', "Структура для ИИ", full_page=True)
|
||||
|
||||
html5_run = client.post(
|
||||
"/html5/projects/ai-demo/ai-structure/run",
|
||||
data={"project_id": "ai-demo-html5", "input_path": str(source), "output_path": str(tmp_path / "html5-out")},
|
||||
)
|
||||
assert_html5_response_contract(html5_run, "ready", "sir_snapshot.json", "normalized_project.json")
|
||||
|
||||
|
||||
def test_ai_structure_prepare_reports_cf_cfe_export_required(tmp_path: Path):
|
||||
source = tmp_path / "cf-source"
|
||||
output = tmp_path / "cf-out"
|
||||
source.mkdir()
|
||||
(source / "base.cf").write_bytes(b"binary-cf")
|
||||
(source / "ext.cfe").write_bytes(b"binary-cfe")
|
||||
client = TestClient(app)
|
||||
|
||||
response = client.post(
|
||||
"/ai-structure/prepare",
|
||||
json={"project_id": "binary-demo", "input_path": str(source), "output_path": str(output)},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
payload = response.json()
|
||||
assert payload["status"] == "export_required"
|
||||
assert len(payload["binary_1c_files"]) == 2
|
||||
assert "DumpConfigToFiles" in (output / "export_plan.md").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_import_full_replace_replaces_current_normalized_project(tmp_path: Path):
|
||||
first = tmp_path / "first"
|
||||
second = tmp_path / "second"
|
||||
|
||||
Reference in New Issue
Block a user