Files
connectionmachine/tests/test_completion_api.py
Jimmy f9bf119af6 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
2026-04-11 02:14:26 +12:00

37 lines
953 B
Python

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