mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 22:59:59 -07:00
- 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>
74 lines
2.4 KiB
Python
74 lines
2.4 KiB
Python
"""Tests for utility modules."""
|
|
|
|
import pytest
|
|
from utils.process import is_valid_mac, is_valid_channel
|
|
from utils.dependencies import check_tool
|
|
from data.oui import get_manufacturer
|
|
|
|
|
|
class TestMacValidation:
|
|
"""Tests for MAC address validation."""
|
|
|
|
def test_valid_mac(self):
|
|
"""Test valid MAC addresses."""
|
|
assert is_valid_mac('AA:BB:CC:DD:EE:FF') is True
|
|
assert is_valid_mac('aa:bb:cc:dd:ee:ff') is True
|
|
assert is_valid_mac('00:11:22:33:44:55') is True
|
|
|
|
def test_invalid_mac(self):
|
|
"""Test invalid MAC addresses."""
|
|
assert is_valid_mac('') is False
|
|
assert is_valid_mac(None) is False
|
|
assert is_valid_mac('invalid') is False
|
|
assert is_valid_mac('AA:BB:CC:DD:EE') is False
|
|
assert is_valid_mac('AA-BB-CC-DD-EE-FF') is False
|
|
|
|
|
|
class TestChannelValidation:
|
|
"""Tests for WiFi channel validation."""
|
|
|
|
def test_valid_channels(self):
|
|
"""Test valid channel numbers."""
|
|
assert is_valid_channel(1) is True
|
|
assert is_valid_channel(6) is True
|
|
assert is_valid_channel(11) is True
|
|
assert is_valid_channel('36') is True
|
|
assert is_valid_channel(149) is True
|
|
|
|
def test_invalid_channels(self):
|
|
"""Test invalid channel numbers."""
|
|
assert is_valid_channel(0) is False
|
|
assert is_valid_channel(-1) is False
|
|
assert is_valid_channel(201) is False
|
|
assert is_valid_channel(None) is False
|
|
assert is_valid_channel('invalid') is False
|
|
|
|
|
|
class TestToolCheck:
|
|
"""Tests for tool availability checking."""
|
|
|
|
def test_common_tools(self):
|
|
"""Test checking for common tools."""
|
|
# These should return bool, regardless of whether installed
|
|
assert isinstance(check_tool('ls'), bool)
|
|
assert isinstance(check_tool('nonexistent_tool_12345'), bool)
|
|
|
|
def test_nonexistent_tool(self):
|
|
"""Test that nonexistent tools return False."""
|
|
assert check_tool('nonexistent_tool_xyz_12345') is False
|
|
|
|
|
|
class TestOuiLookup:
|
|
"""Tests for OUI manufacturer lookup."""
|
|
|
|
def test_known_manufacturer(self):
|
|
"""Test looking up known manufacturers."""
|
|
# Apple prefix
|
|
result = get_manufacturer('00:25:DB:AA:BB:CC')
|
|
assert result == 'Apple' or result == 'Unknown'
|
|
|
|
def test_unknown_manufacturer(self):
|
|
"""Test looking up unknown manufacturer."""
|
|
result = get_manufacturer('FF:FF:FF:FF:FF:FF')
|
|
assert result == 'Unknown'
|