Files
Aislo/resources/tester/test_145_3_b08_summary_owners.py
T
eomsangdonandClaude Opus 5.5 dbc9a32b72 feat(B08): 구조물 집계표 열마다 사본 주인별 값 owners(145-3 이음)
- 열 owners = {사본 주인 id: 그 주인이 낸 값} — 주인 id = linked_snapshots 키(pipe@측점 · 구조물 id · {id}__{그룹})
- 칸을 낸 잇기 사본이 먼저 · 없으면 시설 본체 · owners 합 = 열 계 · 기존 키 · 화면 그대로
- 새 test_145_3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01STqEqztUthVFBmEP18wBSz
2026-10-09 15:20:56 +09:00

47 lines
2.3 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 -*-
"""145-3 이음 — B08 구조물 집계표 열마다 `owners` = {사본 주인 id: 그 주인이 낸 값}.
주인 id = `linked_snapshots` 키(`pipe@측점` · 구조물 id · `{id}__{그룹}`) · 열 owners 합 = 열 계 ·
칸을 낸 잇기 사본이 먼저(없으면 시설 본체).
"""
from __future__ import annotations
import pytest
from test_120_b08_drain_summary import out # noqa: F401 — 픽스처(관 밖 횡단배수 견본)
from test_143_1_b08_linked_snapshots import _run as _run_143
from test_143_1_b08_linked_snapshots import root # noqa: F401 — 픽스처(실제 사본 폴더)
from M02_MasterTemplete import M02_Item_Snapshot as snapshots
def _check_sums(result: dict, keys: set[str]) -> None:
for column in result["columns"]:
owners = column["owners"]
assert set(owners) <= keys, column["id"]
assert sum(owners.values()) == pytest.approx(result["total"].get(column["id"], 0.0))
def test_owners_합_열_계_주인은_사본_키(out): # noqa: F811
cols = {c["id"]: c for c in out["columns"]}
_check_sums(out, set(out["linked"]))
# 본체 칸 = 본체 잇기 사본(gboxbody) · 날개벽 = 유입 잇기 · 흙막이 = 유출 잇기
assert cols["pipe:box|body|2.0×2.0"]["owners"] == {"pipe@300.0__gboxbody": 9.6}
assert cols["pipe:box_culvert|wing|inlet"]["owners"] == {"pipe@300.0__gboxin": 1.0}
assert cols["pipe:revet|돌쌓기(메)|2.0"]["owners"] == {"pipe@300.0__gboxout": 10.0}
# 세월교 월류 폭 = 저장된 잇기(gford) · 관 공은 본체(사본 키 = 관 지점 id)
assert cols["pipe:ford|1000|2|width"]["owners"] == {"pipe@400.0__gford": 12.0}
assert cols["pipe:len|800"]["owners"] == {"pipe@300.0": 18.0}
# B05 구조물 = 구조물 id · 그룹 잇기 = {id}__{그룹}
assert cols["pipe:open_ditch"]["owners"] == {"s-ditch": 1.0}
assert cols["pipe:cross_underdrain"]["owners"] == {"s-ud__gcrossud": 1.0}
def test_실제_사본_폴더_키와_같다(root): # noqa: F811
result = _run_143(root)
linked = set(snapshots.linked_snapshots(root))
_check_sums(result, linked)
cols = {c["id"]: c for c in result["columns"]}
assert cols["pipe:len|800"]["owners"] == {"pipe@100.0": 16.0}
assert cols["pipe:len|1000"]["owners"] == {"pipe@500.0__gford": 18.0}