summaryrefslogtreecommitdiff
path: root/tests/conftest.py
blob: ab3003be73cbe34891a3505692f37e35a130908a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from __future__ import annotations

import copy

import pytest

from gap_pipeline.models import CanonicalItem


@pytest.fixture
def item() -> CanonicalItem:
    return CanonicalItem(
        item_id="demo-A-1",
        problem=r"Let \(a>0\). Prove that \(a+1/a\ge 2\).",
        solution=(
            r"Since \((a-1)^2\ge0\), expanding gives \(a^2-2a+1\ge0\). "
            r"Divide by \(a>0\) to obtain \(a+1/a\ge2\)."
        ),
        variables=["a"],
        problem_type="proof",
    )


@pytest.fixture
def plan_dict() -> dict:
    return {
        "core_steps": [
            "use nonnegativity of a square",
            "expand and divide by a positive quantity",
        ],
        "mutable_slots": {
            "slot1": {
                "description": "the positive reference value",
                "original": "1",
            }
        },
    }


@pytest.fixture
def candidate_dict() -> dict:
    return {
        "question": "Let x>0. Prove that x+4/x >= 4.",
        "solution": (
            "Since (x-2)^2 >= 0, expand and divide by x>0 "
            "to get x+4/x >= 4."
        ),
    }


def changed_candidate(candidate: dict, suffix: str) -> dict:
    value = copy.deepcopy(candidate)
    value["question"] = value["question"] + f" [{suffix}]"
    value["solution"] = value["solution"] + f" Repair {suffix}."
    return value