Forward the lab 5 foundation while preserving lab 6 telemetry

Source: immutable lab5 snapshot f88e9ba43cdfd7eb6a5a7ae5feb4247b4e820071; forward the allowed diff from 64d5c67. Carry SQLAlchemy, Alembic, reliability fixes, versioned jobs, infrastructure and student tests without changing protected coursework files.

Validation: make check, validate, lint; 515 student tests passed with one Linux-only skip; public smoke with telemetry enabled and repeat migration passed. Stop the owned stack and retain volumes. Preserve the existing OTel work in progress; grade implementation remains a separate phase.
This commit is contained in:
Artyom
2026-11-06 12:29:35 +03:00
parent dc9256baf9
commit 12db77133f
161 changed files with 11160 additions and 1467 deletions
+15 -6
View File
@@ -1,10 +1,13 @@
import asyncio
from urllib.parse import quote
from uuid import uuid4
from uuid import UUID, uuid4
from httpx import AsyncClient
from sqlalchemy import func, select
from conftest import PASSWORD, actor, keyed, make_chat, new_user, register, running_app, scalar
from messenger.identity.infrastructure.postgres import UserRow
from messenger.messaging.infrastructure.postgres import ChatMemberRow, ChatRow
REGISTRATIONS = 25
@@ -65,8 +68,8 @@ async def test_rejected_registration_leaves_no_trace() -> None:
"/api/v1/users", json={"username": "AB", "display_name": "", "password": PASSWORD}
)
assert invalid.status_code == 400
sql = "SELECT count(*) FROM users WHERE username = $1"
assert await scalar(sql, alice["username"]) == 1
sql = select(func.count()).select_from(UserRow).where(UserRow.username == alice["username"])
assert await scalar(sql) == 1
async def test_failed_chat_creation_rolls_back_both_tables() -> None:
@@ -83,9 +86,15 @@ async def test_failed_chat_creation_rolls_back_both_tables() -> None:
assert rejected.json()["error"]["code"] == "invalid_request"
after = (await client.get("/api/v1/chats?limit=100", headers=actor(alice))).json()
assert after["items"] == before["items"]
assert await scalar("SELECT count(*) FROM chats WHERE title = $1", title) == 0
members = "SELECT count(*) FROM chat_members WHERE user_id = $1::uuid"
assert await scalar(members, alice["id"]) == 0
assert (
await scalar(select(func.count()).select_from(ChatRow).where(ChatRow.title == title)) == 0
)
members = (
select(func.count())
.select_from(ChatMemberRow)
.where(ChatMemberRow.user_id == UUID(alice["id"]))
)
assert await scalar(members) == 0
async def test_rejected_message_does_not_enter_history() -> None: