feat: QR PNG 생성 + vote URL resolver
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
34
tests/e2e.py
34
tests/e2e.py
@@ -299,6 +299,38 @@ def t_topics_seeded_after_assign():
|
||||
assert c["tone"]
|
||||
|
||||
|
||||
def t_make_qr_png():
|
||||
from app import make_qr_png
|
||||
png = make_qr_png("http://localhost:8501/?mode=vote")
|
||||
# PNG signature 8 bytes
|
||||
assert png[:8] == b"\x89PNG\r\n\x1a\n"
|
||||
assert len(png) > 100
|
||||
|
||||
|
||||
def t_compute_vote_url_priority():
|
||||
import os as _os
|
||||
from app import compute_vote_url, save_data, load_data, _empty_state
|
||||
save_data(_empty_state())
|
||||
|
||||
# 1. settings.public_base_url 우선
|
||||
d = load_data()
|
||||
d["settings"]["public_base_url"] = "http://example.com:9000"
|
||||
save_data(d)
|
||||
assert compute_vote_url() == "http://example.com:9000/?mode=vote"
|
||||
|
||||
# 2. env fallback
|
||||
d["settings"].pop("public_base_url")
|
||||
save_data(d)
|
||||
_os.environ["PUBLIC_BASE_URL"] = "http://env-host:7777"
|
||||
assert compute_vote_url() == "http://env-host:7777/?mode=vote"
|
||||
_os.environ.pop("PUBLIC_BASE_URL")
|
||||
|
||||
# 3. localhost / LAN fallback
|
||||
url = compute_vote_url()
|
||||
assert url.endswith("/?mode=vote")
|
||||
assert url.startswith("http://")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"# E2E (data={TEST_DATA})\n")
|
||||
test("hackathon.json 로드 (34명, 7팀)", t_load)
|
||||
@@ -318,6 +350,8 @@ if __name__ == "__main__":
|
||||
test("stage 헬퍼", t_stage_helpers)
|
||||
test("topics 헬퍼", t_topics_helpers)
|
||||
test("topics 시드", t_topics_seeded_after_assign)
|
||||
test("QR PNG 생성", t_make_qr_png)
|
||||
test("vote URL 우선순위", t_compute_vote_url_priority)
|
||||
|
||||
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