tmp/ 가 창끼리 안 건너가는 것이 확정돼(랩탑이 시간 두고 두 번 확인) 시험·예외가 저절로 건너가도록 git 안으로 옮김. 사용자 확정. - 내용은 하나도 안 고침 — 자리만 옮김. tmp/tests 는 남겨 둠. - 같은 이름이 이미 있던 64 개는 랩탑 것을 그대로 두고 건너뜀. - helper_b05_*.js 둘은 랩탑이 .cjs 로 이미 올린 것과 **줄바꿈만 다른 같은 내용**이라 복사본을 도로 뺌(시험이 .cjs 를 부름). - resources/tester/ 에서 전체 1176 통과 · 29 건너뜀 · 실패 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
54 lines
2.1 KiB
Python
54 lines
2.1 KiB
Python
"""산출 요약(최소·중앙·최대) 검사 — 2026-09-07 조율 창 권고.
|
|
|
|
이것은 **검사가 아니라 눈에 띄게 하는 장치**다. 기준을 정해 걸러 내지 않는다 —
|
|
임도 물량은 ㎥·㎡·m·ton 이 섞여 「얼마 이하면 이상하다」를 한 벌로 못 정한다.
|
|
그래서 시험도 「단위를 안 섞는가」·「없는 값을 0 으로 만들지 않는가」를 본다.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from common_util.common_util_quantity_spread import spread, spread_by_unit # noqa: E402
|
|
|
|
|
|
def test_값이_없으면_0이_아니라_없음() -> None:
|
|
"""0 으로 만들면 「값이 0 인 것」과 구별이 안 된다."""
|
|
assert spread([]) is None
|
|
assert spread_by_unit([], value_key="amount") == {}
|
|
|
|
|
|
def test_단위를_안_섞음() -> None:
|
|
"""㎥ 와 ton 을 한 통에 넣으면 최솟값이 뜻을 잃는다."""
|
|
rows = [
|
|
{"unit": "㎥", "amount": 2526.99},
|
|
{"unit": "㎥", "amount": 90.51},
|
|
{"unit": "ton", "amount": 23.89},
|
|
]
|
|
result = spread_by_unit(rows, value_key="amount")
|
|
assert result["㎥"]["min"] == 90.51
|
|
assert result["㎥"]["max"] == 2526.99
|
|
assert result["ton"]["count"] == 1
|
|
|
|
|
|
def test_자릿수가_어긋난_값이_최솟값에서_드러남() -> None:
|
|
"""서브가 겪은 「합계 68.8원」 같은 것 — 값이 있기는 하니 시험은 안 잡는다.
|
|
최솟값이 나머지와 자릿수가 다르면 사람이 본다."""
|
|
rows = [{"unit": "㎡", "amount": v} for v in (13518.6, 18952.3, 68.8)]
|
|
result = spread_by_unit(rows, value_key="amount")
|
|
assert result["㎡"]["min"] == 68.8
|
|
assert result["㎡"]["max"] == 18952.3
|
|
|
|
|
|
def test_숫자가_아닌_값은_건너뜀() -> None:
|
|
rows = [{"unit": "㎥", "amount": None}, {"unit": "㎥", "amount": 5.0}]
|
|
assert spread_by_unit(rows, value_key="amount")["㎥"]["count"] == 1
|
|
|
|
|
|
def test_단위가_없으면_물음표로_모음() -> None:
|
|
assert "?" in spread_by_unit([{"amount": 1.0}], value_key="amount")
|