mirror of
https://github.com/dtzp555-max/network-mcp-server.git
synced 2026-07-21 21:15:08 +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>
83 lines
1.9 KiB
Python
83 lines
1.9 KiB
Python
"""Tests for SNMP OID utilities."""
|
|
|
|
from network_mcp.snmp.oids import detect_vendor, format_bytes, format_speed, format_uptime
|
|
|
|
|
|
def test_detect_vendor_cisco():
|
|
assert detect_vendor("Cisco IOS Software, C2960 Software") == "Cisco"
|
|
|
|
|
|
def test_detect_vendor_juniper():
|
|
assert detect_vendor("Juniper Networks, Inc. ex4300") == "Juniper"
|
|
|
|
|
|
def test_detect_vendor_ubiquiti():
|
|
assert detect_vendor("Linux ubnt 4.14.0 UniFi Dream Machine") == "Ubiquiti"
|
|
|
|
|
|
def test_detect_vendor_arista():
|
|
assert detect_vendor("Arista Networks EOS version 4.28") == "Arista"
|
|
|
|
|
|
def test_detect_vendor_fortinet():
|
|
assert detect_vendor("FortiGate-60F v7.2.0") == "Fortinet"
|
|
|
|
|
|
def test_detect_vendor_mikrotik():
|
|
assert detect_vendor("RouterOS 7.12") == "MikroTik"
|
|
|
|
|
|
def test_detect_vendor_unknown():
|
|
assert detect_vendor("Some Unknown Device") == "Unknown"
|
|
|
|
|
|
def test_detect_vendor_case_insensitive():
|
|
assert detect_vendor("CISCO IOS XE") == "Cisco"
|
|
|
|
|
|
def test_format_uptime_days():
|
|
# 2 days, 3 hours, 4 minutes, 5 seconds = 183845 seconds * 100
|
|
assert format_uptime(18384500) == "2d 3h 4m 5s"
|
|
|
|
|
|
def test_format_uptime_hours():
|
|
assert format_uptime(370500) == "1h 1m 45s"
|
|
|
|
|
|
def test_format_uptime_minutes():
|
|
assert format_uptime(12000) == "2m 0s"
|
|
|
|
|
|
def test_format_speed_gbps():
|
|
assert format_speed(1_000_000_000) == "1 Gbps"
|
|
assert format_speed(10_000_000_000) == "10 Gbps"
|
|
|
|
|
|
def test_format_speed_mbps():
|
|
assert format_speed(100_000_000) == "100 Mbps"
|
|
assert format_speed(1_000_000) == "1 Mbps"
|
|
|
|
|
|
def test_format_speed_kbps():
|
|
assert format_speed(64_000) == "64 Kbps"
|
|
|
|
|
|
def test_format_bytes_tb():
|
|
assert "TB" in format_bytes(2_000_000_000_000)
|
|
|
|
|
|
def test_format_bytes_gb():
|
|
assert "GB" in format_bytes(5_000_000_000)
|
|
|
|
|
|
def test_format_bytes_mb():
|
|
assert "MB" in format_bytes(50_000_000)
|
|
|
|
|
|
def test_format_bytes_kb():
|
|
assert "KB" in format_bytes(50_000)
|
|
|
|
|
|
def test_format_bytes_bytes():
|
|
assert format_bytes(500) == "500 B"
|