feat: stage 헬퍼 (get_stage, set_stage, can_accept_votes)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
tests/e2e.py
34
tests/e2e.py
@@ -225,6 +225,39 @@ def t_load_data_backfills_nested_settings():
|
||||
assert fresh["topics"] == {"categories": []}
|
||||
|
||||
|
||||
def t_stage_helpers():
|
||||
from app import get_stage, set_stage, can_accept_votes, load_data, save_data, _empty_state
|
||||
save_data(_empty_state())
|
||||
|
||||
assert get_stage() == "intro"
|
||||
assert can_accept_votes(load_data()) is False # intro → False
|
||||
|
||||
set_stage("vote")
|
||||
d = load_data()
|
||||
assert d["settings"]["current_stage"] == "vote"
|
||||
assert d["settings"]["voting_open"] is True
|
||||
assert can_accept_votes(d) is True
|
||||
|
||||
set_stage("topics")
|
||||
d = load_data()
|
||||
assert d["settings"]["current_stage"] == "topics"
|
||||
assert d["settings"]["voting_open"] is True # 떠나도 voting_open 유지
|
||||
assert can_accept_votes(d) is False # stage 다르면 False
|
||||
|
||||
# 명시적 마감 후 vote 다시 들어오면 voting_open 자동 True
|
||||
d["settings"]["voting_open"] = False
|
||||
save_data(d)
|
||||
set_stage("vote")
|
||||
assert can_accept_votes(load_data()) is True
|
||||
|
||||
# invalid stage → ValueError
|
||||
try:
|
||||
set_stage("invalid_stage")
|
||||
raise AssertionError("expected ValueError")
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"# E2E (data={TEST_DATA})\n")
|
||||
test("hackathon.json 로드 (34명, 7팀)", t_load)
|
||||
@@ -241,6 +274,7 @@ if __name__ == "__main__":
|
||||
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)
|
||||
test("stage 헬퍼", t_stage_helpers)
|
||||
|
||||
fails = sum(1 for r, _ in results if r == FAIL)
|
||||
print(f"\n# {len(results)} 중 통과 {len(results) - fails}, 실패 {fails}")
|
||||
|
||||
Reference in New Issue
Block a user