from __future__ import annotations

from datetime import UTC, datetime
from unittest import TestCase

from app.routers.restaurants import _local_day_window


class TestRestaurantStatsDayWindow(TestCase):
    def test_local_day_window_uses_restaurant_timezone_boundaries(self) -> None:
        now_utc = datetime(2026, 2, 22, 23, 30, tzinfo=UTC)

        today_start, today_end, _week_start = _local_day_window(
            "Europe/Brussels",
            now_utc=now_utc,
        )

        # At UTC 23:30, Brussels (UTC+1 winter) reads Feb 23 00:30 — local
        # day is Feb 23. Boundaries are naive-UTC (storage convention) so
        # local midnight Feb 23 maps to 23:00 UTC Feb 22, and local
        # midnight Feb 24 maps to 23:00 UTC Feb 23.
        self.assertEqual(today_start, datetime(2026, 2, 22, 23, 0))
        self.assertEqual(today_end, datetime(2026, 2, 23, 23, 0))
