Download tests/test_production_config.py from sitcod3/modul-x: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/sitcod3/modul-x/resolve/main/tests/test_production_config.py
- Command line
-
hf download hf://spaces/sitcod3/modul-x/tests/test_production_config.py
-
curl -L -o test_production_config.py https://huggingface.co/spaces/sitcod3/modul-x/resolve/main/tests/test_production_config.py
1.64 kB
| import unittest | |
| from pydantic import ValidationError | |
| from app.config import Settings | |
| class ProductionSettingsTests(unittest.TestCase): | |
| def test_production_accepts_explicit_secure_configuration(self): | |
| settings = Settings( | |
| _env_file=None, | |
| app_environment="production", | |
| debug=False, | |
| license_enforcement="true", | |
| supabase_url="https://project.example", | |
| supabase_service_role_key="server-only-key", | |
| cors_origins=["https://app.example.com"], | |
| ) | |
| self.assertEqual(settings.app_environment, "production") | |
| def test_production_rejects_demo_or_insecure_configuration(self): | |
| with self.assertRaisesRegex( | |
| ValidationError, | |
| "DEBUG must be false.*LICENSE_ENFORCEMENT must be true.*" | |
| "SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are required.*" | |
| "CORS_ORIGINS must contain only HTTPS origins", | |
| ): | |
| Settings( | |
| _env_file=None, | |
| app_environment="production", | |
| debug=True, | |
| license_enforcement="false", | |
| cors_origins=["http://localhost:5173"], | |
| ) | |
| def test_development_keeps_demo_configuration_available(self): | |
| settings = Settings( | |
| _env_file=None, | |
| app_environment="development", | |
| license_enforcement="false", | |
| cors_origins=["http://localhost:5173"], | |
| ) | |
| self.assertEqual(settings.license_enforcement, "false") | |
| if __name__ == "__main__": | |
| unittest.main() | |