|
| 1 | +from datetime import date, datetime |
| 2 | + |
| 3 | +from data.semesters import current_semester, current_semester_start, step_semesters |
| 4 | + |
| 5 | + |
| 6 | +def test_semesters(): |
| 7 | + start1 = current_semester_start(date(year=2022, month=11, day=1)) |
| 8 | + start2 = current_semester_start(date(year=1022, month=7, day=30)) |
| 9 | + start3 = current_semester_start(date(year=2322, month=1, day=12)) |
| 10 | + |
| 11 | + assert start1.month == 9 |
| 12 | + assert start2.month == 5 |
| 13 | + assert start3.month == 1 |
| 14 | + |
| 15 | + assert step_semesters(start1, -3).month == 9 |
| 16 | + assert step_semesters(start1, -3).year == start1.year - 1 |
| 17 | + |
| 18 | + assert step_semesters(start1, -2).month == 1 |
| 19 | + assert step_semesters(start1, -2).year == start1.year |
| 20 | + |
| 21 | + assert step_semesters(start1, -1).month == 5 |
| 22 | + assert step_semesters(start1, -1).year == start1.year |
| 23 | + |
| 24 | + assert step_semesters(start1, 0).month == 9 |
| 25 | + assert step_semesters(start1, 0).year == start1.year |
| 26 | + |
| 27 | + assert step_semesters(start1, 1).month == 1 |
| 28 | + assert step_semesters(start1, 1).year == start1.year + 1 |
| 29 | + |
| 30 | + assert step_semesters(start1, 2).month == 5 |
| 31 | + assert step_semesters(start1, 2).year == start1.year + 1 |
| 32 | + |
| 33 | + assert step_semesters(start1, 3).month == 9 |
| 34 | + assert step_semesters(start1, 3).year == start1.year + 1 |
| 35 | + |
| 36 | + assert step_semesters(start3, -4).month == 9 |
| 37 | + assert step_semesters(start3, -4).year == start3.year - 2 |
| 38 | + |
| 39 | + assert str(current_semester(start1)) == "fall" |
0 commit comments