rsnarsna
feat(config): introduce central env.py credentials provider and integrate with main, mongo, and config
3be6319 Download tests/test_env_credentials.py from Rsnarsna/auto: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/Rsnarsna/auto/resolve/main/tests/test_env_credentials.py
- Command line
-
hf download hf://spaces/Rsnarsna/auto/tests/test_env_credentials.py
-
curl -L -o test_env_credentials.py https://huggingface.co/spaces/Rsnarsna/auto/resolve/main/tests/test_env_credentials.py
1.4 kB
| """ | |
| Unit tests for ALLI Backend central environment configuration (env.py). | |
| """ | |
| import os | |
| import pytest | |
| import env | |
| import config | |
| def test_env_credentials_loaded(): | |
| """Verify all environment credentials and defaults are loaded in env.py.""" | |
| creds = env.get_all_env_credentials() | |
| assert isinstance(creds, dict) | |
| assert "PORT" in creds | |
| assert "SUPABASE_URL" in creds | |
| assert "SUPABASE_KEY" in creds | |
| assert "DATABASE_URL" in creds | |
| assert "MONGODB_URI" in creds | |
| assert "MONGODB_DB_NAME" in creds | |
| assert "STAGE" in creds | |
| def test_env_types_and_defaults(): | |
| """Verify types and format of core configuration variables.""" | |
| assert isinstance(env.PORT, int) | |
| assert env.PORT > 0 | |
| assert isinstance(env.STAGE, str) | |
| assert env.STAGE == "dev" | |
| assert env.SUPABASE_URL.startswith("https://") | |
| assert len(env.SUPABASE_KEY) > 0 | |
| assert env.MONGODB_URI.startswith("mongodb") | |
| assert env.MONGODB_DB_NAME == "alli" | |
| assert isinstance(env.AUTH_REQUIRED, bool) | |
| assert isinstance(env.DEFAULT_EXECUTION_TIMEOUT, float) | |
| def test_config_env_integration(): | |
| """Verify config.py imports and respects env.py variables.""" | |
| assert config.DEFAULT_PORT == env.PORT | |
| assert config.DEFAULT_EXECUTION_TIMEOUT == env.DEFAULT_EXECUTION_TIMEOUT | |
| assert config.DEFAULT_TARGET_LANGUAGE == "python" | |
| assert config.DEFAULT_TARGET_VERSION == "3.12" | |