Тесты по модулям предметных областей

Пункт 12 ревью 2026-09-28 17:35 (docs/changes/026): tests/test_app.py
(936 строк) разнесён на test_security, test_devices, test_operations,
test_backups, test_events, test_ids_migrations, test_architecture; общие
хелперы — tests/helpers.py. Тела тестов не менялись (AST совпадает).
security.reset_all_failures() — фикстура сбрасывает счётчики попыток по
всем ключам, тесты не зависят от порядка.

Тесты: 36 из 36 полным прогоном, каждый модуль отдельно и в обратном
порядке; тест-линтер после переноса проверен мутацией.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Opus 5.5 committed 2026-09-28 21:30:23 +03:00
1 parent 5367cb5e9c
commit e1f197ccff
14 files changed
+1133 -995

No files matched your search

+7
View File
@@ -109,6 +109,13 @@ def reset_failures(key: str) -> None:
_locked_until.pop(key, None)
def reset_all_failures() -> None:
"""Сбрасывает счётчики неудачных попыток по всем ключам (для тестов и будущего администрирования)."""
with _guard:
_fails.clear()
_locked_until.clear()
async def require_api_token(cred: HTTPAuthorizationCredentials | None = Depends(_bearer)) -> None:
expected = get_settings().api_token
if cred is None or not hmac.compare_digest(cred.credentials.encode(), expected.encode()):