Spaces:
Running
Running
File size: 6,162 Bytes
1080e14 | 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | """Utility: rewrite all 9 repo fixture files to exact PRD content."""
import json
import pathlib
ROOT = pathlib.Path(__file__).resolve().parent.parent
# ββ payments_repo βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(ROOT / "server/repos/payments_repo/broken.py").write_text(
"import stripe\n"
"\n"
'stripe.api_key = "sk_test_REPLACE_ME"\n'
"\n"
"\n"
"def charge_customer(amount_inr: int, customer_id: str) -> dict:\n"
' """Charge an INR amount to a customer. Returns {id, status}."""\n'
" charge = stripe.Charge.create(\n"
" amount=amount_inr * 100, # paise\n"
' currency="inr",\n'
" customer=customer_id,\n"
" )\n"
' return {"id": charge.id, "status": charge.status}\n',
encoding="utf-8",
)
(ROOT / "server/repos/payments_repo/tests.json").write_text(
json.dumps(
{
"test_basic_charge": {
"args": [100, "cust_001"],
"expected": {
"id": {"type": "str", "contains": "cust_001"},
"status": {"type": "str"},
},
},
"test_zero_amount": {
"args": [0, "cust_002"],
"expected": {
"status": {"type": "str", "equals": "failed"},
},
},
"test_large_amount": {
"args": [50000, "cust_003"],
"expected": {
"id": {"type": "str", "contains": "5000000"},
"status": {"type": "str"},
},
},
},
indent=2,
),
encoding="utf-8",
)
(ROOT / "server/repos/payments_repo/meta.json").write_text(
json.dumps(
{
"repo_id": "payments_repo",
"deprecated_sdk": "stripe",
"ground_truth_replacement": "razorpay",
"category": "payments",
"entrypoint": "charge_customer",
"error_log": (
"ImportError: stripe SDK suspended for IN region "
"(sanctions notice 2026-04). All inbound traffic blocked at gateway."
),
},
indent=2,
),
encoding="utf-8",
)
# ββ maps_repo βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(ROOT / "server/repos/maps_repo/broken.py").write_text(
"import googlemaps\n"
"\n"
"\n"
"def address_to_coords(address: str) -> dict:\n"
' """Geocode an address. Returns {lat, lng}."""\n'
' client = googlemaps.Client(key="GMAPS_KEY")\n'
" result = client.geocode(address)\n"
' loc = result[0]["geometry"]["location"]\n'
' return {"lat": loc["lat"], "lng": loc["lng"]}\n',
encoding="utf-8",
)
(ROOT / "server/repos/maps_repo/tests.json").write_text(
json.dumps(
{
"test_bangalore": {
"args": ["MG Road, Bangalore"],
"expected": {"lat": {"type": "float"}, "lng": {"type": "float"}},
},
"test_mumbai": {
"args": ["Marine Drive, Mumbai"],
"expected": {"lat": {"type": "float"}, "lng": {"type": "float"}},
},
"test_chennai": {
"args": ["Marina Beach, Chennai"],
"expected": {"lat": {"type": "float"}, "lng": {"type": "float"}},
},
},
indent=2,
),
encoding="utf-8",
)
(ROOT / "server/repos/maps_repo/meta.json").write_text(
json.dumps(
{
"repo_id": "maps_repo",
"deprecated_sdk": "googlemaps",
"ground_truth_replacement": "mmi_sdk",
"category": "maps",
"entrypoint": "address_to_coords",
"error_log": (
"googlemaps.exceptions.ApiError: 403 \u2014 Maps Platform key "
"revoked for IN region per regulatory action 2026-Q2."
),
},
indent=2,
),
encoding="utf-8",
)
# ββ comms_repo ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(ROOT / "server/repos/comms_repo/broken.py").write_text(
"from twilio.rest import Client\n"
"\n"
"\n"
"def send_otp(phone: str, code: str) -> dict:\n"
' """Send a one-time password via SMS. Returns {sid, status}."""\n'
' client = Client("ACxxx", "auth_xxx")\n'
" msg = client.messages.create(\n"
' to=phone, from_="+1555TWILIO", body=f"OTP: {code}"\n'
" )\n"
' return {"sid": msg.sid, "status": msg.status}\n',
encoding="utf-8",
)
(ROOT / "server/repos/comms_repo/tests.json").write_text(
json.dumps(
{
"test_indian_number": {
"args": ["+919876543210", "123456"],
"expected": {"sid": {"type": "str"}, "status": {"type": "str"}},
},
"test_short_code": {
"args": ["+919999000011", "00000"],
"expected": {"sid": {"type": "str"}},
},
"test_long_otp": {
"args": ["+918000000001", "987654"],
"expected": {"status": {"type": "str"}},
},
},
indent=2,
),
encoding="utf-8",
)
(ROOT / "server/repos/comms_repo/meta.json").write_text(
json.dumps(
{
"repo_id": "comms_repo",
"deprecated_sdk": "twilio",
"ground_truth_replacement": "kaleyra",
"category": "messaging",
"entrypoint": "send_otp",
"error_log": (
"TwilioRestException: HTTP 451 Unavailable For Legal Reasons. "
"Cross-border SMS gateway disabled."
),
},
indent=2,
),
encoding="utf-8",
)
print("All 9 fixture files written successfully.")
|