"""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