def test_get_filtered_courses_by_load(courses, all_courses): # testing for the average load <= 2 which should include Course1 and Course3 db_courses = Course.get_filtered_courses_by_load(2, all_courses) assert db_courses.filter(pk=courses[0].course_id) and db_courses.filter( pk=courses[2].course_id) assert not db_courses.filter(pk=courses[1].course_id)
def filters_to_results(all_courses): return { 'mand': Course.get_mandatory_courses(all_courses), 'elect': Course.get_elective_courses(all_courses), 'load_below': Course.get_filtered_courses_by_load(3.5, all_courses), 'rate_over': Course.get_filtered_courses_by_rating(3.5, all_courses), 'has_preqs': Course.get_courses_with_preqs(all_courses), 'no_preqs': Course.get_courses_without_preqs(all_courses), 'rater_num': Course.get_courses_with_ratings(all_courses, 5) }
def test_load_and_elective_and_mandatory_filters(courses, all_courses): # expect to return only Course3 db_courses = Course.get_filtered_courses_by_load(2, all_courses) db_courses_elect = Course.get_elective_courses(db_courses) db_courses_mand = Course.get_mandatory_courses(db_courses) # checking elective is only Course3 assert db_courses_elect.filter(pk=courses[2].course_id) assert not db_courses_elect.filter( pk=courses[1].course_id) and not db_courses_elect.filter( pk=courses[0].course_id) # checking mandatory is only Course1 assert db_courses_mand.filter(pk=courses[0].course_id) assert not db_courses_mand.filter( pk=courses[1].course_id) and not db_courses_mand.filter( pk=courses[2].course_id)
def test_get_rating_and_load_filters(courses, all_courses): # expect only Course1 db_courses = Course.get_filtered_courses_by_load(2, all_courses) db_courses = Course.get_filtered_courses_by_rating(3, db_courses) assert db_courses.filter(pk=courses[0].course_id)