e4719cb9ae
Manual entry now takes one parent's sjukpenningnivå, lägstanivå and dubbeldagar left (plus optional reserved days) and derives the rest in build_snapshot, shared with the scraper. The scraper also reads the family panel and exposes a partner deduction; with two parents it is saved as a 'deduced' snapshot (migration 002). Parent count is the single source of entitlement: one member gets 480 days and 96 savable at age 4, two get 240 and 48 each. Workspaces are capped at two parents. Also lands the in-flight squash of migrations 002–011 into the initial schema and the removal of planning_mode. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
"""Tests for Settings' production hardening validator.
|
|
|
|
Never mutates the module-level `settings` singleton — constructs fresh
|
|
`Settings()` instances instead, passing kwargs directly (bypassing env/file
|
|
loading concerns) so these tests are isolated from the process environment.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from app.config import Settings
|
|
|
|
|
|
class TestProductionJwtSecretValidation:
|
|
def test_development_allows_default_secret(self) -> None:
|
|
settings = Settings(app_env="development")
|
|
assert settings.jwt_secret == "dev-secret-change-in-production-min-32-chars"
|
|
|
|
def test_test_env_allows_default_secret(self) -> None:
|
|
settings = Settings(app_env="test")
|
|
assert settings.app_env == "test"
|
|
|
|
def test_production_rejects_default_secret(self) -> None:
|
|
with pytest.raises(ValueError, match="APP_JWT_SECRET"):
|
|
Settings(app_env="production")
|
|
|
|
def test_production_rejects_short_secret(self) -> None:
|
|
with pytest.raises(ValueError, match="APP_JWT_SECRET"):
|
|
Settings(app_env="production", jwt_secret="short-secret")
|
|
|
|
def test_production_accepts_strong_secret(self) -> None:
|
|
strong_secret = "a" * 32
|
|
settings = Settings(app_env="production", jwt_secret=strong_secret)
|
|
assert settings.jwt_secret == strong_secret
|
|
|
|
def test_default_app_env_is_development(self) -> None:
|
|
settings = Settings()
|
|
assert settings.app_env == "development"
|
|
|
|
def test_default_log_level_is_info(self) -> None:
|
|
settings = Settings()
|
|
assert settings.log_level == "INFO"
|
|
|
|
|
|
class TestScraperDebugDumpOnSuccess:
|
|
def test_defaults_to_false(self) -> None:
|
|
settings = Settings()
|
|
assert settings.scraper_debug_dump_on_success is False
|
|
|
|
def test_can_be_enabled(self) -> None:
|
|
settings = Settings(scraper_debug_dump_on_success=True)
|
|
assert settings.scraper_debug_dump_on_success is True
|