mirror of
https://github.com/smittix/intercept.git
synced 2026-07-06 00:28:12 -07:00
96172ca593
First-time run of ruff-format via pre-commit hook normalises quote style, trailing commas, and whitespace across 188 Python files. No logic changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
"""Tests for configuration module."""
|
|
|
|
|
|
class TestConfigEnvVars:
|
|
"""Tests for environment variable configuration."""
|
|
|
|
def test_default_values(self):
|
|
"""Test that default values are set."""
|
|
from config import DEBUG, HOST, PORT
|
|
|
|
assert PORT == 5050
|
|
assert HOST == "0.0.0.0"
|
|
assert DEBUG is False
|
|
|
|
def test_env_override(self, monkeypatch):
|
|
"""Test that environment variables override defaults."""
|
|
monkeypatch.setenv("INTERCEPT_PORT", "8080")
|
|
monkeypatch.setenv("INTERCEPT_DEBUG", "true")
|
|
|
|
# Re-import to get new values
|
|
import importlib
|
|
|
|
import config
|
|
|
|
importlib.reload(config)
|
|
|
|
assert config.PORT == 8080
|
|
assert config.DEBUG is True
|
|
|
|
# Reset
|
|
monkeypatch.delenv("INTERCEPT_PORT", raising=False)
|
|
monkeypatch.delenv("INTERCEPT_DEBUG", raising=False)
|
|
importlib.reload(config)
|
|
|
|
def test_invalid_env_values(self, monkeypatch):
|
|
"""Test that invalid env values fall back to defaults."""
|
|
monkeypatch.setenv("INTERCEPT_PORT", "invalid")
|
|
|
|
import importlib
|
|
|
|
import config
|
|
|
|
importlib.reload(config)
|
|
|
|
# Should fall back to default
|
|
assert config.PORT == 5050
|
|
|
|
monkeypatch.delenv("INTERCEPT_PORT", raising=False)
|
|
importlib.reload(config)
|