feat: _empty_state — current_stage + topics 키 추가

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
th-kim0823
2026-04-27 19:42:13 +09:00
parent 3311002d95
commit c675b8c297
2 changed files with 86 additions and 2 deletions

View File

@@ -9,7 +9,11 @@ import shutil
# 격리 데이터 파일 (실제 hackathon.json과 분리)
TEST_DATA = tempfile.mktemp(suffix=".json")
shutil.copy("/app/hackathon.json", TEST_DATA)
SEED_CANDIDATES = ["/app/data/hackathon.json", "/app/hackathon.json"]
seed = next((p for p in SEED_CANDIDATES if os.path.exists(p)), None)
if seed is None:
raise SystemExit(f"seed 파일 없음: {SEED_CANDIDATES}")
shutil.copy(seed, TEST_DATA)
os.environ["DATA_PATH"] = TEST_DATA
os.environ["ADMIN_TOKEN"] = "test"
@@ -198,6 +202,29 @@ def t_vote_count():
assert len(list_votes()) == 0
def t_empty_state_has_topics_and_stage():
from app import _empty_state
s = _empty_state()
assert s["settings"]["current_stage"] == "intro"
assert s["topics"] == {"categories": []}
def t_load_data_backfills_nested_settings():
"""기존 settings에 voting_open만 있을 때 current_stage 자동 보강."""
legacy = {
"people": [],
"settings": {"voting_open": True},
"titles": {},
"tie_breaks": {},
"votes": [],
}
save_data(legacy)
fresh = load_data()
assert fresh["settings"]["voting_open"] is True
assert fresh["settings"]["current_stage"] == "intro"
assert fresh["topics"] == {"categories": []}
if __name__ == "__main__":
print(f"# E2E (data={TEST_DATA})\n")
test("hackathon.json 로드 (34명, 7팀)", t_load)
@@ -212,6 +239,8 @@ if __name__ == "__main__":
test("archive 동률 skip", t_archive_skip_pending)
test("atomic write", t_atomic_write)
test("clear_votes", t_vote_count)
test("empty_state 신규 키", t_empty_state_has_topics_and_stage)
test("load_data nested 키 backfill", t_load_data_backfills_nested_settings)
fails = sum(1 for r, _ in results if r == FAIL)
print(f"\n# {len(results)} 중 통과 {len(results) - fails}, 실패 {fails}")