kin: BATON-ARCH-010 Написать unit-тесты бэкенда (tester FAILED без вывода)
This commit is contained in:
parent
59eb117589
commit
8012cb1c0f
5 changed files with 49 additions and 5 deletions
|
|
@ -13,7 +13,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||
from fastapi.responses import JSONResponse
|
||||
|
||||
from backend import config, db, telegram
|
||||
from backend.middleware import verify_webhook_secret
|
||||
from backend.middleware import rate_limit_register, verify_webhook_secret
|
||||
from backend.models import (
|
||||
RegisterRequest,
|
||||
RegisterResponse,
|
||||
|
|
@ -45,6 +45,7 @@ async def _keep_alive_loop(app_url: str) -> None:
|
|||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# Startup
|
||||
app.state.rate_counters = {}
|
||||
await db.init_db()
|
||||
logger.info("Database initialized")
|
||||
|
||||
|
|
@ -100,7 +101,7 @@ async def health() -> dict[str, Any]:
|
|||
|
||||
|
||||
@app.post("/api/register", response_model=RegisterResponse)
|
||||
async def register(body: RegisterRequest) -> RegisterResponse:
|
||||
async def register(body: RegisterRequest, _: None = Depends(rate_limit_register)) -> RegisterResponse:
|
||||
result = await db.register_user(uuid=body.uuid, name=body.name)
|
||||
return RegisterResponse(user_id=result["user_id"], uuid=result["uuid"])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue