Files
Aislo/resources/tester/test_m01_flow_c.py
T
eomsangdonandClaude Opus 5 17838d0098 feat(m01): 로직 테스트 방식 C — 흐름 그림
설계 값 → 표 찾기 → 수량 → × 단가 → 할증·덧줄 → 비목 합계 → 계 일곱 칸.
상자를 누르면 값·출처 · 로직이 부르는 로직은 상자 안에서 펼침 · 설계 값을 바꾸면
바로 다시 셈(로직 화면과 같은 `fetchLogic`·`runCalc` — 읽기·시험 계산만).
뼈대는 순수 모듈로 떼어 Node 헬퍼 + pytest 로 검증.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PAdA5ThqmtVSsbzjusk1cJ
2026-09-20 21:38:50 +09:00

83 lines
3.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""M01 로직 테스트 방식 C(흐름 그림) 뼈대 검증 — `M01_MasterData_UI_Test_C_Model.ts`.
프론트에 JS 테스트 러너가 없어 Node 헬퍼(helper_m01_flow_c.cjs)가 TS를 트랜스파일해
돌리고, pytest 는 그 결과(JSON)를 본다. 뼈대만 봄 — 금액은 엔진이 준 답을 그대로 옮기는지.
"""
import json
import os
import subprocess
import pytest
HERE = os.path.dirname(os.path.abspath(__file__))
@pytest.fixture(scope="module")
def flow():
proc = subprocess.run(
["node", os.path.join(HERE, "helper_m01_flow_c.cjs")],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
def test_칸_차례(flow):
"""설계 값 → 표 찾기 → 수량 → × 단가 → 할증·덧줄 → 비목 합계 → 계."""
assert flow["칸"] == ["입력", "중간", "수량", "단가", "덧줄", "비목", "계"]
# 계산 전에도 같은 뼈대 — 값만 비어 있음
assert flow["칸_계산전"] == flow["칸"]
# 돈이 아닌 로직은 호표가 없음
assert flow["칸_돈아님"] == ["입력", "중간", "계"]
def test_값은_엔진_답_그대로(flow):
v = flow["값"]
assert v["중간값"] == "15"
assert v["수량값"] == "1.2"
assert (v["단가노트"], v["단가값"]) == ("× 300,000", "360,000")
assert v["덧줄값"] == "10,800"
assert v["비목"] == [["노무비", "360,000"], ["재료비", "10,800"], ["경비", "40,000"]]
assert v["계값"] == "410,800"
def test_상자를_누르면_값과_출처(flow):
v = flow["값"]
assert v["중간식"] == ["식", "찾기(QF000422, 높이=높이).증가율"]
assert v["수량식"] == ["식", "찾기(QF000421, 뒷길이=뒷길이).석공"]
assert v["덧줄식"] == ["식", "노무비 * 0.03"]
assert ["단위", "㎝"] in v["입력출처"]
# 비목 상자 = 그 비목에 들어온 줄
assert v["비목상세"] == [[["석공", "360,000"]], [["잡재료", "10,800"]], [["굴착기", "40,000"]]]
def test_로직이_로직을_부르는_줄(flow):
assert flow["logicRef"] == ["GC000268", None]
assert flow["값"]["로직"] == "GC000268" # 펼칠 상자
assert flow["값"]["로직아님"] is None
def test_id_는_다시_그려도_같음(flow):
assert flow["값"]["id"] == ["수량:0", "단가:0", "덧줄:0", "계"]
assert flow["값"]["묶음"] == ["노무비", "경비"] # 비목으로 묶어 접기
def test_계산_전과_멈춤(flow):
# 값이 없어도 식은 보임 · 값 없는 요소는 막힘 표시
assert flow["계산전"]["수량값"] == ""
assert flow["계산전"]["수량식"][1].startswith("찾기(")
assert flow["계산전"]["단가막힘"] is True
assert flow["계산전"]["계값"] == ""
assert flow["멈춤"]["칸"] == flow["칸"] and flow["멈춤"]["계값"] == ""
def test_돈_아닌_로직(flow):
assert flow["돈아님"]["중간값"] == "0.8"
assert flow["돈아님"]["결과값"] == "42.5"
assert flow["돈아님"]["결과식"] == ["식", "3600 * q * E / Cm"]