cd3577b299
- Weeks stay inside the month: week 1 starts on the 1st (through the next Sunday if the 1st is a weekend); a trailing Mon/Tue joins the last week. "Last week" is the previous period. - Prev-week review columns: 전주 업무 | 결과(text, new result_note) | 전주 목표 | 결과(amount). - Header now shows month target, cumulative weekly target, month-to-date sales and gap (amount + %), with decisions/notes beside it; the area stays fixed while scrolling. - Goals board: the monthly sales target is entered per week; the sum becomes the month target. - Migration 020: result_note, goal_week_targets, drop Monday-only check, move absorbed Monday meetings to the new week start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
3.3 KiB
Python
62 lines
3.3 KiB
Python
"""주간 회의록 주차 규칙(2026-10-07) — store.month_weeks·week_period·prev_week_period·validate_period_start. DB 없이 실행."""
|
|
import unittest
|
|
from datetime import date, timedelta
|
|
|
|
from app.modules.project import store
|
|
|
|
|
|
def fmt(periods):
|
|
return [(a.isoformat(), b.isoformat()) for a, b in periods]
|
|
|
|
|
|
class MonthWeeksTest(unittest.TestCase):
|
|
def test_first_on_weekday_starts_week_one(self):
|
|
# 2026-10-01 목 → 1주차 10/1~10/4, 말일 10/31 토 → 마지막 주차 10/26~10/31
|
|
self.assertEqual(fmt(store.month_weeks(2026, 10)), [
|
|
("2026-10-01", "2026-10-04"), ("2026-10-05", "2026-10-11"), ("2026-10-12", "2026-10-18"),
|
|
("2026-10-19", "2026-10-25"), ("2026-10-26", "2026-10-31")])
|
|
|
|
def test_first_on_weekend_joins_next_week(self):
|
|
# 2026-08-01 토 → 1주차 8/1~8/9, 2026-11-01 일 → 1주차 11/1~11/8
|
|
self.assertEqual(store.month_weeks(2026, 8)[0], (date(2026, 8, 1), date(2026, 8, 9)))
|
|
self.assertEqual(store.month_weeks(2026, 11)[0], (date(2026, 11, 1), date(2026, 11, 8)))
|
|
|
|
def test_last_day_monday_or_tuesday_joins_previous_week(self):
|
|
# 2026-08-31 월 → 마지막 주차 8/24~8/31, 2026-03-31 화 → 3/23~3/31
|
|
self.assertEqual(store.month_weeks(2026, 8)[-1], (date(2026, 8, 24), date(2026, 8, 31)))
|
|
self.assertEqual(store.month_weeks(2026, 3)[-1], (date(2026, 3, 23), date(2026, 3, 31)))
|
|
# 말일 수(2026-09-30) → 9/28~9/30 그대로 한 주차
|
|
self.assertEqual(store.month_weeks(2026, 9)[-1], (date(2026, 9, 28), date(2026, 9, 30)))
|
|
|
|
def test_periods_cover_month_without_gaps(self):
|
|
for y in (2025, 2026, 2027, 2028):
|
|
for m in range(1, 13):
|
|
ws = store.month_weeks(y, m)
|
|
self.assertEqual(ws[0][0], date(y, m, 1))
|
|
self.assertEqual(ws[-1][1], store.month_last_day(y, m))
|
|
for (a, b), (c, _) in zip(ws, ws[1:]):
|
|
self.assertEqual(c, b + timedelta(days=1))
|
|
self.assertEqual(c.weekday(), 0) # 2주차부터는 월요일 시작
|
|
self.assertEqual(b.weekday(), 6)
|
|
|
|
def test_period_lookup_and_previous(self):
|
|
self.assertEqual(store.week_period(date(2026, 10, 3)), (date(2026, 10, 1), date(2026, 10, 4)))
|
|
# 10월 1주차의 지난주 = 9월 마지막 주차(9/28~9/30)
|
|
self.assertEqual(store.prev_week_period(date(2026, 10, 1)), (date(2026, 9, 28), date(2026, 9, 30)))
|
|
self.assertEqual(store.prev_week_period(date(2026, 10, 12)), (date(2026, 10, 5), date(2026, 10, 11)))
|
|
self.assertEqual(store.week_number(date(2026, 10, 12)), 3)
|
|
|
|
def test_validate_period_start(self):
|
|
self.assertEqual(store.validate_period_start("2026-10-01"), date(2026, 10, 1))
|
|
self.assertEqual(store.validate_period_start("2026-10-05"), date(2026, 10, 5))
|
|
with self.assertRaises(ValueError):
|
|
store.validate_period_start("2026-10-06")
|
|
with self.assertRaises(ValueError):
|
|
store.validate_period_start("2026-08-03") # 8/1(토) 1주차에 흡수된 월요일
|
|
# 날짜만 확인(기존 회의록 조회용) — 월요일이 아니어도 된다
|
|
self.assertEqual(store.validate_week_start("2026-10-01"), date(2026, 10, 1))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|