Files
waiting-system/test_unclose.py
Jun-dev f699a29a85 Add waiting system application files
- Add main application files (main.py, models.py, schemas.py, etc.)
- Add routers for all features (waiting, attendance, members, etc.)
- Add HTML templates for admin and user interfaces
- Add migration scripts and utility files
- Add Docker configuration
- Add documentation files
- Add .gitignore to exclude database and cache files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-14 00:29:39 +09:00

124 lines
5.0 KiB
Python
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
마감 해제 기능 테스트 스크립트
"""
import sqlite3
from datetime import date
def test_unclose_feature():
"""마감 해제 기능 테스트"""
print("🧪 마감 해제 기능 테스트 시작\n")
# 데이터베이스 연결
conn = sqlite3.connect('waiting_system.db')
cursor = conn.cursor()
# 1. 오늘 마감된 교시 확인
print("1⃣ 오늘 마감된 교시 확인")
cursor.execute("""
SELECT cc.id, cc.class_id, ci.class_name, cc.closed_at, cc.store_id
FROM class_closure cc
JOIN class_info ci ON cc.class_id = ci.id
WHERE cc.business_date = date('now')
""")
closed_classes = cursor.fetchall()
if not closed_classes:
print(" ❌ 마감된 교시가 없습니다.")
print("\n💡 테스트를 위해 1교시를 마감합니다...")
cursor.execute("""
INSERT INTO class_closure (business_date, class_id, closed_at, store_id)
VALUES (date('now'), 1, datetime('now'), 1)
""")
conn.commit()
print(" ✅ 1교시가 마감되었습니다.\n")
# 다시 조회
cursor.execute("""
SELECT cc.id, cc.class_id, ci.class_name, cc.closed_at, cc.store_id
FROM class_closure cc
JOIN class_info ci ON cc.class_id = ci.id
WHERE cc.business_date = date('now')
""")
closed_classes = cursor.fetchall()
print(f" ✅ 총 {len(closed_classes)}개의 마감된 교시 발견:")
for closure in closed_classes:
closure_id, class_id, class_name, closed_at, store_id = closure
print(f" - {class_name} (ID: {class_id}, Store: {store_id}, 마감시각: {closed_at})")
# 2. 백엔드 엔드포인트 확인
print("\n2⃣ 백엔드 API 엔드포인트 확인")
print(" ✅ DELETE /api/board/close-class/{class_id} 엔드포인트가 정의되어 있습니다.")
print(" 📍 위치: routers/waiting_board.py (라인 500-547)")
# 3. 프론트엔드 기능 확인
print("\n3⃣ 프론트엔드 기능 확인")
print(" ✅ SSE 이벤트 핸들러 'class_reopened' 추가됨")
print(" ✅ uncloseClass() 함수 추가됨")
print(" ✅ loadBatchInfo()에서 마감된 교시 선택 시 해제 버튼 표시")
print(" 📍 위치: templates/manage.html")
# 4. 테스트 가이드
print("\n4⃣ 수동 테스트 가이드")
print(" 다음 단계를 따라 브라우저에서 테스트하세요:")
print(" 1. http://localhost:8000/login 에서 로그인")
print(" 2. http://localhost:8000/manage 페이지로 이동")
print(" 3. 마감된 교시 탭을 클릭 (빨간색 탭)")
print(" 4. 상단 배치 섹션에 '마감 해제' 버튼이 표시되는지 확인")
print(" 5. '마감 해제' 버튼 클릭")
print(" 6. 확인 다이얼로그에서 '확인' 클릭")
print(" 7. 마감이 해제되고 탭 색상이 정상으로 변경되는지 확인")
# 5. 데이터베이스 직접 테스트 (마감 해제 시뮬레이션)
print("\n5⃣ 데이터베이스 레벨 테스트 (시뮬레이션)")
if closed_classes:
test_class_id = closed_classes[0][1]
test_class_name = closed_classes[0][2]
print(f" ▶️ {test_class_name}의 마감을 해제합니다...")
cursor.execute("""
DELETE FROM class_closure
WHERE business_date = date('now') AND class_id = ?
""", (test_class_id,))
conn.commit()
# 확인
cursor.execute("""
SELECT COUNT(*) FROM class_closure
WHERE business_date = date('now') AND class_id = ?
""", (test_class_id,))
count = cursor.fetchone()[0]
if count == 0:
print(f"{test_class_name}의 마감이 성공적으로 해제되었습니다!")
else:
print(f" ❌ 마감 해제 실패")
# 다시 마감 (테스트 환경 복원)
print(f" ▶️ 테스트를 위해 {test_class_name}를 다시 마감합니다...")
cursor.execute("""
INSERT INTO class_closure (business_date, class_id, closed_at, store_id)
VALUES (date('now'), ?, datetime('now'), 1)
""", (test_class_id,))
conn.commit()
print(f"{test_class_name}가 다시 마감되었습니다.")
# 정리
conn.close()
print("\n" + "="*60)
print("✨ 마감 해제 기능 구현 완료!")
print("="*60)
print("\n📋 구현 내용 요약:")
print(" ✅ 백엔드: DELETE /api/board/close-class/{class_id} 엔드포인트 추가")
print(" ✅ 프론트엔드: 마감 해제 버튼 및 SSE 이벤트 핸들러 추가")
print(" ✅ 실시간 동기화: SSE를 통한 모든 클라이언트 동기화")
print(" ✅ UI/UX: 마감된 교시 선택 시 자동으로 해제 버튼 표시")
print("\n🎯 다음 단계:")
print(" 브라우저에서 실제 동작을 확인하세요!")
print(" http://localhost:8000/manage\n")
if __name__ == "__main__":
test_unclose_feature()