test(m01-sl): 표 블록 열이 서버 · Table_Build · Import_Parse 셋 다 같은지
- 견본 표(범위 조건 · 값 칸 범위 80~100 · 범위 칸에 수 하나)로 서버 /outside 표 답 = sub3 blockCells = sub6 tableRows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KmELpdXFDRZHhfbGuRhSmL
This commit is contained in:
@@ -10,7 +10,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
|
||||
@@ -23,6 +25,7 @@ from M01_MasterData import M01_MasterData_Router as router_module
|
||||
from M01_MasterData import M01_MasterData_Store as store
|
||||
from M01_MasterData.SheetLogic import M01_SL_Router as sl
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
REAL = store.FOLDER
|
||||
OWN = "로직_자체.json"
|
||||
SAMPLE = "QF999997"
|
||||
@@ -247,3 +250,57 @@ def test_시스템_관리자가_아니면_403(folder: Path) -> None:
|
||||
assert client.post("/api/m01/sl/outside", json={"items": []}).status_code == 403
|
||||
app.dependency_overrides[verify_session] = lambda: {"role": "SYSTEM_ADMIN", "company_id": None}
|
||||
assert client.get("/api/m01/sl/list").json() == {"logics": []}
|
||||
|
||||
|
||||
def _node_json(script: str) -> object:
|
||||
result = subprocess.run(
|
||||
["node", "--experimental-strip-types", "--no-warnings",
|
||||
"--input-type=module", "-e", script],
|
||||
capture_output=True, text=True, encoding="utf-8", timeout=60, cwd=ROOT,
|
||||
) # fmt: skip
|
||||
assert result.returncode == 0, result.stderr
|
||||
return json.loads(result.stdout)
|
||||
|
||||
|
||||
@pytest.mark.skipif(NO_NODE, reason="node 가 없음")
|
||||
def test_표_블록이_Table_Import_와_같은_열(client: TestClient) -> None:
|
||||
"""서버 표 답(머리 줄 + 줄) = sub3 Table_Build `blockCells` = sub6 Import_Parse `tableRows`."""
|
||||
got = _post(
|
||||
client, "/api/m01/sl/outside", {"items": [{"id": "t", "kind": "표", "table": SAMPLE}]}
|
||||
)
|
||||
rows = got["values"][0]["rows"]
|
||||
table = json.dumps(
|
||||
{"조건": TABLE["조건"], "값칸": TABLE["값칸"], "줄": TABLE["줄"]}, ensure_ascii=False
|
||||
)
|
||||
info = json.dumps(
|
||||
{"conds": TABLE["조건"], "vals": TABLE["값칸"], "rows": TABLE["줄"]}, ensure_ascii=False
|
||||
)
|
||||
|
||||
build = (ROOT / "M01_MasterData/SheetLogic/M01_SL_Table_Build.ts").as_uri()
|
||||
cells = _node_json(
|
||||
f"import {{ blockCells }} from '{build}';console.log(JSON.stringify(blockCells({info})));"
|
||||
)
|
||||
letters = "ABCDEFGHIJ"
|
||||
mine = {
|
||||
f"{letters[c]}{r + 1}": {"값": v}
|
||||
for r, line in enumerate(rows)
|
||||
for c, v in enumerate(line)
|
||||
if v is not None
|
||||
}
|
||||
assert cells == mine
|
||||
|
||||
src = (ROOT / "M01_MasterData/SheetLogic/M01_SL_Import_Parse.ts").read_text(encoding="utf-8")
|
||||
body = re.search(r"/\*\* 범위 칸 꼬리[\s\S]*?\nexport function tableRows[\s\S]*?\n}\n", src)
|
||||
assert body, "Import_Parse 의 tableCols · tableRows 를 못 찾음"
|
||||
script = (
|
||||
"const currentLanguageIndex = 0;\n"
|
||||
+ body.group(0).replace("export ", "")
|
||||
+ f"\nconsole.log(JSON.stringify(tableRows({table})));"
|
||||
)
|
||||
result = subprocess.run(
|
||||
["node", "--experimental-strip-types", "--no-warnings",
|
||||
"--input-type=module-typescript", "-e", script],
|
||||
capture_output=True, text=True, encoding="utf-8", timeout=60,
|
||||
) # fmt: skip
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert json.loads(result.stdout) == rows
|
||||
|
||||
Reference in New Issue
Block a user