Add initial web editor app, CLI scripts, and test scaffolding.
This introduces the FastAPI editor implementation and related project setup so the app can be run and validated locally. Made-with: Cursor
This commit is contained in:
36
tests/test_completion_api.py
Normal file
36
tests/test_completion_api.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_python_completion_returns_basic_suggestions(tmp_path):
|
||||
editor_dir = Path(__file__).resolve().parents[1]
|
||||
src_dir = editor_dir / "src"
|
||||
if str(src_dir) not in sys.path:
|
||||
sys.path.insert(0, str(src_dir))
|
||||
|
||||
os.environ["WORKSPACE_ROOT"] = str(tmp_path)
|
||||
import app as editor_app
|
||||
|
||||
editor_app = importlib.reload(editor_app)
|
||||
editor_app.WORKSPACE_ROOT = tmp_path
|
||||
client = TestClient(editor_app.app)
|
||||
|
||||
response = client.post(
|
||||
"/api/python/completions",
|
||||
json={
|
||||
"file_path": "example.py",
|
||||
"content": "import os\nos.pa",
|
||||
"line": 2,
|
||||
"column": 5,
|
||||
"max_results": 20,
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
names = [item["name"] for item in body["completions"]]
|
||||
assert "path" in names
|
||||
Reference in New Issue
Block a user