import unittest
from datetime import date

import week

STAGE = {"cardio_min": 100, "strength_days": 2}

MONDAY = date(2026, 7, 27)
FRIDAY = date(2026, 7, 31)
SUNDAY = date(2026, 8, 2)


class SuggestionTest(unittest.TestCase):
    def test_everything_done_asks_for_nothing(self):
        text = week.suggestion(STAGE, cardio=100, strength=2, today=FRIDAY)

        self.assertIn("закрыта", text)

    def test_cardio_gap_is_split_across_remaining_days(self):
        # пятница: осталось 3 дня, не хватает 60 минут → 20 в день
        text = week.suggestion(STAGE, cardio=40, strength=2, today=FRIDAY)

        self.assertIn("20 мин", text)
        self.assertIn("Прогулка", text)

    def test_minutes_round_up_to_five(self):
        # осталось 3 дня, не хватает 52 минуты → 17.3 → 20
        text = week.suggestion(STAGE, cardio=48, strength=2, today=FRIDAY)

        self.assertIn("20 мин", text)

    def test_small_remainder_is_marked_as_closing_the_week(self):
        text = week.suggestion(STAGE, cardio=90, strength=2, today=SUNDAY)

        self.assertIn("закроет неделю", text)

    def test_strength_wins_when_week_is_running_out(self):
        text = week.suggestion(STAGE, cardio=0, strength=0, today=FRIDAY)

        self.assertIn("Силовая", text)
        self.assertIn("35–45", text)

    def test_early_in_week_cardio_comes_first(self):
        text = week.suggestion(STAGE, cardio=0, strength=0, today=MONDAY)

        self.assertIn("Прогулка", text)

    def test_walk_never_shorter_than_fifteen_minutes(self):
        # понедельник, не хватает 7 минут на 7 дней → 1 в день, но это не прогулка
        text = week.suggestion(STAGE, cardio=93, strength=2, today=MONDAY)

        self.assertIn("15 мин", text)


if __name__ == "__main__":
    unittest.main()
