"""520-7 배수유역 저장분 받기 — 되돌리기(Ctrl+Z) 한 번에 셋이 부르는 저장분 GET 을 한 번으로. 화면 파일(`B05_Profile_UI_Drainage_Saved` · `_Run`)을 가짜 fetch 로 돌림(`helper_520_7_drainage_saved_once.cjs`). - 관 자리 되돌림 · 시설 따라감 reload · 묶음 초안 버림이 한 번에 = GET 한 번 · 셋 다 「올렸음」. - 초안 버림이 먼저 · reload 가 뒤따름 = GET 한 번 · 초안 버림도 「올렸음」(낡음 남지 않음). - 화면이 저장분 그대로면 초안 버림 = GET 없이 그 답 다시 올림 · 다른 답이 오른 뒤면 다시 받음. - 세션 관 초안이 있으면 그 관 목록으로 세부 유역(GET 아님). """ import json import os import subprocess import pytest HERE = os.path.dirname(os.path.abspath(__file__)) @pytest.fixture(scope="module") def r(): proc = subprocess.run( ["node", os.path.join(HERE, "helper_520_7_drainage_saved_once.cjs")], capture_output=True, text=True, timeout=60, encoding="utf-8", ) assert proc.returncode == 0, proc.stderr return json.loads(proc.stdout) def test_open_fetches_once(r): assert r["open"] == {"gets": 1, "results": [True], "matches": True} def test_undo_three_callers_one_get(r): assert r["undoMoved"] == {"gets": 1, "results": [True, True, True], "shown": "saved2"} def test_back_before_reload_still_applied(r): assert r["backThenReload"] == {"gets": 1, "results": [True, True], "shown": ["saved3"]} def test_back_reuses_shown_saved_answer(r): assert r["backOnly"] == {"gets": 0, "results": [True], "shown": "saved3"} assert r["afterLive"] == {"gets": 1, "results": [True], "shown": "saved4"} def test_pending_pipes_use_detail_not_get(r): assert r["pending"] == {"gets": 0, "detail": 1, "results": [True]}