Files
Aislo/resources/tester/test_est_multi_search.py
T
eomsangdonandClaude Opus 5.5 5b2ebeb676 feat(est-test): 저장된 작업 통합 검색과 가져오기
- 원본 통합 검색처럼 자료 7종을 검색어로 찾고 하위 연결째 현재 공사로 가져옴

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 19:43:15 +09:00

37 lines
1.6 KiB
Python

"""EST 테스트 앱 통합 검색(원본 TFRMMULTISERCH, 검색위치 = 저장된 작업)."""
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def test_search_finds_words_in_selected_kinds(tmp_path):
sample = json.loads((ROOT / "tools/est-test/sample.json").read_text(encoding="utf-8"))
sample["name"] = "검색 시험 공사"
(tmp_path / ("a" * 24 + ".json")).write_text(json.dumps(sample), encoding="utf-8")
(tmp_path / ("b" * 24 + ".json")).write_text("{bad json", encoding="utf-8")
(tmp_path / "forms.json").write_text("[]", encoding="utf-8")
script = """
const s = require('./tools/est-test/search-store.cjs'), dir = process.argv[1];
const out = {};
out.labor = s.search(dir, '건설기계 운전사', ['6']);
out.none = s.search(dir, '건설기계', ['5']);
out.excluded = s.search(dir, '건설기계', ['6'], 'a'.repeat(24));
const err = [];
for (const args of [['', ['6']], ['x', ['999']]]) { try { s.search(dir, ...args); } catch (e) { err.push(e.message.slice(0, 4)); } }
out.err = err;
process.stdout.write(JSON.stringify(out));
"""
result = json.loads(
subprocess.check_output(["node", "-e", script, str(tmp_path)], cwd=ROOT).decode("utf-8")
)
hit = result["labor"]["hits"][0]
assert result["labor"]["total"] >= 1
assert hit["project"] == "검색 시험 공사" and hit["kind"] == 6 and hit["label"] == "노임단가"
assert "건설기계운전사" in hit["Name"].replace(" ", "")
assert result["none"]["total"] == 0
assert result["excluded"]["total"] == 0
assert result["err"] == ["검색어를", "검색할 "]