chore: port lab 5 solution into the lab 6 skeleton
Source: mtusi2026lab5-safronov, solution/bvt2301-safronov, 046ec9e. Contracts, public tests and evidence of lab 5 are not carried over. The compose project, image and CI prefix are renamed to lab6; the first broker start defect is recorded in KNOWN_ISSUES.md; PLAN.md outlines the OpenSpec changes of lab 6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
"""Быстрые тесты сервисов: без PostgreSQL, Valkey, S3, брокера, docker и сети.
|
||||
|
||||
`settings` читает `.env` и `config.toml` по абсолютному пути, поэтому поля, от
|
||||
которых зависят ветки сервисов, подставляются здесь: результат не зависит от
|
||||
локальных файлов и окружения (design change `unit-of-work`, решение 13).
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from fakes import (
|
||||
FakeCache,
|
||||
FakeDatabase,
|
||||
FakeJobPublisher,
|
||||
FakeObjectStorage,
|
||||
FakeUnitOfWork,
|
||||
)
|
||||
from src.config import settings
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def anyio_backend() -> str:
|
||||
return "asyncio"
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def fixed_settings(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
fixed = (
|
||||
(
|
||||
settings.worker,
|
||||
{
|
||||
"max_attempts": 3,
|
||||
"job_timeout_seconds": 60,
|
||||
"lease_margin_seconds": 10,
|
||||
"retry_base_delay_seconds": 5,
|
||||
"retry_max_delay_seconds": 300,
|
||||
"reconnect_seconds": 0.01,
|
||||
},
|
||||
),
|
||||
(settings.auth, {"session_ttl_seconds": 3600}),
|
||||
(settings.idempotency, {"ttl_seconds": 86400}),
|
||||
(settings.cache, {"chat_ttl_seconds": 600}),
|
||||
(
|
||||
settings.uploads,
|
||||
{"body_timeout_seconds": 1, "max_unfinished_jobs": 0},
|
||||
),
|
||||
(settings.app, {"instance_id": "test-instance"}),
|
||||
)
|
||||
for section, fields in fixed:
|
||||
for name, value in fields.items():
|
||||
monkeypatch.setattr(section, name, value)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def database() -> FakeDatabase:
|
||||
return FakeDatabase()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def uow(database: FakeDatabase) -> FakeUnitOfWork:
|
||||
return FakeUnitOfWork(database)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cache(database: FakeDatabase) -> FakeCache:
|
||||
return FakeCache(database)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def storage(database: FakeDatabase) -> FakeObjectStorage:
|
||||
return FakeObjectStorage(database)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def publisher(database: FakeDatabase) -> FakeJobPublisher:
|
||||
return FakeJobPublisher(database)
|
||||
Reference in New Issue
Block a user