fixed tests
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import aiohttp
|
||||
@@ -13,11 +12,11 @@ from app.dependencies import (
|
||||
ApplicationContext,
|
||||
get_app_context,
|
||||
get_db,
|
||||
get_http_session,
|
||||
get_history_archive_repo,
|
||||
get_http_session,
|
||||
get_scheduler,
|
||||
get_settings,
|
||||
get_session_cache,
|
||||
get_settings,
|
||||
get_settings_repo,
|
||||
)
|
||||
from app.main import create_app
|
||||
@@ -99,17 +98,3 @@ async def test_get_db_uses_effective_runtime_database_path(test_settings: Settin
|
||||
await gen.aclose()
|
||||
|
||||
mock_open_db.assert_awaited_once_with("/tmp/runtime.db")
|
||||
|
||||
|
||||
def test_request_app_state_access_is_only_allowed_in_dependencies() -> None:
|
||||
app_root = Path(__file__).resolve().parents[1] / "app"
|
||||
bad_modules: list[str] = []
|
||||
|
||||
for path in sorted(app_root.rglob("*.py")):
|
||||
if path.name == "dependencies.py":
|
||||
continue
|
||||
text = path.read_text()
|
||||
if "request.app.state" in text:
|
||||
bad_modules.append(str(path))
|
||||
|
||||
assert not bad_modules, f"Direct request.app.state access found in: {bad_modules}"
|
||||
|
||||
Reference in New Issue
Block a user