def test_meetingtime_conflicts(): beg1 = datetime.time(10, 0, 0) end1 = datetime.time(12, 0, 0) rng1 = TimeRange(beg1, end1) mtime1 = MeetingTime(rng1, [0, 2, 4]) mtime2 = MeetingTime(rng1, [1, 3]) # Same time, different weekdays assert not mtime1.conflicts(mtime2) beg2 = datetime.time(12, 0, 0) end2 = datetime.time(14, 0, 0) rng2 = TimeRange(beg2, end2) mtime2 = MeetingTime(rng2, [0, 2, 4]) # Same weekdays, different time assert not mtime1.conflicts(mtime2) beg3 = datetime.time(10, 0, 0) end3 = datetime.time(14, 0, 0) rng3 = TimeRange(beg3, end3) mtime3 = MeetingTime(rng3, [0, 2, 4]) # Same weekdays, overlapping time assert mtime1.conflicts(mtime3)
def test_meetingtime_during(): timerng = TimeRange(datetime.time(0, 0, 0), datetime.time(9, 0, 0)) mt = MeetingTime(timerng, [0, 1, 2, 3, 4, 5, 6]) dt = datetime.datetime(2015, 1, 1, 8, 30, 0) assert (mt.during(dt) is True) dt = datetime.datetime(2015, 1, 1, 9, 30, 0) assert (mt.during(dt) is False)
def test_now(): courses = [] timerng = TimeRange(datetime.time(0, 0, 0), datetime.time(23, 59, 59)) course1 = Course('course1', 'C1', 1) # This one never meets! mtime = MeetingTime(timerng, [0]) mtime.weekdays = [] course1.add_time(mtime) courses.append(course1) assert search.active_now(courses) is None course2 = Course('course2', 'C2', 1) # This one meets literally all the time mtime = MeetingTime(timerng, [0, 1, 2, 3, 4, 5, 6]) course2.add_time(mtime) courses.append(course2) # course2 should fit our criteria assert course2 == search.active_now(courses)