Esempio n. 1
0
def test_multiple_courses(db, course_quirk, course_strange, course_charm):
    courses = Course.find_by_org(db, 1)
    assert len(courses) == 2
    courses = Course.find_by_org(db, 2)
    assert len(courses) == 1
    courses = Course.find_by_org(db, 3)
    assert len(courses) == 0
Esempio n. 2
0
def test_course_params(db, course_strange):
    # confirm named arguments work even when reversed
    found_by_code = Course.find_by_code(org_id=course_strange.org_id, db=db, code=course_strange.course_code)
    assert found_by_code.course_code == course_strange.course_code

    # confirm that putting the positional values the wrong way round will [probably] fail
    with pytest.raises(ValueError):
        found_by_code = Course.find_by_code(db, course_strange.org_id, course_strange.course_code)

    # test for unbexpected param
    with pytest.raises(TypeError):
        Course.find_by_pk(primary_key=course_strange.id, db=db)
    with pytest.raises(TypeError):
        found_by_code = Course.find_by_code(course_code=course_strange.course_code, org_id=course_strange.org_id, db=db)
    with pytest.raises(TypeError):
        found_by_code = Course.find_by_code(code=course_strange.course_code, id=course_strange.org_id, db=db)
    with pytest.raises(TypeError):
        Course.find_by_org(id=course_strange.org_id, db=db)