Move runtime application state into a dedicated runtime state manager
This commit is contained in:
@@ -60,6 +60,28 @@ def test_create_app_skips_cors_when_no_origins_are_configured() -> None:
|
||||
assert cors_middleware == []
|
||||
|
||||
|
||||
def test_create_app_initialises_runtime_state_manager() -> None:
|
||||
"""The FastAPI app exposes a dedicated runtime state manager on app.state."""
|
||||
settings = Settings(
|
||||
database_path="/tmp/test.db",
|
||||
fail2ban_socket="/tmp/fake_fail2ban.sock",
|
||||
fail2ban_config_dir="/tmp/fail2ban",
|
||||
session_secret="test-secret-key-do-not-use-in-production",
|
||||
session_duration_minutes=60,
|
||||
timezone="UTC",
|
||||
log_level="debug",
|
||||
)
|
||||
|
||||
app = create_app(settings=settings)
|
||||
runtime_state = app.state.runtime_state
|
||||
|
||||
assert runtime_state.setup_complete_cached is False
|
||||
assert runtime_state.server_status.online is False
|
||||
assert runtime_state.pending_recovery is None
|
||||
assert runtime_state.last_activation is None
|
||||
assert app.state.server_status.online is False
|
||||
|
||||
|
||||
def test_create_app_disables_cors_by_default() -> None:
|
||||
"""The FastAPI app does not add CORS middleware when no origins are configured by environment."""
|
||||
settings = Settings(
|
||||
|
||||
Reference in New Issue
Block a user