import unittest
from datetime import date

from algo.util import get_week_start_day


class Test_get_week_start_day(unittest.TestCase):  # pylint: disable=invalid-name

    def test_week_start_day(self):

        expected_week_start = '2022-11-06'  # Sunday

        start_week_day = get_week_start_day(date.fromisoformat('2022-11-12'))  # Saturday
        self.assertEqual(start_week_day.isoformat(), expected_week_start)

        start_week_day = get_week_start_day(date.fromisoformat('2022-11-11'))  # Friday
        self.assertEqual(start_week_day.isoformat(), expected_week_start)

        start_week_day = get_week_start_day(date.fromisoformat('2022-11-10'))  # Thursday
        self.assertEqual(start_week_day.isoformat(), expected_week_start)

        start_week_day = get_week_start_day(date.fromisoformat('2022-11-09'))  # Wednesday
        self.assertEqual(start_week_day.isoformat(), expected_week_start)

        start_week_day = get_week_start_day(date.fromisoformat('2022-11-07'))  # Monday
        self.assertEqual(start_week_day.isoformat(), expected_week_start)

        start_week_day = get_week_start_day(date.fromisoformat(expected_week_start))  # Sunday iteself
        self.assertEqual(start_week_day.isoformat(), expected_week_start)
