def test_ranges_eq(caplog): caplog.set_level(logging.DEBUG) c = Constants(matriculation_year=2000) ctx = RequirementContext() x = Assertion.load({"assert": { "count(courses)": { "$eq": 1 } }}, c=c, ctx=ctx, data_type=DataType.Course, path=['$']) result = x.input_size_range(maximum=5) assert list(result) == [1]
def test_resolution(caplog): caplog.set_level(logging.DEBUG) c = Constants(matriculation_year=2000) ctx = RequirementContext() x = Assertion.load({"assert": { "count(items)": { "$eq": 1 } }}, c=c, ctx=ctx, data_type=DataType.Recital, path=['$']) result = x.audit_and_resolve(tuple([IntThing()]), ctx=ctx) assert result.ok() is True result = x.audit_and_resolve(tuple([IntThing(), IntThing()]), ctx=ctx) assert result.ok() is False
def test_ranges_eq_2(caplog): """ensure that a solution with fewer matching courses than requested is still proposed""" caplog.set_level(logging.DEBUG) c = Constants(matriculation_year=2000) ctx = RequirementContext() result = Assertion.load({ "assert": { "count(courses)": { "$eq": 3 } } }, c=c, ctx=ctx, data_type=DataType.Course, path=['$']).input_size_range(maximum=2) assert list(result) == [2] result = Assertion.load({ "assert": { "count(courses)": { "$neq": 3 } } }, c=c, ctx=ctx, data_type=DataType.Course, path=['$']).input_size_range(maximum=2) assert list(result) == [0, 1, 2] result = Assertion.load({ "assert": { "count(courses)": { "$lt": 3 } } }, c=c, ctx=ctx, data_type=DataType.Course, path=['$']).input_size_range(maximum=2) assert list(result) == [0, 1, 2] result = Assertion.load({ "assert": { "count(courses)": { "$lte": 3 } } }, c=c, ctx=ctx, data_type=DataType.Course, path=['$']).input_size_range(maximum=2) assert list(result) == [0, 1, 2, 3] result = Assertion.load({ "assert": { "count(courses)": { "$gt": 3 } } }, c=c, ctx=ctx, data_type=DataType.Course, path=['$']).input_size_range(maximum=2) assert list(result) == [2] result = Assertion.load({ "assert": { "count(courses)": { "$gte": 3 } } }, c=c, ctx=ctx, data_type=DataType.Course, path=['$']).input_size_range(maximum=2) assert list(result) == [2]