def now(): global g_courses found = search.active_now(g_courses) if found: click.echo('Opening notes for ' + str(found)) else: click.echo('No course happening now.')
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)