The API image ran four uvicorn workers, and each one built a full flow controller — four sets of MQTT subscriptions, cron ticks and webhooks. Runs one worker now; scaling out is the worker split, not more processes. Adds a loop-lag watchdog and a deep /utils/health/ that fails when the event loop is wedged or Redis is unreachable, the two failure modes a process-alive check never sees. Autoheal restarts on that signal, behind a compose profile because it mounts the Docker socket. The private user-seeding routes now need an explicit opt-in rather than just ENVIRONMENT=local, so a deployment that kept the default never exposes them. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011LF61rxW1FG5YCD2J9YqjY
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
import pytest
|
|
from fastapi.testclient import TestClient
|
|
from sqlmodel import Session, select
|
|
|
|
from app.core.config import settings
|
|
from app.models import User
|
|
|
|
|
|
def test_create_user(client: TestClient, db: Session) -> None:
|
|
r = client.post(
|
|
f"{settings.API_V1_STR}/private/users/",
|
|
json={
|
|
"email": "pollo@listo.com",
|
|
"password": "password123",
|
|
"full_name": "Pollo Listo",
|
|
},
|
|
)
|
|
|
|
assert r.status_code == 200
|
|
|
|
data = r.json()
|
|
|
|
user = db.exec(select(User).where(User.id == data["id"])).first()
|
|
|
|
assert user
|
|
assert user.email == "pollo@listo.com"
|
|
assert user.full_name == "Pollo Listo"
|
|
|
|
|
|
def test_creating_a_user_is_refused_unless_the_private_api_is_enabled(
|
|
client: TestClient, monkeypatch: pytest.MonkeyPatch
|
|
) -> None:
|
|
"""The route is always mounted so the SDK keeps its shape; the opt-in is
|
|
what decides whether unauthenticated user seeding actually works."""
|
|
monkeypatch.setattr(settings, "PRIVATE_API_ENABLED", False)
|
|
|
|
r = client.post(
|
|
f"{settings.API_V1_STR}/private/users/",
|
|
json={
|
|
"email": "nobody@listo.com",
|
|
"password": "password123",
|
|
"full_name": "Nobody",
|
|
},
|
|
)
|
|
|
|
assert r.status_code == 403
|