Forward-port lab3 SQLAlchemy and Alembic foundation
Carry sourcef591fa64e5forward from72a1e57. Preserve lab4 attachment transactions, reconciliation locks, quarantine, and existing schema data through verified legacy adoption. Keep report and evidence work in progress untouched.
This commit is contained in:
@@ -2,14 +2,16 @@ import asyncio
|
||||
import time
|
||||
from datetime import datetime
|
||||
from hashlib import sha256
|
||||
from uuid import UUID
|
||||
|
||||
import pytest
|
||||
from redis.asyncio import Redis
|
||||
from sqlalchemy import select
|
||||
|
||||
from conftest import actor, bearer, keyed, make_chat, register, resolve, running_app, scalar
|
||||
from messenger.identity.application.ports import SessionDirectory
|
||||
from messenger.identity.domain.models import Session
|
||||
from messenger.identity.infrastructure.postgres import PostgresSessionRepository
|
||||
from messenger.identity.infrastructure.postgres import PostgresSessionRepository, SessionRow
|
||||
from messenger.identity.infrastructure.valkey import CachedSessionDirectory
|
||||
from messenger.shared.application.errors import Unavailable
|
||||
|
||||
@@ -34,8 +36,9 @@ async def test_second_check_is_served_from_cache(valkey: dict[str, str]) -> None
|
||||
assert (await cache.info("stats"))["keyspace_hits"] == hits + 1
|
||||
key = key_of(token_of(alice))
|
||||
stored = str(await cache.get(key))
|
||||
sql = "SELECT expires_at FROM sessions WHERE user_id = $1::uuid"
|
||||
expires_at: datetime = await scalar(sql, alice["id"])
|
||||
expires_at: datetime = await scalar(
|
||||
select(SessionRow.expires_at).where(SessionRow.user_id == UUID(alice["id"]))
|
||||
)
|
||||
assert alice["id"] in stored and token_of(alice) not in stored
|
||||
assert await cache.pexpiretime(key) <= int(expires_at.timestamp() * 1000)
|
||||
await cache.aclose()
|
||||
|
||||
Reference in New Issue
Block a user