24 lines
1014 B
Python
24 lines
1014 B
Python
import datetime
|
|
|
|
from chrono.utils.date import get_weekday_index
|
|
|
|
|
|
def test_get_weekday_index():
|
|
for date in (
|
|
datetime.date(2021, 11, 1), # month starting a Monday
|
|
datetime.date(2021, 12, 1), # month starting a Wednesday
|
|
datetime.date(2021, 5, 1), # month starting a Sunday
|
|
):
|
|
assert get_weekday_index(date) == 1
|
|
assert get_weekday_index(date.replace(day=3)) == 1
|
|
assert get_weekday_index(date.replace(day=7)) == 1
|
|
assert get_weekday_index(date.replace(day=8)) == 2
|
|
assert get_weekday_index(date.replace(day=10)) == 2
|
|
assert get_weekday_index(date.replace(day=14)) == 2
|
|
assert get_weekday_index(date.replace(day=15)) == 3
|
|
assert get_weekday_index(date.replace(day=21)) == 3
|
|
assert get_weekday_index(date.replace(day=22)) == 4
|
|
assert get_weekday_index(date.replace(day=28)) == 4
|
|
assert get_weekday_index(date.replace(day=29)) == 5
|
|
assert get_weekday_index(date.replace(day=30)) == 5
|