feat(휴가): 협의자 결재·신청 화면 개편(라디오·붙박이 달력·결재 라인)·내 신청 내역
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
VACATION_TEST_DB_URL 이 localhost/127.0.0.1 일 때만 돈다(아니면 skip). 앱 계정(vacation_app)으로 접속해 권한(GRANT)까지 본다.
|
||||
psql … -v app_password=… -f scripts/sql/vacation_db_init.sql
|
||||
psql … -d vacation_db -f scripts/sql/vacation_db_001_options_mail.sql
|
||||
psql … -d vacation_db -f scripts/sql/vacation_db_003_consults.sql
|
||||
VACATION_TEST_DB_URL=postgresql://vacation_app:<pw>@localhost:55432/vacation_db python -m pytest tests/test_vacation_db.py
|
||||
"""
|
||||
import os
|
||||
@@ -43,6 +44,65 @@ class VacationOptionsDBTests(unittest.TestCase):
|
||||
again = self.st.save_options(approvers=[], notifiers=[], by="admin@test.local") # 덮어쓰기(키 하나)
|
||||
self.assertEqual((again["approvers"], again["notifiers"]), ([], []))
|
||||
|
||||
def _consult_req(self, owner, status="제출"):
|
||||
return self.st.create_request(
|
||||
owner=owner, owner_name="김철수", status=status,
|
||||
payload={"vacation_type": "연차", "start_date": "2026-11-05", "end_date": "2026-11-06", "start_half": "full", "end_half": "full", "reason": "x"},
|
||||
consults=[{"email": "park@test.local", "name": "박과장", "message": "박 내용"},
|
||||
{"email": "choi@test.local", "name": "최대리", "message": "최 내용"}])
|
||||
|
||||
def test_consult_all_approve_moves_to_approver(self):
|
||||
"""협의자(003) — 모두 승인해야 결재자에게, 그 전엔 승인 못 함, 내 협의 목록·권한."""
|
||||
owner = f"kim-{uuid.uuid4().hex[:6]}@test.local"
|
||||
req = self._consult_req(owner)
|
||||
rid = req["id"]
|
||||
self.assertEqual(req["status"], "협의중")
|
||||
self.assertEqual([(c["email"], c["message"], c["state"]) for c in self.st.list_consults(request_id=rid)],
|
||||
[("park@test.local", "박 내용", "대기"), ("choi@test.local", "최 내용", "대기")])
|
||||
with self.assertRaises(ValueError): # 협의 중에는 결재자가 승인 못 함
|
||||
self.st.approve(request_id=rid, approver_email="lee@test.local")
|
||||
self.assertNotIn(rid, [r["id"] for r in self.st.list_pending()])
|
||||
self.assertIn(rid, [r["id"] for r in self.st.my_consults(email="PARK@test.local")])
|
||||
with self.assertRaises(PermissionError):
|
||||
self.st.decide_consult(request_id=rid, email="nobody@test.local", approve=True)
|
||||
got, event = self.st.decide_consult(request_id=rid, email="park@test.local", approve=True)
|
||||
self.assertEqual((got["status"], event), ("협의중", None)) # 한 명 남음
|
||||
self.assertNotIn(rid, [r["id"] for r in self.st.my_consults(email="park@test.local")])
|
||||
with self.assertRaises(ValueError): # 같은 사람이 두 번은 못 함
|
||||
self.st.decide_consult(request_id=rid, email="park@test.local", approve=True)
|
||||
got, event = self.st.decide_consult(request_id=rid, email="choi@test.local", approve=True)
|
||||
self.assertEqual((got["status"], event), ("제출", "consulted"))
|
||||
self.assertIn(rid, [r["id"] for r in self.st.list_pending()])
|
||||
self.assertEqual(self.st.approve(request_id=rid, approver_email="lee@test.local")["status"], "승인")
|
||||
self.st.hard_delete(request_id=rid, user_email=owner, is_admin=True)
|
||||
self.assertEqual(self.st.list_consults(request_id=rid), []) # 신청을 지우면 함께
|
||||
|
||||
def test_consult_reject_edit_and_resubmit(self):
|
||||
"""협의자 한 명이 반려 → 신청 반려, 고쳐서 다시 제출하면 협의가 처음부터, 협의자 없이 내면 바로 제출."""
|
||||
owner = f"kim-{uuid.uuid4().hex[:6]}@test.local"
|
||||
rid = self._consult_req(owner)["id"]
|
||||
self.st.decide_consult(request_id=rid, email="park@test.local", approve=True)
|
||||
with self.assertRaisesRegex(ValueError, "사유"):
|
||||
self.st.decide_consult(request_id=rid, email="choi@test.local", approve=False)
|
||||
got, event = self.st.decide_consult(request_id=rid, email="choi@test.local", approve=False, reason="일정 겹침")
|
||||
self.assertEqual((got["status"], got["reject_reason"], got["approver_email"], event), ("반려", "일정 겹침", "choi@test.local", "rejected"))
|
||||
again = self.st.submit(request_id=rid, owner=owner)
|
||||
self.assertEqual(again["status"], "협의중")
|
||||
self.assertEqual({c["state"] for c in self.st.list_consults(request_id=rid)}, {"대기"})
|
||||
self.st.decide_consult(request_id=rid, email="choi@test.local", approve=False, reason="x")
|
||||
payload = {"vacation_type": "연차", "start_date": "2026-11-05", "end_date": "2026-11-05", "reason": "y"}
|
||||
self.st.update_request(request_id=rid, owner=owner, payload=payload, consults=[])
|
||||
self.assertEqual(self.st.list_consults(request_id=rid), [])
|
||||
self.assertEqual(self.st.submit(request_id=rid, owner=owner)["status"], "제출")
|
||||
self.st.hard_delete(request_id=rid, user_email=owner, is_admin=False)
|
||||
|
||||
def test_consult_mail_log_events(self):
|
||||
"""003 이 메일 기록 CHECK 를 넓혔는지 — 협의 메일도 기록된다."""
|
||||
rid = uuid.uuid4().hex[:12]
|
||||
for ev in ("consult_request", "consulted"):
|
||||
self.st.add_mail_log(request_id=rid, event=ev, sender="a@test.local", via="smtp", recipients=["b@test.local"], subject="s", ok=True)
|
||||
self.assertEqual([m["event"] for m in self.st.list_mail_log(request_id=rid)], ["consult_request", "consulted"])
|
||||
|
||||
def test_submit_approve_mail_log_end_to_end(self):
|
||||
"""신청 → 제출 → 승인을 실제 DB 로, 메일은 가짜 SMTP — 기록이 상세 화면용 목록으로 나온다."""
|
||||
from app.modules.vacation import notify
|
||||
|
||||
Reference in New Issue
Block a user