def test_get_mandatory_courses(courses, all_courses):
    # should get back only Course1 from courses
    db_courses = Course.get_mandatory_courses(all_courses)

    assert db_courses.filter(pk=courses[0].course_id)
    assert not db_courses.filter(
        pk=courses[1].course_id) and not db_courses.filter(
            pk=courses[2].course_id)
def test_rating_and_mandatory_filters(courses, all_courses):
    # expect to return only Course1
    db_courses = Course.get_filtered_courses_by_rating(2.5, all_courses)
    db_courses = Course.get_mandatory_courses(db_courses)

    assert db_courses.filter(pk=courses[0].course_id)
    assert not db_courses.filter(
        pk=courses[1].course_id) and not db_courses.filter(
            pk=courses[2].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_elective_and_mandatory_filters(all_courses):
    # expect to return only Course1
    db_courses = Course.get_elective_courses(all_courses)
    db_courses = Course.get_mandatory_courses(db_courses)

    assert not db_courses