"""current_mode — 시간대 + 휴장일 판정 (순수 함수)."""
import datetime as dt
from zoneinfo import ZoneInfo

from mode import current_mode

KST = ZoneInfo("Asia/Seoul")
HOLIDAYS = {"2026-05-25"}  # 가상 휴장일 (월요일)


def _kst(y, m, d, hh, mm):
    return dt.datetime(y, m, d, hh, mm, tzinfo=KST)


def test_weekday_trading_hours_is_trading():
    # 2026-05-22 금요일 10:00 — 트레이딩 시간대
    assert current_mode(_kst(2026, 5, 22, 10, 0), HOLIDAYS) == "trading"


def test_weekday_before_open_is_free():
    # 평일 06:00 — 장 전
    assert current_mode(_kst(2026, 5, 22, 6, 0), HOLIDAYS) == "free"


def test_weekday_after_close_is_free():
    # 평일 17:00 — 장 마감 후
    assert current_mode(_kst(2026, 5, 22, 17, 0), HOLIDAYS) == "free"


def test_weekend_is_free():
    # 2026-05-23 토요일 10:00
    assert current_mode(_kst(2026, 5, 23, 10, 0), HOLIDAYS) == "free"


def test_holiday_weekday_is_free():
    # 2026-05-25 월요일이지만 휴장일 → 트레이딩 시간대라도 free
    assert current_mode(_kst(2026, 5, 25, 10, 0), HOLIDAYS) == "free"


def test_trading_boundary_inclusive_start_exclusive_end():
    # 07:00 정각 = 트레이딩 시작, 16:30 정각 = 마감 (16:30은 free)
    assert current_mode(_kst(2026, 5, 22, 7, 0), HOLIDAYS) == "trading"
    assert current_mode(_kst(2026, 5, 22, 16, 29), HOLIDAYS) == "trading"
    assert current_mode(_kst(2026, 5, 22, 16, 30), HOLIDAYS) == "free"
