Handle UNC binary directories in AI structure flow
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
import json
|
||||
import re
|
||||
@@ -1961,6 +1962,62 @@ def test_html5_ai_structure_routes_binary_cfe_through_windows_agent(tmp_path: Pa
|
||||
assert (output / f"codex-1c-context-{project_id}" / "AGENTS.md").exists()
|
||||
|
||||
|
||||
def test_html5_ai_structure_routes_unc_directory_with_cf_through_windows_agent(monkeypatch, tmp_path: Path):
|
||||
from api_server import html5_ai_structure_controller as controller
|
||||
|
||||
copied_root = tmp_path / "copied-unc"
|
||||
copied_root.mkdir()
|
||||
(copied_root / "base.cf").write_bytes(b"binary-cf")
|
||||
|
||||
copied_targets: list[tuple[str, Path]] = []
|
||||
|
||||
def fake_copy_smb_tree_to_local(*, source: str, target: Path, username: str, password: str, domain: str | None = None) -> None:
|
||||
copied_targets.append((source, target))
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
for item in copied_root.iterdir():
|
||||
if item.is_file():
|
||||
(target / item.name).write_bytes(item.read_bytes())
|
||||
|
||||
class FakeJob:
|
||||
job_id = "agent-import-test"
|
||||
status = "QUEUED"
|
||||
source = "CF_FILE"
|
||||
logs = ["queued"]
|
||||
|
||||
started: dict[str, object] = {}
|
||||
|
||||
async def fake_start_binary_job(**kwargs):
|
||||
started.update(kwargs)
|
||||
return FakeJob()
|
||||
|
||||
saved_runs: dict[str, dict[str, object]] = {}
|
||||
|
||||
monkeypatch.setattr(controller, "copy_smb_tree_to_local", fake_copy_smb_tree_to_local)
|
||||
|
||||
html = asyncio.run(
|
||||
controller.html5_ai_structure_run(
|
||||
project_id="unc-demo",
|
||||
form={
|
||||
"project_id": ["unc-demo"],
|
||||
"input_path": [r"\\192.168.220.200\mst\1c\MARKA\CODEX\CF"],
|
||||
"output_path": [r"\\192.168.220.200\mst\1c\MARKA\CODEX\CODEX"],
|
||||
"smb_username": ["m"],
|
||||
"smb_password": ["secret"],
|
||||
},
|
||||
prepare=lambda **_: {},
|
||||
work_root=tmp_path / "work",
|
||||
start_binary_job=fake_start_binary_job,
|
||||
save_run_state=lambda job_id, payload: saved_runs.setdefault(job_id, payload),
|
||||
)
|
||||
)
|
||||
|
||||
assert "Windows Agent" in html
|
||||
assert copied_targets
|
||||
assert started["input_path"] == r"\\192.168.220.200\mst\1c\MARKA\CODEX\CF"
|
||||
assert started["detected_binary_relative_path"] == "base.cf"
|
||||
assert "agent-import-test" in saved_runs
|
||||
|
||||
|
||||
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