コード例 #1
0
def test_check_reqs():

    subj1001 = course.Course('SUBJ', '1001', 'Subject1', 6, [t1, t2], faculty)
    subj1002 = course.Course('SUBJ', '1002', 'Subject2', 6, [t1, t2], faculty)
    subj1003 = course.Course('SUBJ', '1003', 'Subject3', 6, [t1, t2], faculty)
    subj1004 = course.Course('SUBJ', '1004', 'Subject4', 6, [t1, t2], faculty)
    subj1005 = course.Course('SUBJ', '1005', 'Subject5', 6, [t1, t2], faculty)
    subj1006 = course.Course('SUBJ', '1006', 'Subject6', 6, [t1, t2], faculty)

    req1001 = subjectReq.SubjectReq(subj1001, 75)
    req1002 = subjectReq.SubjectReq(subj1002)
    req1003 = subjectReq.SubjectReq(subj1003)
    req1004 = subjectReq.SubjectReq(subj1004)

    req1002_and = andReq.AndReq([req1002, req1003])
    prereq_or = orReq.OrReq([req1001, req1002_and])

    ex = ['SUBJ1005', 'SUBJ1006']
    subj1007 = course.Course('SUBJ',
                             '1007',
                             'Subject7',
                             6, [t1, t2],
                             faculty,
                             prereqs=prereq_or,
                             coreqs=req1004,
                             exclusions=ex)

    enrol1005 = courseEnrollment.CourseEnrollment(subj1005, t1)

    prog = program.Program(degree1, [enrol1005], [])

    errors = subj1007.check_reqs(prog, t2)

    assert len(errors) == 3
    assert errors[0]['filter_type'] == 'Prerequisite'
    assert errors[0]['info'] == [
        '(A mark of 75 in SUBJ1001 OR (SUBJ1002 AND SUBJ1003))'
    ]
    assert errors[1]['filter_type'] == 'Corequisite'
    assert errors[1]['info'] == ['SUBJ1004']
    assert errors[2]['filter_type'] == 'Exclusion'
    assert errors[2]['info'] == ['SUBJ1005']

    prog.add_course(subj1001, t1)
    errors = subj1007.check_reqs(prog, t2)
    assert len(errors) == 2
    assert errors[0]['filter_type'] == 'Corequisite'
    assert errors[0]['info'] == ['SUBJ1004']
    assert errors[1]['filter_type'] == 'Exclusion'
    assert errors[1]['info'] == ['SUBJ1005']

    assert subj1007.check_warnings(prog, t2) == ['A mark of 75 in SUBJ1001']
