Files
intercept/tests/test_config.py
James Smith ddeff002c9 Refactor into modular structure with improvements
- Split monolithic intercept.py (15k lines) into modular structure:
  - routes/ - Flask blueprints for each feature
  - templates/ - Jinja2 HTML templates
  - data/ - OUI database, satellite TLEs, detection patterns
  - utils/ - dependencies, process management, logging
  - config.py - centralized configuration with env var support

- Add type hints to function signatures
- Replace bare except clauses with specific exceptions
- Add proper logging module (replaces print statements)
- Add environment variable support (INTERCEPT_* prefix)
- Add test suite with pytest
- Add Dockerfile for containerized deployment
- Add pyproject.toml with ruff/black/mypy config
- Add requirements-dev.txt for development dependencies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 16:28:48 +00:00

49 lines
1.3 KiB
Python

"""Tests for configuration module."""
import os
import pytest
class TestConfigEnvVars:
"""Tests for environment variable configuration."""
def test_default_values(self):
"""Test that default values are set."""
from config import PORT, HOST, DEBUG
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)