Forward the lab 4 foundation and migrate the lab 5 pipeline to SQLAlchemy

This commit is contained in:
Artyom
2026-11-06 09:12:25 +03:00
parent ae9f60fe1f
commit 1217da5f5e
134 changed files with 8243 additions and 1409 deletions
+4 -7
View File
@@ -4,12 +4,11 @@ import re
from typing import Any
from uuid import uuid4
import asyncpg
import pytest
from httpx import AsyncClient
from test_attachments import storage, trio, upload
from conftest import DATABASE, actor
from conftest import actor, sql_connection
from messenger.attachments.application.pipeline import TRANSIENT_ERROR
from messenger.attachments.application.ports import Rendition
from messenger.attachments.domain.errors import ImageTooDemanding
@@ -21,11 +20,9 @@ from pipeline import pipeline_of
async def rows(sql: str, *args: Any) -> list[dict[str, Any]]:
connection = await asyncpg.connect(DATABASE["url"])
try:
return [dict(row) for row in await connection.fetch(sql, *args)]
finally:
await connection.close()
async with sql_connection() as connection:
result = await connection.exec_driver_sql(sql, args)
return [dict(row) for row in result.mappings()] if result.returns_rows else []
async def accepted(http: AsyncClient) -> tuple[dict[str, Any], dict[str, Any], str]: