feat: add POST /format endpoint

This commit is contained in:
2026-06-14 06:57:55 -06:00
parent b0a7ac9503
commit 8d40a7b2f0
3 changed files with 49 additions and 1 deletions

18
test_main.py Normal file
View File

@@ -0,0 +1,18 @@
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_format_endpoint_formats_python_code():
response = client.post("/format", json={"code": "x=1\n", "language": "python"})
assert response.status_code == 200
assert response.json() == {"code": "x = 1\n"}
def test_format_endpoint_returns_400_on_syntax_error():
response = client.post(
"/format", json={"code": "def foo(:\n", "language": "python"}
)
assert response.status_code == 400