mirror of
https://github.com/dtzp555-max/network-mcp-server.git
synced 2026-07-19 09:43:07 +00:00
MVP with zero-dependency SNMP backend for AI-powered network management: - get_snmp_value: query single OID - walk_snmp_tree: walk OID subtree - get_device_info: vendor auto-detection, uptime, location - get_interfaces: interface status with human-readable output - discover_devices: subnet SNMP discovery Tech: FastMCP + pysnmp-lextudio, Python 3.10+ Works with: Cisco, Juniper, Arista, UniFi, Fortinet, and any SNMP device 23 tests passing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
829 B
Python
28 lines
829 B
Python
"""Tests for configuration module."""
|
|
|
|
import os
|
|
|
|
from network_mcp.config import get_default_community, get_snmp_timeout
|
|
|
|
|
|
def test_default_community_from_env(monkeypatch):
|
|
monkeypatch.setenv("SNMP_COMMUNITY", "my_secret")
|
|
assert get_default_community() == "my_secret"
|
|
|
|
|
|
def test_default_community_fallback(monkeypatch):
|
|
monkeypatch.delenv("SNMP_COMMUNITY", raising=False)
|
|
# Without config file, should return "public"
|
|
monkeypatch.setenv("NETWORK_MCP_CONFIG_DIR", "/tmp/nonexistent-mcp-test")
|
|
assert get_default_community() == "public"
|
|
|
|
|
|
def test_snmp_timeout_from_env(monkeypatch):
|
|
monkeypatch.setenv("SNMP_TIMEOUT", "10.0")
|
|
assert get_snmp_timeout() == 10.0
|
|
|
|
|
|
def test_snmp_timeout_default(monkeypatch):
|
|
monkeypatch.delenv("SNMP_TIMEOUT", raising=False)
|
|
assert get_snmp_timeout() == 5.0
|