Esempio n. 1
0
def test_load_predicate_constant_expands_to_several_nested():
    ppm = tuple(['saxophone', 'jazz saxophone'])
    constants = Constants(primary_performing_medium=ppm)
    ctx = RequirementContext()
    input_data = {'name': {'$in': ['piano', '$primary-performing-medium']}}

    c = load_predicate(input_data, c=constants, mode=DataType.Course, ctx=ctx)
    assert isinstance(c, Predicate)

    assert list(c.expected) == ['piano', 'saxophone', 'jazz saxophone']
def test_su_during_covid_different_clause() -> None:
    ctx = RequirementContext()
    clause = load_predicate({"grade": {"$gte": "B"}}, c=c, mode=mode, ctx=ctx)
    assert isinstance(clause, Predicate)

    course = course_from_str(
        'CSCI 251',
        grade_code='S',
        grade_option=GradeOption.SU,
        su_grade_code='C',
        year=2019,
        term='3',
    )
    assert apply_predicate__grade(course, clause) is False
def test_graded_during_covid() -> None:
    ctx = RequirementContext()
    clause = load_predicate({"grade": {
        "$gte": "C",
        "$during_covid": "C-"
    }},
                            c=c,
                            mode=mode,
                            ctx=ctx)
    assert isinstance(clause, Predicate)

    course = course_from_str(
        'CSCI 251',
        grade_code='C',
        grade_option=GradeOption.Grade,
        year=2019,
        term='3',
    )
    assert apply_predicate__grade(course, clause) is True
Esempio n. 4
0
def test_clauses_in(caplog):
    caplog.set_level(logging.DEBUG)

    c = Constants(matriculation_year=2000)
    ctx = RequirementContext()
    course = course_from_str(s="CSCI 296")

    values = tuple([296, 298, 396, 398])
    x = load_predicate({"number": {
        "$in": values
    }},
                       c=c,
                       ctx=ctx,
                       mode=DataType.Course)
    expected_single = Predicate.from_args(key="number",
                                          expected=values,
                                          original=values,
                                          operator=Operator.In)
    assert x == expected_single

    assert x.apply(course) is True
Esempio n. 5
0
def test_clauses(caplog):
    caplog.set_level(logging.DEBUG)

    c = Constants(matriculation_year=2000)
    ctx = RequirementContext()

    x = load_predicate({"attributes": {
        "$eq": "csci_elective"
    }},
                       c=c,
                       ctx=ctx,
                       mode=DataType.Course)
    expected_single = Predicate.from_args(key="attributes",
                                          expected="csci_elective",
                                          original="csci_elective",
                                          operator=Operator.EqualTo)
    assert x == expected_single

    crs = course_from_str(s="CSCI 121", attributes=["csci_elective"])

    assert x.apply(crs) is True