- profiler: Literal instead of Query(enum=...) (broke on FastAPI 0.162) - pin fastapi/starlette/uvicorn/pydantic for the profiler, upper bounds for APP_CORE - health check: show the service log when an HTTP check fails - update.sh: the "before" version comes from deploy.state - migrate.py: hint about OVPMON_*_DB_PATH when the default database is missing - docs: --source --no-pull mode, dependency pinning, PIP_CONSTRAINT - tests: new test for the section parameter, fixed test_server_process.py Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
28 lines
766 B
Python
28 lines
766 B
Python
import os
|
|
import tempfile
|
|
|
|
# The DB path must be set before database.py is imported (via main)
|
|
_tmp = tempfile.TemporaryDirectory()
|
|
os.environ["OVPMON_PROFILER_DB_PATH"] = os.path.join(_tmp.name, "test.db")
|
|
|
|
from fastapi.testclient import TestClient
|
|
from main import app
|
|
from utils.auth import verify_token
|
|
|
|
app.dependency_overrides[verify_token] = lambda: {"sub": "test"}
|
|
client = TestClient(app)
|
|
|
|
|
|
def test_get_stats():
|
|
response = client.get("/api/server/process/stats")
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
assert "pid" in data
|
|
assert "cpu_percent" in data
|
|
assert "memory_mb" in data
|
|
|
|
|
|
def test_control_invalid():
|
|
response = client.post("/api/server/process/invalid_action")
|
|
assert response.status_code == 400
|