From 6c6929a505625027925c732155f1c21d6543fb4e Mon Sep 17 00:00:00 2001
From: th-kim0823
Date: Mon, 27 Apr 2026 19:48:34 +0900
Subject: [PATCH] =?UTF-8?q?feat:=20topics=20=ED=97=AC=ED=8D=BC=20(get=5Fto?=
=?UTF-8?q?pics,=20update=5Ftopics)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-Authored-By: Claude Sonnet 4.6
---
app.py | 11 +++++++++++
tests/e2e.py | 21 +++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/app.py b/app.py
index 4c5a7f1..61dc913 100644
--- a/app.py
+++ b/app.py
@@ -134,6 +134,17 @@ def can_accept_votes(data):
return s.get("current_stage") == "vote" and s.get("voting_open", False)
+def get_topics():
+ return load_data().get("topics", {}).get("categories", [])
+
+
+def update_topics(categories):
+ def _fn(data):
+ data.setdefault("topics", {})
+ data["topics"]["categories"] = categories
+ update_data(_fn)
+
+
def get_tie_breaks():
return load_data().get("tie_breaks", {})
diff --git a/tests/e2e.py b/tests/e2e.py
index adb84b4..d77b59b 100644
--- a/tests/e2e.py
+++ b/tests/e2e.py
@@ -258,6 +258,26 @@ def t_stage_helpers():
pass
+def t_topics_helpers():
+ from app import get_topics, update_topics, load_data, save_data, _empty_state
+ save_data(_empty_state())
+
+ assert get_topics() == []
+
+ sample = [
+ {"id": "T1", "title": "테스트", "tagline": "tl", "tone": "tn",
+ "items": [f"item{i}" for i in range(10)]}
+ ]
+ update_topics(sample)
+ assert get_topics() == sample
+
+ # atomic 갱신 확인
+ sample2 = [{"id": "T1", "title": "교체", "tagline": "tl", "tone": "tn",
+ "items": [f"x{i}" for i in range(10)]}]
+ update_topics(sample2)
+ assert get_topics() == sample2
+
+
if __name__ == "__main__":
print(f"# E2E (data={TEST_DATA})\n")
test("hackathon.json 로드 (34명, 7팀)", t_load)
@@ -275,6 +295,7 @@ if __name__ == "__main__":
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)
+ test("topics 헬퍼", t_topics_helpers)
fails = sum(1 for r, _ in results if r == FAIL)
print(f"\n# {len(results)} 중 통과 {len(results) - fails}, 실패 {fails}")