def test_kattis_result(): result = aaps.KattisResult() result.add_AC('helloworld', '01-01-2017 08:00') result.add_WA('helloworld', '01-01-2017 07:00') assert len(result.AC) == 1 assert len(result.WA) == 1 assert result.AC[0].id == 'helloworld' assert result.WA[0].id == 'helloworld'
def test_after_deadline(): ruleset = get_ruleset_from_file('test_after_deadline.json') assert len(ruleset.rules) == 1 kattis = aaps.KattisResult() kattis.add_AC('testproblem', '01-01-2017 08:00') result = resolve_for_result(kattis, ruleset) assert len(result.goals) == 1 assert result.goals[0].points == 1 # Halved from 2
def handle_student(student): kattis = aaps.KattisResult() if is_student: kattis.resolve_sessions_with_input() add_sub = lambda sub: kattis.add_submission(sub) util.map_now(add_sub, student.submissions) context = resolver.make_context() plugins = kattis.get_plugins() add_plugin = lambda c, r: resolver.context_add_plugin(context, c, r) util.starmap_now(add_plugin, plugins) result = resolver.resolve(ruleset, context) return make_student_result(student, ruleset, kattis, context, result)
def test_lab(): ruleset = get_ruleset_from_file('test_lab.json') assert len(ruleset.rules) == 1 kattis = aaps.KattisResult() kattis.add_AC('labproblem1', '01-01-2017 08:00') kattis.add_AC('labproblem2', '01-01-2017 07:00') result = resolve_for_result(kattis, ruleset) assert len(result.goals) == 1 assert result.goals[0].points == 2
def test_uppgift(): ruleset = get_ruleset_from_file('test_uppgift.json') assert len(ruleset.rules) == 1 kattis = aaps.KattisResult() kattis.add_AC('helloworld', '01-01-2017 07:00') kattis.add_AC('helloworld2', '01-01-2017 07:00') result = resolve_for_result(kattis, ruleset) assert len(result.goals) == 1 assert result.goals[0].points == 2
def test_lab_with_big_points(): ruleset = get_ruleset_from_file('test_lab_with_big_points.json') assert len(ruleset.rules) == 1 kattis = aaps.KattisResult() kattis.add_AC('labproblem-normal', '01-01-2017 08:00') kattis.add_AC('labproblem-medium', '01-01-2017 08:00') kattis.add_AC('labproblem-big', '01-01-2017 08:00') result = resolve_for_result(kattis, ruleset) assert len(result.goals) == 1 assert result.goals[0].points == 1 + 2 + 42
def test_use_checker_and_handler(): ruleset = get_ruleset_from_file('test_use_checker_and_handler.json') assert len(ruleset.rules) == 2 kattis = aaps.KattisResult() kattis.add_AC('testproblem', '01-01-2017 08:00') kattis.add_WA('testproblem2', '01-01-2017 08:00') result = resolve_for_result(kattis, ruleset) assert len(result.goals) == 2 assert any(goal.points == 1 and goal.id == 'test-problem' for goal in result.goals) assert any(goal.points == 0 and goal.id == 'test-problem-2' for goal in result.goals)