コード例 #2
0
def test_check():
    # Make some courses
    # subj1001
    subj1001 = course.Course('SUBJ', '1001', 'Subject1', 6,
                             [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty)

    # subj1002, prereq subj1001
    prereq1001 = subjectReq.SubjectReq(subj1001)
    subj1002 = course.Course('SUBJ', '1002', 'Subject2', 6,
                             [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty,
                             prereq1001)

    # subj1003, prereq subj1001 and 1002
    subj1003 = course.Course('SUBJ', '1003', 'Subject3', 6,
                             [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty,
                             prereq1001)

    uni.reset_courses([subj1001, subj1002, subj1003])

    filter1001 = specificCourseFilter.SpecificCourseFilter(subj1001)
    filter1002 = specificCourseFilter.SpecificCourseFilter(subj1002)
    filter1003 = specificCourseFilter.SpecificCourseFilter(subj1003)
    req1001 = minDegreeReq.MinDegreeReq(filter1001, 6)
    req1002 = minDegreeReq.MinDegreeReq(filter1002, 6)
    req1003 = minDegreeReq.MinDegreeReq(filter1003, 6)
    degree1 = degree.Degree(1, 'Bachelor of Testing', 2019, 2, faculty,
                            [req1001, req1002, req1003], 'BAT1')

    enrol1001 = courseEnrollment.CourseEnrollment(subj1001, t1)
    enrol1002 = courseEnrollment.CourseEnrollment(subj1002, t2)
    enrol1003 = courseEnrollment.CourseEnrollment(subj1003, t7)

    prog = program.Program(degree1, [enrol1001, enrol1002, enrol1003], [])

    req = yearReq.YearReq(2)
    assert len(req.check(prog, t1)) == 1
    assert len(req.check(prog, t2)) == 1
    assert len(req.check(prog, t3)) == 1
    assert len(req.check(prog, t4)) == 0
    assert len(req.check(prog, t5)) == 0
    assert len(req.check(prog, t6)) == 0
    assert len(req.check(prog, t7)) == 0
    assert len(req.check(prog, t8)) == 0
    assert len(req.check(prog, t9)) == 0
    assert req.check(prog, t3)[0] == 'Year 2 in your degree'

    req = yearReq.YearReq(-1)
    assert len(req.check(prog, t1)) == 1
    assert len(req.check(prog, t2)) == 1
    assert len(req.check(prog, t3)) == 1
    assert len(req.check(prog, t4)) == 1
    assert len(req.check(prog, t5)) == 1
    assert len(req.check(prog, t6)) == 1
    assert len(req.check(prog, t7)) == 0
    assert len(req.check(prog, t8)) == 0
    assert len(req.check(prog, t9)) == 0
    assert req.check(prog, t3)[0] == 'Final year in your degree'
コード例 #3
0
def test_check():
    # subj1001
    subj1001 = course.Course('SUBJ', '1001', 'Subject1', 6, [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty)

    # subj1003, prereq subj1001 and final year
    prereq_final = yearReq.YearReq(year=-1)
    prereq1001 = subjectReq.SubjectReq(subj1001)

    req1001_and_final = andReq.AndReq([prereq1001, prereq_final])
    subj1003 = course.Course('SUBJ', '1003', 'Subject3', 6, [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty, req1001_and_final)

    subj1004 = course.Course('SUBJ', '1004', 'Subject4', 6, [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty)

    filter1001 = specificCourseFilter.SpecificCourseFilter(subj1001)
    filter1003 = specificCourseFilter.SpecificCourseFilter(subj1003)
    filter1004 = specificCourseFilter.SpecificCourseFilter(subj1004)

    # subj1002, prereq 6 uoc from subj1003, 1004
    or_filter = orFilter.OrFilter([filter1003, filter1004])
    prereq_6uoc = uocReq.UOCReq(6, or_filter)
    assert prereq_6uoc.filter is not None
    subj1002 = course.Course('SUBJ', '1002', 'Subject2', 6, [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty, prereq_6uoc)

    filter1002 = specificCourseFilter.SpecificCourseFilter(subj1002)

    uni.reset_courses([subj1001, subj1002, subj1003, subj1004])

    req1001 = minDegreeReq.MinDegreeReq(filter1001, 6)
    req1002 = minDegreeReq.MinDegreeReq(filter1002, 6)
    req1003 = minDegreeReq.MinDegreeReq(filter1003, 6)

    degree1 = degree.Degree(1, 'Bachelor of Testing', 2019, 3, faculty, [req1001, req1002, req1003], 'BAT1')

    gen = generator.Generator(degree1, uni)
    prog = gen.generate()

    assert len(prereq_6uoc.check(prog, t9)) == 0
    assert len(prereq_6uoc.check(prog, t8)) == 0
    assert len(prereq_6uoc.check(prog, t7)) == 1
    assert prereq_6uoc.check(prog, t7)[0] == '6 UoC fulfilling [(SUBJ1003) OR (SUBJ1004)]'

    prereq_12uoc = uocReq.UOCReq(12)
    assert len(prereq_12uoc.check(prog, t9)) == 0
    assert len(prereq_12uoc.check(prog, t8)) == 0
    assert len(prereq_12uoc.check(prog, t7)) == 1
    assert prereq_12uoc.check(prog, t7)[0] == '12 UoC'
コード例 #4
0
def test_one():
    # Make some courses
    # subj1001
    subj1001 = course.Course('SUBJ', '1001', 'Subject1', 6,
                             [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty)

    # subj1002, prereq subj1001
    prereq1001 = subjectReq.SubjectReq(subj1001)
    prereq_year2 = yearReq.YearReq(year=2)
    assert prereq_year2.year == 2
    req1001_and_year2 = andReq.AndReq([prereq1001, prereq_year2])
    subj1002 = course.Course('SUBJ', '1002', 'Subject2', 6,
                             [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty,
                             req1001_and_year2)

    # subj1003, prereq subj1001 and 1002
    prereq_final = yearReq.YearReq(year=-1)
    assert prereq_final.year == -1
    req1001_and_final = andReq.AndReq([prereq1001, prereq_final])
    subj1003 = course.Course('SUBJ', '1003', 'Subject3', 6,
                             [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty,
                             req1001_and_final)

    uni.reset_courses([subj1001, subj1002, subj1003])

    filter1001 = specificCourseFilter.SpecificCourseFilter(subj1001)
    filter1002 = specificCourseFilter.SpecificCourseFilter(subj1002)
    filter1003 = specificCourseFilter.SpecificCourseFilter(subj1003)
    req1001 = minDegreeReq.MinDegreeReq(filter1001, 6)
    req1002 = minDegreeReq.MinDegreeReq(filter1002, 6)
    req1003 = minDegreeReq.MinDegreeReq(filter1003, 6)

    degree1 = degree.Degree(1, 'Bachelor of Testing', 2019, 3, faculty,
                            [req1001, req1002, req1003], 'BAT1')

    gen = generator.Generator(degree1, uni)
    prog = gen.generate()

    assert prog.enrolled(subj1001)
    assert prog.enrolled(subj1002)
    assert prog.enrolled(subj1003)

    assert prog.term_taken(subj1001) == t1
    assert prog.term_taken(subj1002) == t4
    assert prog.term_taken(subj1003) == t7
コード例 #5
0
def test_with_filter():
    # subj1001
    subj1001 = course.Course('SUBJ', '1001', 'Subject1', 6, [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty)

    # subj1003, prereq subj1001 and final year
    prereq_final = yearReq.YearReq(year=-1)
    prereq1001 = subjectReq.SubjectReq(subj1001)

    req1001_and_final = andReq.AndReq([prereq1001, prereq_final])
    subj1003 = course.Course('SUBJ', '1003', 'Subject3', 6, [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty, req1001_and_final)

    subj1004 = course.Course('SUBJ', '1004', 'Subject4', 6, [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty)

    filter1001 = specificCourseFilter.SpecificCourseFilter(subj1001)
    filter1003 = specificCourseFilter.SpecificCourseFilter(subj1003)
    filter1004 = specificCourseFilter.SpecificCourseFilter(subj1004)

    # subj1002, prereq 6 uoc from subj1003, 1004
    or_filter = orFilter.OrFilter([filter1003, filter1004])
    prereq_6uoc = uocReq.UOCReq(6, or_filter)
    assert prereq_6uoc.filter is not None
    subj1002 = course.Course('SUBJ', '1002', 'Subject2', 6, [t1, t2, t3, t4, t5, t6, t7, t8, t9], faculty, prereq_6uoc)

    filter1002 = specificCourseFilter.SpecificCourseFilter(subj1002)

    uni.reset_courses([subj1001, subj1002, subj1003, subj1004])

    req1001 = minDegreeReq.MinDegreeReq(filter1001, 6)
    req1002 = minDegreeReq.MinDegreeReq(filter1002, 6)
    req1003 = minDegreeReq.MinDegreeReq(filter1003, 6)

    degree1 = degree.Degree(1, 'Bachelor of Testing', 2019, 3, faculty, [req1001, req1002, req1003], 'BAT1')

    gen = generator.Generator(degree1, uni)
    prog = gen.generate()

    assert prog.enrolled(subj1001)
    assert prog.enrolled(subj1002)
    assert prog.enrolled(subj1003)

    assert prog.term_taken(subj1001) == t1
    assert prog.term_taken(subj1002) == t8
    assert prog.term_taken(subj1003) == t7
コード例 #6
0
from classes import subjectReq
from classes import course
from classes import courseEnrollment

faculty = 'SubjFaculty'
t1 = term.Term(2019, 1)
t2 = term.Term(2019, 2)
degree1 = degree.Degree('1', 'Bachelor of Testing', 2019, 3, faculty, [],
                        'BAT1')
subj1001 = course.Course('SUBJ', '1001', 'Subject1', 6, [t1], faculty)
subj1002 = course.Course('SUBJ', '1002', 'Subject1', 6, [t1], faculty)
enrol1001 = courseEnrollment.CourseEnrollment(subj1001, t1)
enrol1002 = courseEnrollment.CourseEnrollment(subj1002, t1)
prog1 = program.Program(degree1, [enrol1001], [])
prog2 = program.Program(degree1, [enrol1002], [])
req = subjectReq.SubjectReq(subj1001)


def test_fulfilled():
    assert req.fulfilled(prog1, t2)
    assert req.fulfilled(prog1, t1, coreq=True)


def test_not_fulfilled():
    assert not req.fulfilled(prog2, t2)


def test_check():
    assert len(req.check(prog1, t2)) == 0
    assert len(req.check(prog1, t1)) == 1
    assert len(req.check(prog2, t2)) == 1
コード例 #7
0
t1 = term.Term(2019, 1)
t2 = term.Term(2019, 2)
t3 = term.Term(2019, 3)
t4 = term.Term(2020, 1)
t5 = term.Term(2020, 2)
t6 = term.Term(2020, 3)

faculty = 'SubjFaculty'

# Make some courses
# subj1001
subj1001 = course.Course('SUBJ', '1001', 'Subject1', 6,
                         [t1, t2, t3, t4, t5, t6], faculty)

# subj1002, prereq subj1001
prereq1001 = subjectReq.SubjectReq(subj1001)
subj1002 = course.Course('SUBJ', '1002', 'Subject2', 6, [t1, t3, t4, t6],
                         faculty, prereq1001)

# subj1003, prereq subj1001 and 1002
prereq1002 = subjectReq.SubjectReq(subj1002)
req1001_and_1002 = andReq.AndReq([prereq1001, prereq1002])
subj1003 = course.Course('SUBJ', '1003', 'Subject3', 6, [t1, t4], faculty,
                         req1001_and_1002)

# TODO subj1004 was not defined! making a dummy one
subj1004 = course.Course('SUBJ', '1004', 'Subject4', 6, [t1, t2], faculty,
                         req1001_and_1002)


def setup_function(function):