"""572-2 B04 유입 캐시 상한 — 프로젝트 넷만 남김 · 다시 쓴 것은 뒤로.""" import numpy as np from B04_PreProcess import B04_PreProcess_Router_Inflow as inflow def _write(path): np.savez( path, x_min=0.0, y_max=0.0, cell_m=1.0, n_rows=1, n_cols=1, road_slot=np.zeros(1), road_chainage=np.zeros(1), path_length=np.zeros(1), ) def test_cache_keeps_four_recent(tmp_path, monkeypatch): monkeypatch.setattr(inflow, "_routing_path", lambda stored: tmp_path / f"{stored}.npz") inflow._CACHE.clear() for name in "abcde": _write(tmp_path / f"{name}.npz") for name in "abcd": inflow._load_routing(name) inflow._load_routing("a") # 다시 씀 → 맨 뒤 inflow._load_routing("e") assert list(inflow._CACHE) == ["c", "d", "a", "e"]