File size: 2,590 Bytes
d51679d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
TASKS = {
    "task_1_easy": {
        "difficulty": "easy",
        "starting_files": {
            "main.py": (
                "import sys\n"
                "<<<<<<< HEAD\n"
                "import logging\n"
                "=======\n"
                "import json\n"
                ">>>>>>> feature-branch\n\n"
                "def do_work():\n"
                "    pass\n"
            )
        },
        "hidden_test": (
            "import sys\n"
            "assert 'logging' in sys.modules, 'Missing logging import'\n"
            "assert 'json' in sys.modules, 'Missing json import'\n"
            "print('SUCCESS')"
        )
    },
    
    "task_2_medium": {
        "difficulty": "medium",
        "starting_files": {
            "cart.py": (
                "def calculate_total(cart):\n"
                "<<<<<<< HEAD\n"
                "    total = sum(item['price'] for item in cart)\n"
                "    return total + calculate_tax(total)\n"
                "=======\n"
                "    return sum(item['price'] * 1.15 for item in cart if item['is_taxable'])\n"
                ">>>>>>> new-tax-logic\n\n"
                "def calculate_tax(amount):\n"
                "    return amount * 0.15\n"
            )
        },
        "hidden_test": (
            "from cart import calculate_total\n"
            "cart =[{'price': 100, 'is_taxable': True}, {'price': 50, 'is_taxable': False}]\n"
            "result = calculate_total(cart)\n"
            "assert result == 165.0, f'Expected 165.0, got {result}'\n"
            "print('SUCCESS')"
        )
    },
    
    "task_3_hard": {
        "difficulty": "hard",
        "starting_files": {
            "api.py": (
                "<<<<<<< HEAD\n"
                "def fetch_user(user_id):\n"
                "=======\n"
                "def getUser(user_id):\n"
                ">>>>>>> rename-refactor\n"
                "    return {'id': user_id, 'name': 'Alice'}\n"
            ),
            "router.py": (
                "# Notice: Dev B added this route using the old naming convention.\n"
                "from api import getUser\n\n"
                "def route_get_user(req_id):\n"
                "    return getUser(req_id)\n"
            )
        },
        "hidden_test": (
            "from router import route_get_user\n"
            "from api import fetch_user\n"
            "assert fetch_user(1)['name'] == 'Alice', 'fetch_user must exist'\n"
            "assert route_get_user(1)['name'] == 'Alice', 'router must function correctly'\n"
            "print('SUCCESS')"
        )
    }
}